diff options
Diffstat (limited to 'src/test')
4 files changed, 161 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs b/src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs new file mode 100644 index 00000000..de78c0bc --- /dev/null +++ b/src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs | |||
@@ -0,0 +1,75 @@ | |||
1 | // 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 | |||
3 | namespace WixToolsetTest.BuildTasks | ||
4 | { | ||
5 | using System; | ||
6 | using System.IO; | ||
7 | using System.Linq; | ||
8 | using WixBuildTools.TestSupport; | ||
9 | using WixToolset.BuildTasks; | ||
10 | using WixToolset.Core.TestPackage; | ||
11 | using WixToolset.Data; | ||
12 | using WixToolset.Data.Tuples; | ||
13 | using Xunit; | ||
14 | |||
15 | public class MsbuildHeatFixture | ||
16 | { | ||
17 | private static readonly string WixTargetsPath = Path.Combine(Path.GetDirectoryName(new Uri(typeof(HeatTask).Assembly.CodeBase).AbsolutePath), "wix.targets"); | ||
18 | |||
19 | [Fact] | ||
20 | public void CanBuildHeatFilePackage() | ||
21 | { | ||
22 | var projectPath = TestData.Get(@"TestData\HeatFilePackage\HeatFilePackage.wixproj"); | ||
23 | |||
24 | using (var fs = new DisposableFileSystem()) | ||
25 | { | ||
26 | var baseFolder = fs.GetFolder(); | ||
27 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
28 | var intermediateFolder = Path.Combine(baseFolder, @"obj\"); | ||
29 | |||
30 | var result = MsbuildRunner.Execute(projectPath, new[] | ||
31 | { | ||
32 | $"-p:WixTargetsPath={WixTargetsPath}", | ||
33 | $"-p:IntermediateOutputPath={intermediateFolder}", | ||
34 | $"-p:OutputPath={binFolder}" | ||
35 | }); | ||
36 | result.AssertSuccess(); | ||
37 | |||
38 | var heatCommandLines = result.Output.Where(line => line.TrimStart().StartsWith("heat.exe file")); | ||
39 | Assert.Single(heatCommandLines); | ||
40 | |||
41 | var warnings = result.Output.Where(line => line.Contains(": warning")); | ||
42 | Assert.Empty(warnings); | ||
43 | |||
44 | var generatedFilePath = Path.Combine(intermediateFolder, @"_HeatFilePackage_file.wxs"); | ||
45 | Assert.True(File.Exists(generatedFilePath)); | ||
46 | |||
47 | var generatedContents = File.ReadAllText(generatedFilePath); | ||
48 | var testXml = generatedContents.GetTestXml(); | ||
49 | Assert.Equal(@"<Wix>" + | ||
50 | "<Fragment>" + | ||
51 | "<DirectoryRef Id='INSTALLFOLDER'>" + | ||
52 | "<Component Id='HeatFilePackage.wixproj' Guid='*'>" + | ||
53 | "<File Id='HeatFilePackage.wixproj' KeyPath='yes' Source='SourceDir\\HeatFilePackage.wixproj' />" + | ||
54 | "</Component>" + | ||
55 | "</DirectoryRef>" + | ||
56 | "</Fragment>" + | ||
57 | "<Fragment>" + | ||
58 | "<ComponentGroup Id='ProductComponents'>" + | ||
59 | "<ComponentRef Id='HeatFilePackage.wixproj' />" + | ||
60 | "</ComponentGroup>" + | ||
61 | "</Fragment>" + | ||
62 | "</Wix>", testXml); | ||
63 | |||
64 | var pdbPath = Path.Combine(binFolder, "HeatFilePackage.wixpdb"); | ||
65 | Assert.True(File.Exists(pdbPath)); | ||
66 | |||
67 | var intermediate = Intermediate.Load(pdbPath); | ||
68 | var section = intermediate.Sections.Single(); | ||
69 | |||
70 | var fileTuple = section.Tuples.OfType<FileTuple>().Single(); | ||
71 | Assert.Equal(@"SourceDir\HeatFilePackage.wixproj", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); | ||
72 | } | ||
73 | } | ||
74 | } | ||
75 | } | ||
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/HeatFilePackage/HeatFilePackage.wixproj b/src/test/WixToolsetTest.BuildTasks/TestData/HeatFilePackage/HeatFilePackage.wixproj new file mode 100644 index 00000000..87f4388a --- /dev/null +++ b/src/test/WixToolsetTest.BuildTasks/TestData/HeatFilePackage/HeatFilePackage.wixproj | |||
@@ -0,0 +1,56 @@ | |||
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="HeatFilePackage.wixproj"> | ||
45 | <ComponentGroupName>ProductComponents</ComponentGroupName> | ||
46 | <DirectoryRefId>INSTALLFOLDER</DirectoryRefId> | ||
47 | <SuppressRootDirectory>true</SuppressRootDirectory> | ||
48 | </HarvestFile> | ||
49 | </ItemGroup> | ||
50 | |||
51 | <Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " /> | ||
52 | <Import Project="$(MSBuildExtensionsPath32)\WixToolset\v4.x\wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\WixToolset\v4.x\wix.targets') " /> | ||
53 | <Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' "> | ||
54 | <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/." /> | ||
55 | </Target> | ||
56 | </Project> \ No newline at end of file | ||
diff --git a/src/test/WixToolsetTest.BuildTasks/TestData/HeatFilePackage/Package.wxs b/src/test/WixToolsetTest.BuildTasks/TestData/HeatFilePackage/Package.wxs new file mode 100644 index 00000000..e509c464 --- /dev/null +++ b/src/test/WixToolsetTest.BuildTasks/TestData/HeatFilePackage/Package.wxs | |||
@@ -0,0 +1,21 @@ | |||
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="ProductComponents" /> | ||
11 | </Feature> | ||
12 | </Product> | ||
13 | |||
14 | <Fragment> | ||
15 | <Directory Id="TARGETDIR" Name="SourceDir"> | ||
16 | <Directory Id="ProgramFilesFolder"> | ||
17 | <Directory Id="INSTALLFOLDER" Name="MsiPackage" /> | ||
18 | </Directory> | ||
19 | </Directory> | ||
20 | </Fragment> | ||
21 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj b/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj index eba81c0c..7573339f 100644 --- a/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj +++ b/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj | |||
@@ -9,6 +9,14 @@ | |||
9 | </PropertyGroup> | 9 | </PropertyGroup> |
10 | 10 | ||
11 | <ItemGroup> | 11 | <ItemGroup> |
12 | <Content Include="TestData\HeatFilePackage\HeatFilePackage.wixproj" CopyToOutputDirectory="PreserveNewest" /> | ||
13 | <Content Include="TestData\HeatFilePackage\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
14 | <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\MsiPackage.wixproj" CopyToOutputDirectory="PreserveNewest" /> | ||
15 | <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\Package.de-de.wxl" CopyToOutputDirectory="PreserveNewest" /> | ||
16 | <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> | ||
17 | <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
18 | <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
19 | <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\data\test.txt" CopyToOutputDirectory="PreserveNewest" /> | ||
12 | <Content Include="TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj" CopyToOutputDirectory="PreserveNewest" /> | 20 | <Content Include="TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj" CopyToOutputDirectory="PreserveNewest" /> |
13 | <Content Include="TestData\SimpleMsiPackage\MsiPackage\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> | 21 | <Content Include="TestData\SimpleMsiPackage\MsiPackage\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> |
14 | <Content Include="TestData\SimpleMsiPackage\MsiPackage\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> | 22 | <Content Include="TestData\SimpleMsiPackage\MsiPackage\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> |
@@ -24,6 +32,7 @@ | |||
24 | <PackageReference Include="Microsoft.Build.Tasks.Core" Version="14.3" Condition="'$(TargetFramework)'=='net461' or '$(TargetFramework)'=='net472'" /> | 32 | <PackageReference Include="Microsoft.Build.Tasks.Core" Version="14.3" Condition="'$(TargetFramework)'=='net461' or '$(TargetFramework)'=='net472'" /> |
25 | <PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.7.179" Condition="'$(TargetFramework)'=='netcoreapp2.1' " /> | 33 | <PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.7.179" Condition="'$(TargetFramework)'=='netcoreapp2.1' " /> |
26 | <PackageReference Include="WixBuildTools.TestSupport" Version="4.0.*" /> | 34 | <PackageReference Include="WixBuildTools.TestSupport" Version="4.0.*" /> |
35 | <PackageReference Include="WixToolset.Core.TestPackage" Version="4.0.*" /> | ||
27 | </ItemGroup> | 36 | </ItemGroup> |
28 | 37 | ||
29 | <ItemGroup> | 38 | <ItemGroup> |