Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug that prevented using directory names with spaces in WiX #1160

Merged
merged 1 commit into from
Mar 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/FakeLib/WiXHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ let getFileIdFromWiXString wiXString fileRegex =
|> Seq.filter(fun line -> Regex.IsMatch(line, "Name=\"" + fileRegex + "\""))
|> Seq.head
// Substring starts immediately after "Id=" tag and is as long as the given file id
|> fun f -> f.Substring(f.IndexOf("Id=") + 4, Regex.Match(f, "Id=\"\S*\"").Length - 5)
|> fun f -> f.Substring(f.IndexOf("Id=") + 4, Regex.Match(f, "Id=\"[^\"]*\"").Length - 5)


/// Retrieves all component ids from given WiX directory string
Expand All @@ -617,7 +617,7 @@ let getComponentIdsFromWiXString wiXString =
// Filter for lines which have a name tag matching the given regex, pick the first and return its ID
lines
|> Seq.filter(fun line -> Regex.IsMatch(line, "<Component"))
|> Seq.map(fun f -> sprintf "<ComponentRef Id=\"%s\" />" (f.Substring(f.IndexOf("Id=") + 4, Regex.Match(f, "Id=\"\S*\"").Length - 5)))
|> Seq.map(fun f -> sprintf "<ComponentRef Id=\"%s\" />" (f.Substring(f.IndexOf("Id=") + 4, Regex.Match(f, "Id=\"[^\"]*\"").Length - 5)))
|> System.String.Concat

/// Creates WiX ComponentRef tags from the given DirectoryInfo
Expand Down
39 changes: 39 additions & 0 deletions src/test/Test.FAKECore/WiXHelperSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,43 @@ internal class When_creating_a_WiDir
private It should_return_a_proper_XML_tag_on_method_call_ToString = () => Arguments.ToString()
.ShouldContain("<Directory Id=\"1\" Name=\"Foo\"></Directory");
}

internal class When_Getting_Component_IDs_From_Directories
{
private static string Parameters;
private static string Arguments;

Establish context = () => {
Parameters = "<Component Id=\"1234\" Name=\"Folder Name With Spaces\">";
};

Because of = () => {
Arguments = WiXHelper.getComponentIdsFromWiXString(Parameters);
Console.WriteLine(Arguments.ToString());
};

private It should_return_the_Id_successfully = () => Arguments.ToString()
.ShouldEqual(WiXHelper.WiXComponentRefDefaults
.With(p => p.Id, "1234")
.ToString());
}

internal class When_Getting_File_IDs_From_Directories
{
private static string Parameters;
private static string Arguments;

Establish context = () =>
{
Parameters = "<File Id=\"5678 ABC\" Name=\"Test.exe\" Source=\"C:\\Some\\Path\" />";
};

Because of = () => {
Arguments = WiXHelper.getFileIdFromWiXString(Parameters, @"\S*.exe");
Console.WriteLine(Arguments.ToString());
};

private It should_return_the_Id_successfully = () => Arguments.ToString()
.ShouldEqual("5678 ABC");
}
}