aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpaulomorgado <470455+paulomorgado@users.noreply.github.com>2020-05-25 13:13:25 +0100
committerPaulo Morgado <470455+paulomorgado@users.noreply.github.com>2020-05-26 08:41:41 +0100
commit0b9fd5ae84460d943e685b9821473f356a66bd3b (patch)
tree404f93e6308fb896f1d1cd06d9988c2e4f96acde /src
parent2480d0ad4bf4f0dd841697d6d607bb35a0fd8161 (diff)
downloadwix-0b9fd5ae84460d943e685b9821473f356a66bd3b.tar.gz
wix-0b9fd5ae84460d943e685b9821473f356a66bd3b.tar.bz2
wix-0b9fd5ae84460d943e685b9821473f356a66bd3b.zip
Allow more than one harvested file and files differing by extension
add component and directory for more disambiguation Fix HarvestFile Ouput added unit tests
Diffstat (limited to 'src')
-rw-r--r--src/WixToolset.BuildTasks/wix.harvest.targets4
-rw-r--r--src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs79
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/HeatFileMultpleFilesSameFileName.wixproj61
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/MyProgram.json1
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/MyProgram.txt1
-rw-r--r--src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/Package.wxs22
-rw-r--r--src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj6
7 files changed, 170 insertions, 4 deletions
diff --git a/src/WixToolset.BuildTasks/wix.harvest.targets b/src/WixToolset.BuildTasks/wix.harvest.targets
index a8be17df..5dd2f729 100644
--- a/src/WixToolset.BuildTasks/wix.harvest.targets
+++ b/src/WixToolset.BuildTasks/wix.harvest.targets
@@ -415,7 +415,7 @@
415 <Target Name="HarvestFile" 415 <Target Name="HarvestFile"
416 DependsOnTargets="$(HarvestFileDependsOn)" 416 DependsOnTargets="$(HarvestFileDependsOn)"
417 Inputs="@(HarvestFile);%(HarvestFile.Transforms)" 417 Inputs="@(HarvestFile);%(HarvestFile.Transforms)"
418 Outputs="$(IntermediateOutputPath)_%(HarvestFile.Filename)_file.wxs" 418 Outputs="@(HarvestFile->'$(IntermediateOutputPath)_%(ComponentGroupName)_%(DirectoryRefId)_%(Filename)%(Extension)_file.wxs')"
419 Condition=" '@(HarvestFile)' != '' "> 419 Condition=" '@(HarvestFile)' != '' ">
420 420
421 <HeatFile 421 <HeatFile
@@ -427,7 +427,7 @@
427 VerboseOutput="$(HarvestFileVerboseOutput)" 427 VerboseOutput="$(HarvestFileVerboseOutput)"
428 AutogenerateGuids="$(HarvestFileAutogenerateGuids)" 428 AutogenerateGuids="$(HarvestFileAutogenerateGuids)"
429 GenerateGuidsNow="$(HarvestFileGenerateGuidsNow)" 429 GenerateGuidsNow="$(HarvestFileGenerateGuidsNow)"
430 OutputFile="$(IntermediateOutputPath)_%(HarvestFile.Filename)_file.wxs" 430 OutputFile="$(IntermediateOutputPath)_%(HarvestFile.ComponentGroupName)_%(HarvestFile.DirectoryRefId)_%(HarvestFile.Filename)%(HarvestFile.Extension)_file.wxs"
431 SuppressFragments="$(HarvestFileSuppressFragments)" 431 SuppressFragments="$(HarvestFileSuppressFragments)"
432 SuppressUniqueIds="$(HarvestFileSuppressUniqueIds)" 432 SuppressUniqueIds="$(HarvestFileSuppressUniqueIds)"
433 Transforms="%(HarvestFile.Transforms)" 433 Transforms="%(HarvestFile.Transforms)"
diff --git a/src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs b/src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs
index de78c0bc..13dd0160 100644
--- a/src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs
+++ b/src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs
@@ -41,7 +41,7 @@ namespace WixToolsetTest.BuildTasks
41 var warnings = result.Output.Where(line => line.Contains(": warning")); 41 var warnings = result.Output.Where(line => line.Contains(": warning"));
42 Assert.Empty(warnings); 42 Assert.Empty(warnings);
43 43
44 var generatedFilePath = Path.Combine(intermediateFolder, @"_HeatFilePackage_file.wxs"); 44 var generatedFilePath = Path.Combine(intermediateFolder, @"_ProductComponents_INSTALLFOLDER_HeatFilePackage.wixproj_file.wxs");
45 Assert.True(File.Exists(generatedFilePath)); 45 Assert.True(File.Exists(generatedFilePath));
46 46
47 var generatedContents = File.ReadAllText(generatedFilePath); 47 var generatedContents = File.ReadAllText(generatedFilePath);
@@ -71,5 +71,82 @@ namespace WixToolsetTest.BuildTasks
71 Assert.Equal(@"SourceDir\HeatFilePackage.wixproj", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); 71 Assert.Equal(@"SourceDir\HeatFilePackage.wixproj", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path);
72 } 72 }
73 } 73 }
74
75 [Fact]
76 public void CanBuildHeatFileWithMultipleFilesPackage()
77 {
78 var projectPath = TestData.Get(@"TestData\HeatFileMultpleFilesSameFileName\HeatFileMultpleFilesSameFileName.wixproj");
79
80 using (var fs = new DisposableFileSystem())
81 {
82 var baseFolder = fs.GetFolder();
83 var binFolder = Path.Combine(baseFolder, @"bin\");
84 var intermediateFolder = Path.Combine(baseFolder, @"obj\");
85
86 var result = MsbuildRunner.Execute(projectPath, new[]
87 {
88 $"-p:WixTargetsPath={WixTargetsPath}",
89 $"-p:IntermediateOutputPath={intermediateFolder}",
90 $"-p:OutputPath={binFolder}"
91 });
92 result.AssertSuccess();
93
94 var heatCommandLines = result.Output.Where(line => line.TrimStart().StartsWith("heat.exe file"));
95 Assert.Equal(2, heatCommandLines.Count());
96
97 var warnings = result.Output.Where(line => line.Contains(": warning"));
98 Assert.Empty(warnings);
99
100 var generatedFilePath = Path.Combine(intermediateFolder, @"_TxtProductComponents_INSTALLFOLDER_MyProgram.txt_file.wxs");
101 Assert.True(File.Exists(generatedFilePath));
102
103 var generatedContents = File.ReadAllText(generatedFilePath);
104 var testXml = generatedContents.GetTestXml();
105 Assert.Equal("<Wix>" +
106 "<Fragment>" +
107 "<DirectoryRef Id='INSTALLFOLDER'>" +
108 "<Component Id='MyProgram.txt' Guid='*'>" +
109 @"<File Id='MyProgram.txt' KeyPath='yes' Source='SourceDir\MyProgram.txt' />" +
110 "</Component>" +
111 "</DirectoryRef>" +
112 "</Fragment>" +
113 "<Fragment>" +
114 "<ComponentGroup Id='TxtProductComponents'>" +
115 "<ComponentRef Id='MyProgram.txt' />" +
116 "</ComponentGroup>" +
117 "</Fragment>" +
118 "</Wix>", testXml);
119
120 generatedFilePath = Path.Combine(intermediateFolder, @"_JsonProductComponents_INSTALLFOLDER_MyProgram.json_file.wxs");
121 Assert.True(File.Exists(generatedFilePath));
122
123 generatedContents = File.ReadAllText(generatedFilePath);
124 testXml = generatedContents.GetTestXml();
125 Assert.Equal("<Wix>" +
126 "<Fragment>" +
127 "<DirectoryRef Id='INSTALLFOLDER'>" +
128 "<Component Id='MyProgram.json' Guid='*'>" +
129 @"<File Id='MyProgram.json' KeyPath='yes' Source='SourceDir\MyProgram.json' />" +
130 "</Component>" +
131 "</DirectoryRef>" +
132 "</Fragment>" +
133 "<Fragment>" +
134 "<ComponentGroup Id='JsonProductComponents'>" +
135 "<ComponentRef Id='MyProgram.json' />" +
136 "</ComponentGroup>" +
137 "</Fragment>" +
138 "</Wix>", testXml);
139
140 var pdbPath = Path.Combine(binFolder, "HeatFileMultpleFilesSameFileName.wixpdb");
141 Assert.True(File.Exists(pdbPath));
142
143 var intermediate = Intermediate.Load(pdbPath);
144 var section = intermediate.Sections.Single();
145
146 var fileTuples = section.Tuples.OfType<FileTuple>().ToArray();
147 Assert.Equal(@"SourceDir\MyProgram.txt", fileTuples[0][FileTupleFields.Source].PreviousValue.AsPath().Path);
148 Assert.Equal(@"SourceDir\MyProgram.json", fileTuples[1][FileTupleFields.Source].PreviousValue.AsPath().Path);
149 }
150 }
74 } 151 }
75} 152}
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/HeatFileMultpleFilesSameFileName.wixproj b/src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/HeatFileMultpleFilesSameFileName.wixproj
new file mode 100644
index 00000000..860fc2dd
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/HeatFileMultpleFilesSameFileName.wixproj
@@ -0,0 +1,61 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <PropertyGroup>
4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6 </PropertyGroup>
7
8 <PropertyGroup>
9 <ProjectGuid>7fb77005-c6e0-454f-8c2d-0a4a79c918ba</ProjectGuid>
10 </PropertyGroup>
11
12 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
13 <PlatformName>$(Platform)</PlatformName>
14 <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
15 <DefineConstants>Debug</DefineConstants>
16 </PropertyGroup>
17 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
18 <PlatformName>$(Platform)</PlatformName>
19 <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
20 </PropertyGroup>
21 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
22 <PlatformName>$(Platform)</PlatformName>
23 <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
24 <DefineConstants>Debug</DefineConstants>
25 </PropertyGroup>
26 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
27 <PlatformName>$(Platform)</PlatformName>
28 <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
29 </PropertyGroup>
30
31 <ItemGroup>
32 <Compile Include="Package.wxs" />
33 </ItemGroup>
34
35 <ItemGroup>
36 <BindInputPaths Include="." />
37 </ItemGroup>
38
39 <PropertyGroup>
40 <HarvestFileSuppressUniqueIds>true</HarvestFileSuppressUniqueIds>
41 </PropertyGroup>
42
43 <ItemGroup>
44 <HarvestFile Include="MyProgram.txt">
45 <ComponentGroupName>TxtProductComponents</ComponentGroupName>
46 <DirectoryRefId>INSTALLFOLDER</DirectoryRefId>
47 <SuppressRootDirectory>true</SuppressRootDirectory>
48 </HarvestFile>
49 <HarvestFile Include="MyProgram.json">
50 <ComponentGroupName>JsonProductComponents</ComponentGroupName>
51 <DirectoryRefId>INSTALLFOLDER</DirectoryRefId>
52 <SuppressRootDirectory>true</SuppressRootDirectory>
53 </HarvestFile>
54 </ItemGroup>
55
56 <Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
57 <Import Project="$(MSBuildExtensionsPath32)\WixToolset\v4.x\wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\WixToolset\v4.x\wix.targets') " />
58 <Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
59 <Error Text="WiX Toolset build tools (v4.0 or later) must be installed to build this project. To download the WiX Toolset, go to http://wixtoolset.org/releases/." />
60 </Target>
61</Project> \ No newline at end of file
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/MyProgram.json b/src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/MyProgram.json
new file mode 100644
index 00000000..5f282702
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/MyProgram.json
@@ -0,0 +1 @@
 \ No newline at end of file
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/MyProgram.txt b/src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/MyProgram.txt
new file mode 100644
index 00000000..5f282702
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/MyProgram.txt
@@ -0,0 +1 @@
 \ No newline at end of file
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/Package.wxs b/src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/Package.wxs
new file mode 100644
index 00000000..884da274
--- /dev/null
+++ b/src/test/WixToolsetTest.BuildTasks/TestData/HeatFileMultpleFilesSameFileName/Package.wxs
@@ -0,0 +1,22 @@
1<?xml version="1.0" encoding="utf-8"?>
2
3<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
4 <Product Id="*" Name="HeatFilePackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
5 <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
6
7 <MediaTemplate />
8
9 <Feature Id="ProductFeature" Title="HeatFileFeature">
10 <ComponentGroupRef Id="TxtProductComponents" />
11 <ComponentGroupRef Id="JsonProductComponents" />
12 </Feature>
13 </Product>
14
15 <Fragment>
16 <Directory Id="TARGETDIR" Name="SourceDir">
17 <Directory Id="ProgramFilesFolder">
18 <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
19 </Directory>
20 </Directory>
21 </Fragment>
22</Wix>
diff --git a/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj b/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj
index 3909cc79..333c7c79 100644
--- a/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj
+++ b/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj
@@ -1,4 +1,4 @@
1<?xml version="1.0" encoding="utf-8"?> 1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> 2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3 3
4<Project Sdk="Microsoft.NET.Sdk"> 4<Project Sdk="Microsoft.NET.Sdk">
@@ -12,6 +12,10 @@
12 <ItemGroup> 12 <ItemGroup>
13 <Content Include="TestData\HeatFilePackage\HeatFilePackage.wixproj" CopyToOutputDirectory="PreserveNewest" /> 13 <Content Include="TestData\HeatFilePackage\HeatFilePackage.wixproj" CopyToOutputDirectory="PreserveNewest" />
14 <Content Include="TestData\HeatFilePackage\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> 14 <Content Include="TestData\HeatFilePackage\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
15 <Content Include="TestData\HeatFileMultpleFilesSameFileName\HeatFileMultpleFilesSameFileName.wixproj" CopyToOutputDirectory="PreserveNewest" />
16 <Content Include="TestData\HeatFileMultpleFilesSameFileName\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
17 <Content Include="TestData\HeatFileMultpleFilesSameFileName\MyProgram.txt" CopyToOutputDirectory="PreserveNewest" />
18 <Content Include="TestData\HeatFileMultpleFilesSameFileName\MyProgram.json" CopyToOutputDirectory="PreserveNewest" />
15 <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\MsiPackage.wixproj" CopyToOutputDirectory="PreserveNewest" /> 19 <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\MsiPackage.wixproj" CopyToOutputDirectory="PreserveNewest" />
16 <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\Package.de-de.wxl" CopyToOutputDirectory="PreserveNewest" /> 20 <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\Package.de-de.wxl" CopyToOutputDirectory="PreserveNewest" />
17 <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> 21 <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />