diff options
11 files changed, 287 insertions, 3 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index 32da5bcf..b3909451 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs | |||
| @@ -70,6 +70,11 @@ namespace WixToolset.Core | |||
| 70 | { | 70 | { |
| 71 | var intermediates = this.CompilePhase(); | 71 | var intermediates = this.CompilePhase(); |
| 72 | 72 | ||
| 73 | if (!intermediates.Any()) | ||
| 74 | { | ||
| 75 | return 1; | ||
| 76 | } | ||
| 77 | |||
| 73 | var tableDefinitions = new TableDefinitionCollection(WindowsInstallerStandard.GetTableDefinitions()); | 78 | var tableDefinitions = new TableDefinitionCollection(WindowsInstallerStandard.GetTableDefinitions()); |
| 74 | 79 | ||
| 75 | if (this.OutputType == OutputType.Library) | 80 | if (this.OutputType == OutputType.Library) |
| @@ -162,6 +167,12 @@ namespace WixToolset.Core | |||
| 162 | 167 | ||
| 163 | var resolver = CreateWixResolverWithVariables(localizer, output); | 168 | var resolver = CreateWixResolverWithVariables(localizer, output); |
| 164 | 169 | ||
| 170 | var intermediateFolder = this.IntermediateFolder; | ||
| 171 | if (String.IsNullOrEmpty(intermediateFolder)) | ||
| 172 | { | ||
| 173 | intermediateFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); | ||
| 174 | } | ||
| 175 | |||
| 165 | var context = new BindContext(); | 176 | var context = new BindContext(); |
| 166 | context.Messaging = Messaging.Instance; | 177 | context.Messaging = Messaging.Instance; |
| 167 | context.ExtensionManager = this.ExtensionManager; | 178 | context.ExtensionManager = this.ExtensionManager; |
| @@ -171,7 +182,7 @@ namespace WixToolset.Core | |||
| 171 | context.Codepage = localizer.Codepage; | 182 | context.Codepage = localizer.Codepage; |
| 172 | //context.DefaultCompressionLevel = this.DefaultCompressionLevel; | 183 | //context.DefaultCompressionLevel = this.DefaultCompressionLevel; |
| 173 | //context.Ices = this.Ices; | 184 | //context.Ices = this.Ices; |
| 174 | context.IntermediateFolder = this.IntermediateFolder; | 185 | context.IntermediateFolder = intermediateFolder; |
| 175 | context.IntermediateRepresentation = output; | 186 | context.IntermediateRepresentation = output; |
| 176 | context.OutputPath = this.OutputPath; | 187 | context.OutputPath = this.OutputPath; |
| 177 | context.OutputPdbPath = Path.ChangeExtension(this.OutputPath, ".wixpdb"); | 188 | context.OutputPdbPath = Path.ChangeExtension(this.OutputPath, ".wixpdb"); |
diff --git a/src/test/WixToolsetTest.CoreIntegrationFixture/ProgramFixture.cs b/src/test/WixToolsetTest.CoreIntegrationFixture/ProgramFixture.cs new file mode 100644 index 00000000..bc2786e9 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegrationFixture/ProgramFixture.cs | |||
| @@ -0,0 +1,32 @@ | |||
| 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.CoreIntegrationFixture | ||
| 4 | { | ||
| 5 | using System.IO; | ||
| 6 | using WixToolset.Core; | ||
| 7 | using WixToolsetTest.CoreIntegrationFixture.Utility; | ||
| 8 | using Xunit; | ||
| 9 | |||
| 10 | public class ProgramFixture | ||
| 11 | { | ||
| 12 | [Fact] | ||
| 13 | public void CanBuildSingleFile() | ||
| 14 | { | ||
| 15 | var folder = TestData.Get(@"TestData\SingleFile"); | ||
| 16 | |||
| 17 | using (var fs = new DisposableFileSystem()) | ||
| 18 | using (var pushd = new Pushd(folder)) | ||
| 19 | { | ||
| 20 | var intermediateFolder = fs.GetFolder(); | ||
| 21 | |||
| 22 | var program = new Program(); | ||
| 23 | var result = program.Run(new[] { "build", "Package.wxs", "PackageComponents.wxs", "-loc", "Package.en-us.wxl", "-bindpath", "data", "-intermediateFolder", intermediateFolder, "-o", $@"{intermediateFolder}\bin\test.msi" }); | ||
| 24 | |||
| 25 | Assert.Equal(0, result); | ||
| 26 | Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.msi"))); | ||
| 27 | Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\test.wixpdb"))); | ||
| 28 | Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\MsiPackage\test.txt"))); | ||
| 29 | } | ||
| 30 | } | ||
| 31 | } | ||
| 32 | } | ||
diff --git a/src/test/WixToolsetTest.CoreIntegrationFixture/TestData/SingleFile/Package.en-us.wxl b/src/test/WixToolsetTest.CoreIntegrationFixture/TestData/SingleFile/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegrationFixture/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.CoreIntegrationFixture/TestData/SingleFile/Package.wxs b/src/test/WixToolsetTest.CoreIntegrationFixture/TestData/SingleFile/Package.wxs new file mode 100644 index 00000000..cdc323ec --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegrationFixture/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.CoreIntegrationFixture/TestData/SingleFile/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegrationFixture/TestData/SingleFile/PackageComponents.wxs new file mode 100644 index 00000000..e26c4509 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegrationFixture/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.CoreIntegrationFixture/TestData/SingleFile/data/test.txt b/src/test/WixToolsetTest.CoreIntegrationFixture/TestData/SingleFile/data/test.txt new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegrationFixture/TestData/SingleFile/data/test.txt | |||
| @@ -0,0 +1 @@ | |||
| This is test.txt. \ No newline at end of file | |||
diff --git a/src/test/WixToolsetTest.CoreIntegrationFixture/Utility/DisposableFileSystem.cs b/src/test/WixToolsetTest.CoreIntegrationFixture/Utility/DisposableFileSystem.cs new file mode 100644 index 00000000..01c0b9fe --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegrationFixture/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.CoreIntegrationFixture.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.CoreIntegrationFixture/Utility/Pushd.cs b/src/test/WixToolsetTest.CoreIntegrationFixture/Utility/Pushd.cs new file mode 100644 index 00000000..8917e02c --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegrationFixture/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.CoreIntegrationFixture.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.CoreIntegrationFixture/Utility/TestData.cs b/src/test/WixToolsetTest.CoreIntegrationFixture/Utility/TestData.cs new file mode 100644 index 00000000..90d56799 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegrationFixture/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.CoreIntegrationFixture.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.CoreIntegrationFixture/WixToolsetTest.CoreIntegrationFixture.csproj b/src/test/WixToolsetTest.CoreIntegrationFixture/WixToolsetTest.CoreIntegrationFixture.csproj new file mode 100644 index 00000000..86482a19 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegrationFixture/WixToolsetTest.CoreIntegrationFixture.csproj | |||
| @@ -0,0 +1,45 @@ | |||
| 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 | <PropertyGroup> | ||
| 11 | <NoWarn>NU1701</NoWarn> | ||
| 12 | </PropertyGroup> | ||
| 13 | |||
| 14 | <ItemGroup> | ||
| 15 | <None Remove="TestData\SingleFile\data\test.txt" /> | ||
| 16 | <None Remove="TestData\SingleFile\Package.en-us.wxl" /> | ||
| 17 | <None Remove="TestData\SingleFile\Package.wxs" /> | ||
| 18 | <None Remove="TestData\SingleFile\PackageComponents.wxs" /> | ||
| 19 | </ItemGroup> | ||
| 20 | |||
| 21 | <ItemGroup> | ||
| 22 | <Content Include="TestData\SingleFile\data\test.txt"> | ||
| 23 | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| 24 | </Content> | ||
| 25 | <Content Include="TestData\SingleFile\Package.en-us.wxl"> | ||
| 26 | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| 27 | </Content> | ||
| 28 | <Content Include="TestData\SingleFile\Package.wxs"> | ||
| 29 | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| 30 | </Content> | ||
| 31 | <Content Include="TestData\SingleFile\PackageComponents.wxs"> | ||
| 32 | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| 33 | </Content> | ||
| 34 | </ItemGroup> | ||
| 35 | |||
| 36 | <ItemGroup> | ||
| 37 | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" /> | ||
| 38 | <PackageReference Include="xunit" Version="2.2.0" /> | ||
| 39 | <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> | ||
| 40 | </ItemGroup> | ||
| 41 | |||
| 42 | <ItemGroup> | ||
| 43 | <ProjectReference Include="..\..\wix\wix.csproj" /> | ||
| 44 | </ItemGroup> | ||
| 45 | </Project> | ||
diff --git a/src/wix/Program.cs b/src/wix/Program.cs index c60831d0..03b11c78 100644 --- a/src/wix/Program.cs +++ b/src/wix/Program.cs | |||
| @@ -19,11 +19,15 @@ namespace WixToolset.Core | |||
| 19 | public static int Main(string[] args) | 19 | public static int Main(string[] args) |
| 20 | { | 20 | { |
| 21 | Messaging.Instance.InitializeAppName("WIX", "wix.exe"); | 21 | Messaging.Instance.InitializeAppName("WIX", "wix.exe"); |
| 22 | |||
| 23 | Messaging.Instance.Display += DisplayMessage; | 22 | Messaging.Instance.Display += DisplayMessage; |
| 24 | 23 | ||
| 25 | var command = CommandLine.ParseStandardCommandLine(args); | 24 | var program = new Program(); |
| 25 | return program.Run(args); | ||
| 26 | } | ||
| 26 | 27 | ||
| 28 | public int Run(string[] args) | ||
| 29 | { | ||
| 30 | var command = CommandLine.ParseStandardCommandLine(args); | ||
| 27 | return command?.Execute() ?? 1; | 31 | return command?.Execute() ?? 1; |
| 28 | } | 32 | } |
| 29 | 33 | ||
