Skip to content

Commit

Permalink
Fixed bug that prevented using directory names with spaces in WiX
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Kroenert authored and Florian Kroenert committed Mar 2, 2016
1 parent 998ddff commit 267118b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
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");
}
}

0 comments on commit 267118b

Please sign in to comment.