diff options
Diffstat (limited to 'src/test/WixToolsetTest.CoreIntegration')
17 files changed, 439 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs b/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs new file mode 100644 index 00000000..9859c05a --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs | |||
@@ -0,0 +1,90 @@ | |||
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.CoreIntegration | ||
4 | { | ||
5 | using System.IO; | ||
6 | using System.Linq; | ||
7 | using WixToolset.Core; | ||
8 | using WixToolset.Data; | ||
9 | using WixToolset.Data.Tuples; | ||
10 | using WixToolsetTest.CoreIntegration.Utility; | ||
11 | using Xunit; | ||
12 | |||
13 | public class ProgramFixture | ||
14 | { | ||
15 | [Fact] | ||
16 | public void CanBuildSingleFile() | ||
17 | { | ||
18 | var folder = TestData.Get(@"TestData\SingleFile"); | ||
19 | |||
20 | using (var fs = new DisposableFileSystem()) | ||
21 | using (var pushd = new Pushd(folder)) | ||
22 | { | ||
23 | var intermediateFolder = fs.GetFolder(); | ||
24 | |||
25 | var program = new Program(); | ||
26 | var result = program.Run(new WixToolsetServiceProvider(), new[] { "build", "Package.wxs", "PackageComponents.wxs", "-loc", "Package.en-us.wxl", "-bindpath", "data", "-intermediateFolder", intermediateFolder, "-o", $@"{intermediateFolder}\bin\test.msi" }); | ||
27 | |||
28 | Assert.Equal(0, result); | ||
29 | |||
30 | Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.msi"))); | ||
31 | Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb"))); | ||
32 | Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\MsiPackage\test.txt"))); | ||
33 | |||
34 | var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\test.wir")); | ||
35 | Assert.Single(intermediate.Sections); | ||
36 | |||
37 | var wixFile = intermediate.Sections.SelectMany(s => s.Tuples).OfType<WixFileTuple>().Single(); | ||
38 | Assert.Equal(@"data\test.txt", wixFile[WixFileTupleFields.Source].AsPath().Path); | ||
39 | Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | [Fact] | ||
44 | public void CanBuildSimpleModule() | ||
45 | { | ||
46 | var folder = TestData.Get(@"TestData\SimpleModule"); | ||
47 | |||
48 | using (var fs = new DisposableFileSystem()) | ||
49 | using (var pushd = new Pushd(folder)) | ||
50 | { | ||
51 | var intermediateFolder = fs.GetFolder(); | ||
52 | |||
53 | var program = new Program(); | ||
54 | var result = program.Run(new WixToolsetServiceProvider(), new[] { "build", "Module.wxs", "-loc", "Module.en-us.wxl", "-bindpath", "data", "-intermediateFolder", intermediateFolder, "-o", $@"{intermediateFolder}\bin\test.msm" }); | ||
55 | |||
56 | Assert.Equal(0, result); | ||
57 | |||
58 | Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.msm"))); | ||
59 | Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb"))); | ||
60 | |||
61 | var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\test.wir")); | ||
62 | Assert.Single(intermediate.Sections); | ||
63 | |||
64 | var wixFile = intermediate.Sections.SelectMany(s => s.Tuples).OfType<WixFileTuple>().Single(); | ||
65 | Assert.Equal(@"data\test.txt", wixFile[WixFileTupleFields.Source].AsPath().Path); | ||
66 | Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); | ||
67 | } | ||
68 | } | ||
69 | |||
70 | [Fact(Skip = "Not implemented yet.")] | ||
71 | public void CanBuildInstanceTransform() | ||
72 | { | ||
73 | var folder = TestData.Get(@"TestData\InstanceTransform"); | ||
74 | |||
75 | using (var fs = new DisposableFileSystem()) | ||
76 | using (var pushd = new Pushd(folder)) | ||
77 | { | ||
78 | var intermediateFolder = fs.GetFolder(); | ||
79 | |||
80 | var program = new Program(); | ||
81 | var result = program.Run(new WixToolsetServiceProvider(), new[] { "build", "Package.wxs", "PackageComponents.wxs", "-loc", "Package.en-us.wxl", "-bindpath", "data", "-intermediateFolder", intermediateFolder, "-o", $@"{intermediateFolder}\bin\test.msi" }); | ||
82 | |||
83 | Assert.Equal(0, result); | ||
84 | |||
85 | var pdb = Pdb.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb"), false); | ||
86 | Assert.NotEmpty(pdb.Output.SubStorages); | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | } | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.en-us.wxl | |||
@@ -0,0 +1,11 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <!-- | ||
4 | This file contains the declaration of all the localizable strings. | ||
5 | --> | ||
6 | <WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US"> | ||
7 | |||
8 | <String Id="DowngradeError">A newer version of [ProductName] is already installed.</String> | ||
9 | <String Id="FeatureTitle">MsiPackage</String> | ||
10 | |||
11 | </WixLocalization> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.wxs new file mode 100644 index 00000000..9c529668 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/Package.wxs | |||
@@ -0,0 +1,27 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Product Id="*" Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a"> | ||
4 | <Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" /> | ||
5 | |||
6 | <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" /> | ||
7 | <MediaTemplate /> | ||
8 | |||
9 | <Property Id="INSTANCEPROPERTY" Secure="yes" /> | ||
10 | |||
11 | <InstanceTransforms Property="INSTANCEPROPERTY"> | ||
12 | <Instance Id="I1" ProductCode="*" ProductName="MsiPackage (Instance 1)" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" /> | ||
13 | </InstanceTransforms> | ||
14 | |||
15 | <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)"> | ||
16 | <ComponentGroupRef Id="ProductComponents" /> | ||
17 | </Feature> | ||
18 | </Product> | ||
19 | |||
20 | <Fragment> | ||
21 | <Directory Id="TARGETDIR" Name="SourceDir"> | ||
22 | <Directory Id="ProgramFilesFolder"> | ||
23 | <Directory Id="INSTALLFOLDER" Name="MsiPackageInstance" /> | ||
24 | </Directory> | ||
25 | </Directory> | ||
26 | </Fragment> | ||
27 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/PackageComponents.wxs new file mode 100644 index 00000000..e26c4509 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/PackageComponents.wxs | |||
@@ -0,0 +1,10 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> | ||
5 | <Component> | ||
6 | <File Source="test.txt" /> | ||
7 | </Component> | ||
8 | </ComponentGroup> | ||
9 | </Fragment> | ||
10 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/data/test.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/data/test.txt new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/InstanceTransform/data/test.txt | |||
@@ -0,0 +1 @@ | |||
This is test.txt. \ No newline at end of file | |||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.en-us.wxl new file mode 100644 index 00000000..c74e86a7 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.en-us.wxl | |||
@@ -0,0 +1,10 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <!-- | ||
4 | This file contains the declaration of all the localizable strings. | ||
5 | --> | ||
6 | <WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US"> | ||
7 | |||
8 | <String Id="Manufacturer">Example Company</String> | ||
9 | |||
10 | </WixLocalization> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wixproj b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wixproj new file mode 100644 index 00000000..597d4318 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wixproj | |||
@@ -0,0 +1,48 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Project ToolsVersion="4.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 | <ProductVersion>0.9</ProductVersion> | ||
7 | <ProjectGuid>27df04c6-3cef-4b9a-bac6-4e78d188384f</ProjectGuid> | ||
8 | <OutputName>MergeModule1</OutputName> | ||
9 | <OutputType>Module</OutputType> | ||
10 | <Name>MergeModule1</Name> | ||
11 | <RootNamespace>MergeModule1</RootNamespace> | ||
12 | </PropertyGroup> | ||
13 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
14 | <PlatformName>$(Platform)</PlatformName> | ||
15 | <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath> | ||
16 | <DefineConstants>Debug</DefineConstants> | ||
17 | </PropertyGroup> | ||
18 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
19 | <PlatformName>$(Platform)</PlatformName> | ||
20 | <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath> | ||
21 | </PropertyGroup> | ||
22 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> | ||
23 | <PlatformName>$(Platform)</PlatformName> | ||
24 | <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath> | ||
25 | <DefineConstants>Debug</DefineConstants> | ||
26 | </PropertyGroup> | ||
27 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "> | ||
28 | <PlatformName>$(Platform)</PlatformName> | ||
29 | <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath> | ||
30 | </PropertyGroup> | ||
31 | <ItemGroup> | ||
32 | <Compile Include="MergeModule.wxs" /> | ||
33 | </ItemGroup> | ||
34 | <ItemGroup> | ||
35 | <EmbeddedResource Include="MergeModule.en-us.wxl" /> | ||
36 | </ItemGroup> | ||
37 | <ItemGroup> | ||
38 | <WixExtension Include="FgwepExtension.wixext"> | ||
39 | <Name>FgwepExtension.wixext</Name> | ||
40 | <HintPath>$(WixExtDir)\FgwepExtension.wixext.dll</HintPath> | ||
41 | </WixExtension> | ||
42 | </ItemGroup> | ||
43 | <Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " /> | ||
44 | <Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\wix.targets') " /> | ||
45 | <Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' "> | ||
46 | <Error Text="FG-WiX or WiX Toolset build tools (v3.11 or later) must be installed to build this project. To download FG-WiX, go to https://www.firegiant.com/downloads/. To download the WiX Toolset, go to http://wixtoolset.org/releases/." /> | ||
47 | </Target> | ||
48 | </Project> \ No newline at end of file | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wxs new file mode 100644 index 00000000..260339ba --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/Module.wxs | |||
@@ -0,0 +1,16 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Module Id="MergeModule1" Language="1033" Version="1.0.0.0"> | ||
4 | <Package Id="243FB739-4D05-472F-9CFB-EF6B1017B6DE" Manufacturer="!(loc.Manufacturer)" InstallerVersion="200" /> | ||
5 | |||
6 | <Directory Id="TARGETDIR" Name="SourceDir"> | ||
7 | <Directory Id="MergeRedirectFolder"> | ||
8 | |||
9 | <Component Id="ModuleComponent" Guid="A04E61B2-3ED4-4803-B2EB-4B773576FA45"> | ||
10 | <File Source="test.txt" /> | ||
11 | </Component> | ||
12 | |||
13 | </Directory> | ||
14 | </Directory> | ||
15 | </Module> | ||
16 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/data/test.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/data/test.txt new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SimpleModule/data/test.txt | |||
@@ -0,0 +1 @@ | |||
This is test.txt. \ No newline at end of file | |||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.en-us.wxl | |||
@@ -0,0 +1,11 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <!-- | ||
4 | This file contains the declaration of all the localizable strings. | ||
5 | --> | ||
6 | <WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US"> | ||
7 | |||
8 | <String Id="DowngradeError">A newer version of [ProductName] is already installed.</String> | ||
9 | <String Id="FeatureTitle">MsiPackage</String> | ||
10 | |||
11 | </WixLocalization> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.wxs new file mode 100644 index 00000000..cdc323ec --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/Package.wxs | |||
@@ -0,0 +1,21 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Product Id="*" Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a"> | ||
4 | <Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" /> | ||
5 | |||
6 | <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" /> | ||
7 | <MediaTemplate /> | ||
8 | |||
9 | <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)"> | ||
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.CoreIntegration/TestData/SingleFile/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/PackageComponents.wxs new file mode 100644 index 00000000..e26c4509 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/PackageComponents.wxs | |||
@@ -0,0 +1,10 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> | ||
5 | <Component> | ||
6 | <File Source="test.txt" /> | ||
7 | </Component> | ||
8 | </ComponentGroup> | ||
9 | </Fragment> | ||
10 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/data/test.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/data/test.txt new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleFile/data/test.txt | |||
@@ -0,0 +1 @@ | |||
This is test.txt. \ No newline at end of file | |||
diff --git a/src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs b/src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs new file mode 100644 index 00000000..795d344a --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs | |||
@@ -0,0 +1,86 @@ | |||
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.CoreIntegration.Utility | ||
4 | { | ||
5 | using System; | ||
6 | using System.Collections.Generic; | ||
7 | using System.IO; | ||
8 | |||
9 | public class DisposableFileSystem : IDisposable | ||
10 | { | ||
11 | protected bool Disposed { get; private set; } | ||
12 | |||
13 | private List<string> CleanupPaths { get; } = new List<string>(); | ||
14 | |||
15 | protected string GetFile(bool create = false) | ||
16 | { | ||
17 | var path = Path.GetTempFileName(); | ||
18 | |||
19 | if (!create) | ||
20 | { | ||
21 | File.Delete(path); | ||
22 | } | ||
23 | |||
24 | this.CleanupPaths.Add(path); | ||
25 | |||
26 | return path; | ||
27 | } | ||
28 | |||
29 | public string GetFolder(bool create = false) | ||
30 | { | ||
31 | var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); | ||
32 | |||
33 | if (create) | ||
34 | { | ||
35 | Directory.CreateDirectory(path); | ||
36 | } | ||
37 | |||
38 | this.CleanupPaths.Add(path); | ||
39 | |||
40 | return path; | ||
41 | } | ||
42 | |||
43 | |||
44 | #region // IDisposable | ||
45 | |||
46 | public void Dispose() | ||
47 | { | ||
48 | this.Dispose(true); | ||
49 | GC.SuppressFinalize(this); | ||
50 | } | ||
51 | |||
52 | protected virtual void Dispose(bool disposing) | ||
53 | { | ||
54 | if (this.Disposed) | ||
55 | { | ||
56 | return; | ||
57 | } | ||
58 | |||
59 | if (disposing) | ||
60 | { | ||
61 | foreach (var path in this.CleanupPaths) | ||
62 | { | ||
63 | try | ||
64 | { | ||
65 | if (File.Exists(path)) | ||
66 | { | ||
67 | File.Delete(path); | ||
68 | } | ||
69 | else if (Directory.Exists(path)) | ||
70 | { | ||
71 | Directory.Delete(path, true); | ||
72 | } | ||
73 | } | ||
74 | catch | ||
75 | { | ||
76 | // Best effort delete, so ignore any failures. | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | |||
81 | this.Disposed = true; | ||
82 | } | ||
83 | |||
84 | #endregion | ||
85 | } | ||
86 | } | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/Utility/Pushd.cs b/src/test/WixToolsetTest.CoreIntegration/Utility/Pushd.cs new file mode 100644 index 00000000..efd733a7 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/Utility/Pushd.cs | |||
@@ -0,0 +1,46 @@ | |||
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.CoreIntegration.Utility | ||
4 | { | ||
5 | using System; | ||
6 | using System.IO; | ||
7 | |||
8 | public class Pushd : IDisposable | ||
9 | { | ||
10 | protected bool Disposed { get; private set; } | ||
11 | |||
12 | public Pushd(string path) | ||
13 | { | ||
14 | this.PreviousDirectory = Directory.GetCurrentDirectory(); | ||
15 | |||
16 | Directory.SetCurrentDirectory(path); | ||
17 | } | ||
18 | |||
19 | public string PreviousDirectory { get; } | ||
20 | |||
21 | #region // IDisposable | ||
22 | |||
23 | public void Dispose() | ||
24 | { | ||
25 | this.Dispose(true); | ||
26 | GC.SuppressFinalize(this); | ||
27 | } | ||
28 | |||
29 | protected virtual void Dispose(bool disposing) | ||
30 | { | ||
31 | if (this.Disposed) | ||
32 | { | ||
33 | return; | ||
34 | } | ||
35 | |||
36 | if (disposing) | ||
37 | { | ||
38 | Directory.SetCurrentDirectory(this.PreviousDirectory); | ||
39 | } | ||
40 | |||
41 | this.Disposed = true; | ||
42 | } | ||
43 | |||
44 | #endregion | ||
45 | } | ||
46 | } | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/Utility/TestData.cs b/src/test/WixToolsetTest.CoreIntegration/Utility/TestData.cs new file mode 100644 index 00000000..e3b21183 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/Utility/TestData.cs | |||
@@ -0,0 +1,17 @@ | |||
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.CoreIntegration.Utility | ||
4 | { | ||
5 | using System; | ||
6 | using System.IO; | ||
7 | |||
8 | public class TestData | ||
9 | { | ||
10 | public static string LocalPath => Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath); | ||
11 | |||
12 | public static string Get(params string[] paths) | ||
13 | { | ||
14 | return Path.Combine(LocalPath, Path.Combine(paths)); | ||
15 | } | ||
16 | } | ||
17 | } | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj new file mode 100644 index 00000000..f9042cda --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj | |||
@@ -0,0 +1,33 @@ | |||
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. --> | ||
3 | |||
4 | <Project Sdk="Microsoft.NET.Sdk"> | ||
5 | <PropertyGroup> | ||
6 | <TargetFramework>netcoreapp2.0</TargetFramework> | ||
7 | <IsPackable>false</IsPackable> | ||
8 | </PropertyGroup> | ||
9 | |||
10 | <ItemGroup> | ||
11 | <Content Include="TestData\SimpleModule\data\test.txt" CopyToOutputDirectory="PreserveNewest" /> | ||
12 | <Content Include="TestData\SimpleModule\Module.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> | ||
13 | <Content Include="TestData\SimpleModule\Module.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
14 | <Content Include="TestData\InstanceTransform\data\test.txt" CopyToOutputDirectory="PreserveNewest" /> | ||
15 | <Content Include="TestData\InstanceTransform\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> | ||
16 | <Content Include="TestData\InstanceTransform\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
17 | <Content Include="TestData\InstanceTransform\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
18 | <Content Include="TestData\SingleFile\data\test.txt" CopyToOutputDirectory="PreserveNewest" /> | ||
19 | <Content Include="TestData\SingleFile\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> | ||
20 | <Content Include="TestData\SingleFile\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
21 | <Content Include="TestData\SingleFile\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
22 | </ItemGroup> | ||
23 | |||
24 | <ItemGroup> | ||
25 | <ProjectReference Include="..\..\wix\wix.csproj" /> | ||
26 | </ItemGroup> | ||
27 | |||
28 | <ItemGroup> | ||
29 | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" /> | ||
30 | <PackageReference Include="xunit" Version="2.2.0" /> | ||
31 | <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> | ||
32 | </ItemGroup> | ||
33 | </Project> | ||