| 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 WixInternal.TestSupport; |
| 8 | using WixInternal.Core.TestPackage; |
| 9 | using Xunit; |
| 10 | |
| 11 | public class CommandLineFixture |
| 12 | { |
| 13 | [Fact] |
| 14 | public void SwitchIsNotConsideredAnArgument() |
| 15 | { |
| 16 | var result = WixRunner.Execute(new[] |
| 17 | { |
| 18 | "build", |
| 19 | "-bindpath", "-thisisaswitchnotanarg", |
| 20 | }); |
| 21 | |
| 22 | WixAssert.CompareLineByLine(new[] |
| 23 | { |
| 24 | "-bindpath is expected to be followed by a value. See -? for additional detail.", |
| 25 | }, result.Messages.Select(m => m.ToString()).ToArray()); |
| 26 | Assert.Equal(1, result.ExitCode); |
| 27 | } |
| 28 | |
| 29 | [Fact] |
| 30 | public void CannotBuildWithInvalidPlatform() |
| 31 | { |
| 32 | var result = WixRunner.Execute(new[] |
| 33 | { |
| 34 | "build", |
| 35 | "-platform", "foo", |
| 36 | }); |
| 37 | |
| 38 | WixAssert.CompareLineByLine(new[] |
| 39 | { |
| 40 | "The argument -platform value 'foo' is invalid. Use one of the following values x86, x64, arm64" |
| 41 | }, result.Messages.Select(m => m.ToString()).ToArray()); |
| 42 | Assert.Equal(1, result.ExitCode); |
| 43 | } |
| 44 | |
| 45 | [Fact] |
| 46 | public void CanBuildWithNoOutputSpecified() |
| 47 | { |
| 48 | var folder = TestData.Get(@"TestData", "SimplePackage"); |
| 49 | var bindFolder = TestData.Get(@"TestData", "SingleFile", "data"); |
| 50 | |
| 51 | using (var fs = new DisposableFileSystem()) |
| 52 | { |
| 53 | var testFolder = fs.GetFolder(create: true); |
| 54 | var srcFile = Path.Combine(testFolder, "SimplePackage.wxs"); |
| 55 | var intermediateFolder = Path.Combine(testFolder, "obj"); |
| 56 | var expectedPath = Path.Combine(testFolder, "SimplePackage.msi"); |
| 57 | |
| 58 | // Copy the source folder into the test working folder so the output can be written to the same folder. |
| 59 | File.Copy(Path.Combine(folder, "SimplePackage.wxs"), srcFile); |
| 60 | |
| 61 | var result = WixRunner.Execute(new[] |
| 62 | { |
| 63 | "build", srcFile, |
| 64 | "-bindpath", bindFolder, |
| 65 | "-intermediateFolder", intermediateFolder |
| 66 | }); |
| 67 | |
| 68 | result.AssertSuccess(); |
| 69 | Assert.True(File.Exists(expectedPath), $"Expected to build MSI to: {expectedPath}"); |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | } |