コード例 #1
0
ファイル: MsbuildFixture.cs プロジェクト: drolevar/Tools
        public void CanBuildSimpleMsiPackage(BuildSystem buildSystem)
        {
            var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");

            using (var fs = new TestDataFolderFileSystem())
            {
                fs.Initialize(sourceFolder);
                var baseFolder  = fs.BaseFolder;
                var binFolder   = Path.Combine(baseFolder, @"bin\");
                var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");

                var result = MsbuildUtilities.BuildProject(buildSystem, projectPath);
                result.AssertSuccess();

                var platformSwitches = result.Output.Where(line => line.Contains("-platform x86"));
                Assert.Single(platformSwitches);

                var warnings = result.Output.Where(line => line.Contains(": warning"));
                Assert.Equal(4, warnings.Count());

                var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories)
                            .Select(s => s.Substring(baseFolder.Length + 1))
                            .OrderBy(s => s)
                            .ToArray();
                WixAssert.CompareLineByLine(new[]
                {
                    @"bin\x86\Release\en-US\cab1.cab",
                    @"bin\x86\Release\en-US\MsiPackage.msi",
                    @"bin\x86\Release\en-US\MsiPackage.wixpdb",
                }, paths);
            }
        }
コード例 #2
0
ファイル: MsbuildFixture.cs プロジェクト: drolevar/Tools
        public void CanBuildSimpleMsiPackageAsWixipl(BuildSystem buildSystem, bool?outOfProc)
        {
            var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");

            using (var fs = new TestDataFolderFileSystem())
            {
                fs.Initialize(sourceFolder);
                var baseFolder  = fs.BaseFolder;
                var binFolder   = Path.Combine(baseFolder, @"bin\");
                var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");

                var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
                {
                    "-p:OutputType=IntermediatePostLink",
                }, outOfProc: outOfProc);
                result.AssertSuccess();

                var wixBuildCommands = MsbuildUtilities.GetToolCommandLines(result, "wix", "build", buildSystem, outOfProc);
                Assert.Single(wixBuildCommands);

                var path = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories)
                           .Select(s => s.Substring(baseFolder.Length + 1))
                           .Single();
                Assert.Equal(@"bin\x86\Release\MsiPackage.wixipl", path);
            }
        }
コード例 #3
0
ファイル: MsbuildFixture.cs プロジェクト: drolevar/Tools
        public void CanBuildSimpleMergeModule(BuildSystem buildSystem)
        {
            var sourceFolder = TestData.Get(@"TestData\MergeModule\SimpleMergeModule");

            using (var fs = new TestDataFolderFileSystem())
            {
                fs.Initialize(sourceFolder);
                var baseFolder  = fs.BaseFolder;
                var binFolder   = Path.Combine(baseFolder, @"bin\");
                var projectPath = Path.Combine(baseFolder, "SimpleMergeModule.wixproj");

                var result = MsbuildUtilities.BuildProject(buildSystem, projectPath);
                result.AssertSuccess();

                var warnings = result.Output.Where(line => line.Contains(": warning"));
                Assert.Empty(warnings);

                var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories)
                            .Select(s => s.Substring(baseFolder.Length + 1))
                            .OrderBy(s => s)
                            .ToArray();
                WixAssert.CompareLineByLine(new[]
                {
                    @"bin\x86\Release\SimpleMergeModule.msm",
                    @"bin\x86\Release\SimpleMergeModule.wixpdb",
                }, paths);
            }
        }
コード例 #4
0
ファイル: MsbuildFixture.cs プロジェクト: drolevar/Tools
        public void CanBuildAndCleanSimpleMsiPackage(BuildSystem buildSystem)
        {
            var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");

            using (var fs = new TestDataFolderFileSystem())
            {
                fs.Initialize(sourceFolder);
                var baseFolder  = fs.BaseFolder;
                var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");

                // Build
                var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, verbosityLevel: "diag");
                result.AssertSuccess();

                var buildOutput = String.Join("\r\n", result.Output);

                var createdPaths = Directory.EnumerateFiles(baseFolder, @"*.*", SearchOption.AllDirectories)
                                   .Select(s => s.Substring(baseFolder.Length + 1))
                                   .OrderBy(s => s)
                                   .ToArray();
                Assert.NotEmpty(createdPaths);

                // Clean
                result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
                {
                    "-t:Clean",
                }, verbosityLevel: "diag");
                result.AssertSuccess();

                var cleanOutput = String.Join("\r\n", result.Output);

                // Clean is only expected to delete the files listed in {Project}.FileListAbsolute.txt,
                // so this is not quite right but close enough.
                var allowedFiles = new HashSet <string>
                {
                    "MsiPackage.wixproj",
                    "Package.en-us.wxl",
                    "Package.wxs",
                    "PackageComponents.wxs",
                    @"data\test.txt",
                    @"obj\x86\Release\MsiPackage.wixproj.FileListAbsolute.txt",
                };

                var remainingPaths = Directory.EnumerateFiles(baseFolder, @"*.*", SearchOption.AllDirectories)
                                     .Select(s => s.Substring(baseFolder.Length + 1))
                                     .Where(s => !allowedFiles.Contains(s))
                                     .OrderBy(s => s)
                                     .ToArray();
                Assert.Empty(remainingPaths);
            }
        }
コード例 #5
0
ファイル: MsbuildHeatFixture.cs プロジェクト: drolevar/Tools
        public void CanBuildHeatFilePackage(BuildSystem buildSystem)
        {
            var sourceFolder = TestData.Get(@"TestData\HeatFilePackage");

            using (var fs = new TestDataFolderFileSystem())
            {
                fs.Initialize(sourceFolder);
                var baseFolder         = fs.BaseFolder;
                var binFolder          = Path.Combine(baseFolder, @"bin\");
                var intermediateFolder = Path.Combine(baseFolder, @"obj\");
                var projectPath        = Path.Combine(baseFolder, "HeatFilePackage.wixproj");

                var result = MsbuildUtilities.BuildProject(buildSystem, projectPath);
                result.AssertSuccess();

                var heatCommandLines = MsbuildUtilities.GetToolCommandLines(result, "heat", "file", buildSystem, true);
                Assert.Single(heatCommandLines);

                var warnings = result.Output.Where(line => line.Contains(": warning"));
                Assert.Empty(warnings);

                var generatedFilePath = Path.Combine(intermediateFolder, "x86", "Release", "_ProductComponents_INSTALLFOLDER_HeatFilePackage.wixproj_file.wxs");
                Assert.True(File.Exists(generatedFilePath));

                var generatedContents = File.ReadAllText(generatedFilePath);
                var testXml           = generatedContents.GetTestXml();
                Assert.Equal(@"<Wix>" +
                             "<Fragment>" +
                             "<DirectoryRef Id='INSTALLFOLDER'>" +
                             "<Component Id='HeatFilePackage.wixproj' Guid='*'>" +
                             "<File Id='HeatFilePackage.wixproj' KeyPath='yes' Source='SourceDir\\HeatFilePackage.wixproj' />" +
                             "</Component>" +
                             "</DirectoryRef>" +
                             "</Fragment>" +
                             "<Fragment>" +
                             "<ComponentGroup Id='ProductComponents'>" +
                             "<ComponentRef Id='HeatFilePackage.wixproj' />" +
                             "</ComponentGroup>" +
                             "</Fragment>" +
                             "</Wix>", testXml);

                var pdbPath = Path.Combine(binFolder, "x86", "Release", "HeatFilePackage.wixpdb");
                Assert.True(File.Exists(pdbPath));

                var intermediate = Intermediate.Load(pdbPath);
                var section      = intermediate.Sections.Single();

                var fileSymbol = section.Symbols.OfType <FileSymbol>().Single();
                Assert.Equal(@"SourceDir\HeatFilePackage.wixproj", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path);
            }
        }
コード例 #6
0
ファイル: MsbuildFixture.cs プロジェクト: drolevar/Tools
        public void CanBuildSimpleMsiPackageWithIceSuppressions(BuildSystem buildSystem)
        {
            var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");

            using (var fs = new TestDataFolderFileSystem())
            {
                fs.Initialize(sourceFolder);
                var baseFolder  = fs.BaseFolder;
                var binFolder   = Path.Combine(baseFolder, @"bin\");
                var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");

                var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
                {
                    MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "SuppressIces", "ICE45;ICE46"),
                });
                result.AssertSuccess();
            }
        }
コード例 #7
0
ファイル: MsbuildFixture.cs プロジェクト: drolevar/Tools
        public void ReportsInnerExceptionForUnexpectedExceptions(BuildSystem buildSystem)
        {
            var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");

            using (var fs = new TestDataFolderFileSystem())
            {
                fs.Initialize(sourceFolder);
                var baseFolder  = fs.BaseFolder;
                var binFolder   = Path.Combine(baseFolder, @"bin\");
                var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");

                var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
                {
                    MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixToolDir", Path.Combine(MsbuildUtilities.WixMsbuildPath, "broken", "net461")),
                }, outOfProc: true);
                Assert.Equal(1, result.ExitCode);

                var expectedMessage = "System.PlatformNotSupportedException: Could not find platform specific 'wixnative.exe' ---> System.IO.FileNotFoundException: Could not find internal piece of WiX Toolset from";
                Assert.Contains(result.Output, m => m.Contains(expectedMessage));
            }
        }
コード例 #8
0
ファイル: MsbuildFixture.cs プロジェクト: drolevar/Tools
        public void CanBuildSimpleMsiPackageWithWarningSuppressions(BuildSystem buildSystem)
        {
            var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");

            using (var fs = new TestDataFolderFileSystem())
            {
                fs.Initialize(sourceFolder);
                var baseFolder  = fs.BaseFolder;
                var binFolder   = Path.Combine(baseFolder, @"bin\");
                var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");

                var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
                {
                    MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "SuppressSpecificWarnings", "1118;1102"),
                });
                result.AssertSuccess();

                var warnings = result.Output.Where(line => line.Contains(": warning"));
                Assert.Empty(warnings);
            }
        }
コード例 #9
0
ファイル: MsbuildFixture.cs プロジェクト: drolevar/Tools
        private void AssertWixpdb(BuildSystem buildSystem, string wixpdbType, string[] expectedOutputFiles)
        {
            var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");

            using (var fs = new TestDataFolderFileSystem())
            {
                fs.Initialize(sourceFolder);
                var baseFolder  = fs.BaseFolder;
                var binFolder   = Path.Combine(baseFolder, @"bin\");
                var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj");

                var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
                {
                    wixpdbType == null ? String.Empty : $"-p:WixPdbType={wixpdbType}",
                });
                result.AssertSuccess();

                var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories)
                            .Select(s => s.Substring(baseFolder.Length + 1))
                            .OrderBy(s => s)
                            .ToArray();
                WixAssert.CompareLineByLine(expectedOutputFiles, paths);
            }
        }
コード例 #10
0
ファイル: MsbuildHeatFixture.cs プロジェクト: drolevar/Tools
        public void CanBuildHeatProjectSdkStyle(BuildSystem buildSystem, bool useToolsVersion)
        {
            var sourceFolder = TestData.Get(@"TestData\HeatProject");

            using (var fs = new TestDataFolderFileSystem())
            {
                fs.Initialize(sourceFolder);
                var baseFolder            = Path.Combine(fs.BaseFolder, "HeatProjectSdkStyle");
                var binFolder             = Path.Combine(baseFolder, @"bin\");
                var intermediateFolder    = Path.Combine(baseFolder, @"obj\");
                var projectPath           = Path.Combine(baseFolder, "HeatProjectSdkStyle.wixproj");
                var referencedProjectPath = Path.Combine(fs.BaseFolder, "SdkStyleCs", "SdkStyleCs.csproj");

                var result = MsbuildUtilities.BuildProject(buildSystem, referencedProjectPath, new[]
                {
                    "-t:restore",
                });
                result.AssertSuccess();

                result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
                {
                    useToolsVersion ? $"-p:HarvestProjectsUseToolsVersion=true" : String.Empty,
                });
                result.AssertSuccess();

                var heatCommandLines = MsbuildUtilities.GetToolCommandLines(result, "heat", "project", buildSystem, true);
                var heatCommandLine  = Assert.Single(heatCommandLines);

                if (useToolsVersion && buildSystem != BuildSystem.DotNetCoreSdk)
                {
                    Assert.Contains("-usetoolsversion", heatCommandLine);
                }
                else
                {
                    Assert.DoesNotContain("-usetoolsversion", heatCommandLine);
                }

                var warnings = result.Output.Where(line => line.Contains(": warning"));
                Assert.Empty(warnings);

                var generatedFilePath = Path.Combine(intermediateFolder, "x86", "Release", "_SdkStyleCs.wxs");
                Assert.True(File.Exists(generatedFilePath));

                var generatedContents = File.ReadAllText(generatedFilePath);
                var testXml           = generatedContents.GetTestXml();
                Assert.Equal(@"<Wix>" +
                             "<Fragment>" +
                             "<DirectoryRef Id='SdkStyleCs.Binaries'>" +
                             "<Component Id='SdkStyleCs.Binaries.SdkStyleCs.dll' Guid='*'>" +
                             "<File Id='SdkStyleCs.Binaries.SdkStyleCs.dll' Source='$(var.SdkStyleCs.TargetDir)\\SdkStyleCs.dll' />" +
                             "</Component>" +
                             "</DirectoryRef>" +
                             "</Fragment>" +
                             "<Fragment>" +
                             "<ComponentGroup Id='SdkStyleCs.Binaries'>" +
                             "<ComponentRef Id='SdkStyleCs.Binaries.SdkStyleCs.dll' />" +
                             "</ComponentGroup>" +
                             "</Fragment>" +
                             "<Fragment>" +
                             "<DirectoryRef Id='SdkStyleCs.Symbols'>" +
                             "<Component Id='SdkStyleCs.Symbols.SdkStyleCs.pdb' Guid='*'>" +
                             "<File Id='SdkStyleCs.Symbols.SdkStyleCs.pdb' Source='$(var.SdkStyleCs.TargetDir)\\SdkStyleCs.pdb' />" +
                             "</Component>" +
                             "</DirectoryRef>" +
                             "</Fragment>" +
                             "<Fragment>" +
                             "<ComponentGroup Id='SdkStyleCs.Symbols'>" +
                             "<ComponentRef Id='SdkStyleCs.Symbols.SdkStyleCs.pdb' />" +
                             "</ComponentGroup>" +
                             "</Fragment>" +
                             "<Fragment>" +
                             "<DirectoryRef Id='SdkStyleCs.Sources'>" +
                             "<Component Id='SdkStyleCs.Sources.SdkStyleCs.cs' Guid='*'>" +
                             "<File Id='SdkStyleCs.Sources.SdkStyleCs.cs' Source='$(var.SdkStyleCs.ProjectDir)\\SdkStyleCs.cs' />" +
                             "</Component>" +
                             "<Component Id='SdkStyleCs.Sources.SdkStyleCs.csproj' Guid='*'>" +
                             "<File Id='SdkStyleCs.Sources.SdkStyleCs.csproj' Source='$(var.SdkStyleCs.ProjectDir)\\SdkStyleCs.csproj' />" +
                             "</Component>" +
                             "</DirectoryRef>" +
                             "</Fragment>" +
                             "<Fragment>" +
                             "<ComponentGroup Id='SdkStyleCs.Sources'>" +
                             "<ComponentRef Id='SdkStyleCs.Sources.SdkStyleCs.cs' />" +
                             "<ComponentRef Id='SdkStyleCs.Sources.SdkStyleCs.csproj' />" +
                             "</ComponentGroup>" +
                             "</Fragment>" +
                             "<Fragment>" +
                             "<ComponentGroup Id='SdkStyleCs.Content' />" +
                             "</Fragment>" +
                             "<Fragment>" +
                             "<ComponentGroup Id='SdkStyleCs.Satellites' />" +
                             "</Fragment>" +
                             "<Fragment>" +
                             "<ComponentGroup Id='SdkStyleCs.Documents' />" +
                             "</Fragment>" +
                             "</Wix>", testXml);

                var pdbPath = Path.Combine(binFolder, "x86", "Release", "HeatProjectSdkStyle.wixpdb");
                Assert.True(File.Exists(pdbPath));

                var intermediate = Intermediate.Load(pdbPath);
                var section      = intermediate.Sections.Single();

                var fileSymbol = section.Symbols.OfType <FileSymbol>().Single();
                Assert.Equal(Path.Combine(fs.BaseFolder, "SdkStyleCs", "bin", "Release", "netstandard2.0\\\\SdkStyleCs.dll"), fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path);
            }
        }