Ejemplo n.º 1
0
        public void LongIdentifiers()
        {
            string longDirectoryName = "Directory_01234567890123456789012345678901234567890123456789012345678901234567890123456789";
            string longComponentName = "Component_01234567890123456789012345678901234567890123456789012345678901234567890123456789";
            string longFileName = "Test_txt_01234567890123456789012345678901234567890123456789012345678901234567890123456789";

            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(IdentifierTests.TestDataDirectory, @"LongIdentifiers\product.wxs"));
            candle.ExpectedWixMessages.Add(new WixMessage(1026, string.Format("The Directory/@Id attribute's value, '{0}', is too long for an identifier.  Standard identifiers are 72 characters long or less.", longDirectoryName),WixMessage.MessageTypeEnum.Warning));
            candle.ExpectedWixMessages.Add(new WixMessage(1026, string.Format("The Component/@Id attribute's value, '{0}', is too long for an identifier.  Standard identifiers are 72 characters long or less.", longComponentName), WixMessage.MessageTypeEnum.Warning));
            candle.ExpectedWixMessages.Add(new WixMessage(1026, string.Format("The File/@Id attribute's value, '{0}', is too long for an identifier.  Standard identifiers are 72 characters long or less.", longFileName), WixMessage.MessageTypeEnum.Warning));
            candle.ExpectedWixMessages.Add(new WixMessage(1026, string.Format("The ComponentRef/@Id attribute's value, '{0}', is too long for an identifier.  Standard identifiers are 72 characters long or less.", longComponentName), WixMessage.MessageTypeEnum.Warning));
            candle.Run();

            Light light = new Light(candle);
            light.SuppressedICEs.Add("ICE03");
            light.Run();

            // verify long names in the resulting msi
            string query = string.Format("SELECT `Directory` FROM `Directory` WHERE `Directory` = '{0}'", longDirectoryName);
            string queryResult = Verifier.Query(light.OutputFile, query);
            Assert.Equal(longDirectoryName, queryResult);

            query = string.Format("SELECT `Component` FROM `Component` WHERE `Component` = '{0}'", longComponentName);
            queryResult = Verifier.Query(light.OutputFile, query);
            Assert.Equal(longComponentName, queryResult);

            query = string.Format("SELECT `File` FROM `File` WHERE `File` = '{0}'", longFileName);
            queryResult = Verifier.Query(light.OutputFile, query);
            Assert.Equal(longFileName, queryResult);

            query = string.Format("SELECT `Component_` FROM `FeatureComponents` WHERE `Component_` = '{0}'", longComponentName);
            queryResult = Verifier.Query(light.OutputFile, query);
            Assert.Equal(longComponentName, queryResult);
        }
Ejemplo n.º 2
0
        public void NamedBindPath()
        {
            // Create a temp text file to bind into the wix library
            DirectoryInfo tempDirectory = Directory.CreateDirectory(Utilities.FileUtilities.GetUniqueFileName());
            string testFileName = Path.Combine(tempDirectory.FullName, "TextFile1.txt");
            StreamWriter outputFile =  File.CreateText(testFileName);
            outputFile.Write("abc");
            outputFile.Close();

            // Build the library
            Lit lit = new Lit();
            lit.ObjectFiles.Add(Candle.Compile(Path.Combine(BindPathTests.TestDataDirectory, @"NamedBindPath\Product.wxs")));
            lit.BindPath = String.Concat("Test=", tempDirectory.FullName);
            lit.BindFiles = true;
            lit.Run();

            // Delete the source file
            File.Delete(testFileName);

            // Link the library and verify files are in the resulting msi layout
            Light light = new Light(lit);
            light.Run();

            string outputFileName = Path.Combine(Path.GetDirectoryName(lit.OutputFile), @"PFiles\WixTestFolder\TextFile1.txt");
            Assert.IsTrue(File.Exists(outputFileName), "File was not created in msi layout as expected.");
            Assert.IsTrue(File.ReadAllText(outputFileName).Equals("abc"), "File contents do not match expected.");
        }
Ejemplo n.º 3
0
        public void PreMsi50ShortcutProperty()
        {
            // Loop through a list of pre-MSI 5.0 Windows Installer version
            foreach (MSIVersions.Versions version in Enum.GetValues(typeof(MSIVersions.Versions)))
            {
                // Skip MSI 5.0 and later
                if (MSIVersions.GetVersion(version) >= MSIVersions.GetVersion(MSIVersions.Versions.MSI50))
                {
                    continue;
                }

                Candle candle = new Candle();
                candle.SourceFiles.Add(Path.Combine(ShortcutPropertyTests.TestDataDirectory, @"PreMsi50ShortcutProperty\product.wxs"));
                candle.PreProcessorParams.Add("InstallerVersion", MSIVersions.GetVersionInMSIFormat(version));
                candle.Run();

                Light light = new Light(candle);

                // Only run validation on MSIs built with the current or earlier than current versions of Windows Installer
                if (DTF.Installer.Version < MSIVersions.GetVersion(version))
                {
                    light.SuppressMSIAndMSMValidation = true;
                }

                light.Run();
            }
        }
Ejemplo n.º 4
0
        public void SimplePedantic()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(WixTests.SharedAuthoringDirectory, "BasicProduct.wxs"));
            candle.Run();

            Light light = new Light(candle);
            light.Pedantic = true;
            light.Run();
        }
        public void SimpleSuppressWarnings()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Environment.ExpandEnvironmentVariables(Path.Combine(SuppressWarningsTests.TestDataDirectory, @"Shared\Warning1079.wxs")));
            candle.Run();

            Light light = new Light(candle);
            light.SuppressWarnings.Add("1079");
            light.Run();
        }
Ejemplo n.º 6
0
        public void SF1824809()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(RegressionTests.TestDataDirectory, @"SF1824809\product.wxs"));
            candle.Run();

            Light light = new Light();
            light.ObjectFiles = candle.ExpectedOutputFiles;
            light.Run();
        }
Ejemplo n.º 7
0
        public void SimpleSuppressICE()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(SuppressICEsTests.TestDataDirectory, @"SimpleSuppressICE\product.wxs"));
            candle.Run();

            Light light = new Light(candle);
            light.SuppressedICEs.Add("ICE18");
            light.Run();
        }
Ejemplo n.º 8
0
        public void InvalidCultures()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(WixTests.BasicProductWxs);
            candle.Run();

            Light light = new Light(candle);
            light.Cultures = "en-US;in-VA;lid";
            light.Run();
        }
Ejemplo n.º 9
0
        public void DuplicateRemoveFolders()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(RemoveFolderTests.TestDataDirectory, @"DuplicateRemoveFolders\product.wxs"));
            candle.Run();

            Light light = new Light(candle);
            light.ExpectedWixMessages.Add(new WixMessage(130, "The primary key 'RemoveFolder1' is duplicated in table 'RemoveFile'.  Please remove one of the entries or rename a part of the primary key to avoid the collision.", WixMessage.MessageTypeEnum.Error));
            light.ExpectedExitCode = 130;
            light.Run();
        }
        public void ValidIdentifier()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(LocalizationTests.TestDataDirectory, @"ValidIdentifier\product.wxs"));
            candle.Run();

            Light light = new Light(candle);
            light.LocFiles.Add(Path.Combine(LocalizationTests.TestDataDirectory, @"ValidIdentifier\en-us.wxl"));
            light.Cultures = "en-us";
            light.Run();
        }
Ejemplo n.º 11
0
        public void SimpleReuseCab()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(ReuseCabTests.TestDataDirectory, @"SimpleReuseCab\product.wxs"));
            candle.Run();

            Light light = new Light(candle);
            light.ReuseCab = true;
            light.CachedCabsPath = Path.Combine(ReuseCabTests.TestDataDirectory, "SimpleReuseCab");
            light.Run();
        }
Ejemplo n.º 12
0
        public void Codepage_x_EBCDIC_KoreanExtended()
        {
            string codepage = "x-EBCDIC-KoreanExtended";

            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(ProductTests.TestDataDirectory, @"Codepage\product.wxs"));
            candle.PreProcessorParams.Add("Codepage", codepage);
            candle.Run();

            Light light = new Light(candle);
            light.Run();
        }
Ejemplo n.º 13
0
        public void NullValues()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(CustomTableTests.TestDataDirectory, @"NullValues\product.wxs"));
            candle.Run();

            Light light = new Light(candle);
            light.ExpectedWixMessages.Add(new WixMessage(53, "There is no data for column 'Column2' in a contained row of custom table 'CustomTable1'.  A non-null value must be supplied for this column.", WixMessage.MessageTypeEnum.Error));
            light.ExpectedWixMessages.Add(new WixMessage(53, "There is no data for column 'Column2' in a contained row of custom table 'CustomTable1'.  A non-null value must be supplied for this column.", WixMessage.MessageTypeEnum.Error));
            light.ExpectedExitCode = 53;
            light.Run();
        }
Ejemplo n.º 14
0
        public void InvalidType()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(CustomTableTests.TestDataDirectory, @"InvalidType\product.wxs"));
            candle.Run();

            Light light = new Light(candle);
            light.ExpectedWixMessages.Add(new WixMessage(8, "The Column2/@CustomTable1 attribute's value, 'C', is not a legal integer value.  Legal integer values are from -2,147,483,648 to 2,147,483,647.", WixMessage.MessageTypeEnum.Error));
            light.ExpectedWixMessages.Add(new WixMessage(53, "There is no data for column 'Column2' in a contained row of custom table 'CustomTable1'.  A non-null value must be supplied for this column.", WixMessage.MessageTypeEnum.Error));
            light.ExpectedExitCode = 53;
            light.Run();
        }
Ejemplo n.º 15
0
        public void ChainDuplicatePackages()
        {
            string candleOutput = Candle.Compile(Path.Combine(ChainTests.TestDataDirectory, @"ChainDuplicatePackages\Product.wxs"));

            Light light = new Light();
            light.ObjectFiles.Add(candleOutput);
            light.OutputFile = "setup.exe";
            light.ExpectedWixMessages.Add(new WixMessage(91, "Duplicate symbol 'ChainPackage:Package1' found.", Message.MessageTypeEnum.Error));
            light.ExpectedWixMessages.Add(new WixMessage(92, "Location of symbol related to previous error.", Message.MessageTypeEnum.Error));
            light.ExpectedExitCode = 92;
            light.Run();
        }
Ejemplo n.º 16
0
        public void SimpleWarningsAsErrors()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(WarningsAsErrorsTests.TestDataDirectory, @"Shared\Warning1079.wxs"));
            candle.Run();

            Light light = new Light(candle);
            light.TreatAllWarningsAsErrors = true;
            light.ExpectedWixMessages.Add(new WixMessage(1079, WixMessage.MessageTypeEnum.Error));
            light.ExpectedExitCode = 1079;
            light.Run();
        }
Ejemplo n.º 17
0
        public void SimpleBindPath()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(BindPathTests.TestDataDirectory, @"SimpleBindPath\product.wxs"));
            candle.Run();

            Light light = new Light(candle);
            light.BindPath = WixTests.SharedFilesDirectory;
            light.Run();

            Verifier.VerifyResults(Path.Combine(BindPathTests.TestDataDirectory, @"SimpleBindPath\expected.msi"), light.OutputFile);
        }
Ejemplo n.º 18
0
        public void Codepage_UTF32()
        {
            string codepage = "utf-32";

            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(ProductTests.TestDataDirectory, @"Codepage\product.wxs"));
            candle.PreProcessorParams.Add("Codepage", codepage);
            candle.Run();

            Light light = new Light(candle);
            light.Run();
        }
Ejemplo n.º 19
0
        public void MultipleWixobjs()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(WixobjTests.TestDataDirectory, @"WixobjTests\product.wxs"));
            candle.SourceFiles.Add(Path.Combine(WixobjTests.TestDataDirectory, @"WixobjTests\features.wxs"));
            candle.SourceFiles.Add(Path.Combine(WixobjTests.TestDataDirectory, @"WixobjTests\component1.wxs"));
            candle.Run();

            Light light = new Light();
            light.ObjectFiles = candle.ExpectedOutputFiles;
            light.Run();
        }
Ejemplo n.º 20
0
        public void ValidServiceConfig()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(RegressionTests.TestDataDirectory,@"ValidServiceConfig\product.wxs"));
            candle.Extensions.Add("WixUtilExtension");
            candle.Run();

            Light light = new Light(candle);
            light.Extensions.Add("WixUtilExtension");
            light.OutputFile = string.Empty;
            light.Run();
        }
        public void Hebrew()
        {
            string wixobj = Candle.Compile(Path.Combine(LocalizationTests.TestDataDirectory, @"Shared\product.wxs"));

            Light light = new Light();
            light.ObjectFiles.Add(wixobj);
            light.LocFiles.Add(Path.Combine(LocalizationTests.TestDataDirectory, @"he-il\he-il.wxl"));
            light.OutputFile = Path.Combine(Path.Combine(this.TestContext.TestDir, Path.GetRandomFileName()), "he-il.msi");
            light.Run();

            Verifier.CompareResults(Path.Combine(LocalizationTests.TestDataDirectory, @"he-il\he-il.msi"), light.OutputFile);
        }
Ejemplo n.º 22
0
        public void ChainDuplicatePackageGroupRefs()
        {
            string candleOutput = Candle.Compile(Path.Combine(ChainTests.TestDataDirectory, @"ChainDuplicatePackageGroupRefs\Product.wxs"));

            Light light = new Light();
            light.ObjectFiles.Add(candleOutput);
            light.OutputFile = "setup.exe";
            light.ExpectedWixMessages.Add(new WixMessage(343, Message.MessageTypeEnum.Error)); //A circular reference of ordering dependencies was detected.
            light.IgnoreWixMessageOrder = true;
            light.ExpectedExitCode = 343;
            light.Run();
        }
Ejemplo n.º 23
0
        public void SimpleShortcut()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(ShortcutTests.TestDataDirectory, @"SimpleShortcut\product.wxs"));
            candle.Run();

            Light light = new Light(candle);
            light.SuppressedICEs.Add("ICE66");
            light.Run();

            Verifier.VerifyResults(Path.Combine(ShortcutTests.TestDataDirectory, @"SimpleShortcut\expected.msi"), light.OutputFile, "Shortcut");
        }
Ejemplo n.º 24
0
        public void DuplicateIgnoreModularization()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(RegressionTests.TestDataDirectory, @"DuplicateIgnoreModularization\product.wxs"));
            // supress deprecated element warning
            candle.SuppressWarnings.Add(1085);
            candle.Run();

            Light light = new Light();
            light.ObjectFiles = candle.ExpectedOutputFiles;
            light.Run();
        }
Ejemplo n.º 25
0
        public void SF1656236()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(RegressionTests.TestDataDirectory, @"SF1656236\product.wxs"));
            candle.Run();

            Light light = new Light();
            light.ObjectFiles = candle.ExpectedOutputFiles;
            light.Run();

            // Verify that the DrLocator table was generated correctly
        }
Ejemplo n.º 26
0
        public void CircularReferences()
        {
            string sourceFile = Path.Combine(ComponentTests.TestDataDirectory, @"CircularReferences\product.wxs");

            Candle candle = new Candle();
            candle.SourceFiles.Add(sourceFile);
            candle.Run();

            Light light = new Light(candle);
            light.ExpectedExitCode = 86;
            light.ExpectedWixMessages.Add(new WixMessage(86, "A circular reference of groups was detected. The infinite loop includes: ComponentGroup:ComponentGroup1. Group references must form a directed acyclic graph.", WixMessage.MessageTypeEnum.Error));
            light.Run();
        }
Ejemplo n.º 27
0
        public void CopyNonExistingFile()
        {
            string sourceFile = Path.Combine(CopyFileTests.TestDataDirectory, @"CopyNonExistingFile\product.wxs");

            Candle candle = new Candle();
            candle.SourceFiles.Add(sourceFile);
            candle.Run();

            Light light = new Light(candle);
            light.ExpectedExitCode = 94;
            light.ExpectedWixMessages.Add(new WixMessage(94, "Unresolved reference to symbol 'File:test' in section 'Product:*'.", WixMessage.MessageTypeEnum.Error));
            light.Run();
        }
        public void InvalidSharedComponent()
        {
            string sourceFile = Path.Combine(IsolateComponentTests.TestDataDirectory, @"InvalidSharedComponent\product.wxs");

            Candle candle = new Candle();
            candle.SourceFiles.Add(sourceFile);
            candle.Run();

            Light light = new Light(candle);
            light.ExpectedExitCode = 94;
            light.ExpectedWixMessages.Add (new WixMessage (94,"Unresolved reference to symbol 'Component:Component2' in section 'Product:*'.",Message.MessageTypeEnum.Error));
            light .Run();
        }
Ejemplo n.º 29
0
        public void DefaultVersion()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(FileTests.TestDataDirectory, @"DefaultVersion\product.wxs"));
            candle.Run();

            Light light = new Light(candle);
            light.ExpectedWixMessages.Add(new WixMessage(1103, "The DefaultVersion '3.0.0.0' was used for file 'TextFile1.txt' which has no version. No entry for this file will be placed in the MsiFileHash table. For unversioned files, specifying a version that is different from the actual file may result in unexpected versioning behavior during a repair or while patching. Version the resource to eliminate this warning.", WixMessage.MessageTypeEnum.Warning));
            light.Run();

            // verify unversioned file is not added to the msifilehash table
            Verifier.VerifyNotTableExists(light.OutputFile, "MsiFileHash");
        }
Ejemplo n.º 30
0
        public void InvalidCommandLineArguments()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(WixTests.BasicProductWxs);
            candle.Run();

            Light light = new Light();
            light.ObjectFiles = candle.ExpectedOutputFiles;
            light.OtherArguments = " -abc";
            light.ExpectedWixMessages.Add(new WixMessage(1098, "'abc' is not a valid command line argument.", WixMessage.MessageTypeEnum.Warning));
            light.ExpectedExitCode = 0;
            light.Run();
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Builds the package.
        /// </summary>
        /// <returns>The path to the built MSI package.</returns>
        protected override BundleBuilder BuildItem()
        {
            // Create paths.
            string rootDirectory = FileUtilities.GetUniqueFileName();
            string objDirectory  = Path.Combine(rootDirectory, Settings.WixobjFolder);
            string exeDirectory  = Path.Combine(rootDirectory, "Bundles");
            string bundle        = Path.Combine(exeDirectory, String.Concat(this.Name, ".exe"));

            // Add the root directory to be cleaned up.
            this.TestArtifacts.Add(new DirectoryInfo(rootDirectory));

            // Compile.
            Candle candle = new Candle();

            candle.Extensions.AddRange(this.Extensions);
            candle.OtherArguments = String.Concat("-dTestName=", this.TestName);
            this.PreprocessorVariables.ToList().ForEach(kv => candle.OtherArguments = String.Concat(candle.OtherArguments, " -d", kv.Key, "=", kv.Value));
            candle.OutputFile = String.Concat(objDirectory, @"\");
            candle.SourceFiles.Add(this.SourceFile);
            candle.SourceFiles.AddRange(this.AdditionalSourceFiles);
            candle.WorkingDirectory = this.TestDataDirectory;
            candle.ExpectedExitCode = ExpectedCandleExitCode;
            candle.Run();

            // Make sure the output directory is cleaned up.
            this.TestArtifacts.Add(new DirectoryInfo(objDirectory));

            // Link.
            Light light = new Light();

            light.Extensions.AddRange(this.Extensions);
            light.OtherArguments = String.Format("-b build={0} -b data={1}", Settings.WixBuildDirectory, Environment.ExpandEnvironmentVariables(@"%WIX_ROOT%\test\data\"));
            this.BindPaths.ToList().ForEach(kv => light.OtherArguments = String.Concat(light.OtherArguments, " -b ", kv.Key, "=", kv.Value));
            light.ObjectFiles = candle.ExpectedOutputFiles;
            light.OutputFile  = bundle;
            light.SuppressPatchSequenceData   = this.SuppressPatchSequenceData;
            light.SuppressMSIAndMSMValidation = true;
            light.WorkingDirectory            = this.TestDataDirectory;
            light.ExpectedExitCode            = ExpectedLightExitCode;
            light.Run();

            // Make sure the output directory is cleaned up.
            this.TestArtifacts.Add(new DirectoryInfo(exeDirectory));

            this.Output = light.OutputFile;
            return(this);
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Builds the package.
        /// </summary>
        /// <returns>The path to the built MSI package.</returns>
        protected override PackageBuilder BuildItem()
        {
            // Create paths.
            string source        = String.IsNullOrEmpty(this.SourceFile) ? Path.Combine(this.DataFolder, String.Concat(this.Name, ".wxs")) : this.SourceFile;
            string rootDirectory = FileUtilities.GetUniqueFileName();
            string objDirectory  = Path.Combine(rootDirectory, Settings.WixobjFolder);
            string msiDirectory  = Path.Combine(rootDirectory, Settings.MSIFolder);
            string package       = Path.Combine(msiDirectory, String.Concat(this.Name, ".msi"));

            // Add the root directory to be cleaned up.
            this.Artifacts.Add(new DirectoryInfo(rootDirectory));

            // Compile.
            Candle candle = new Candle();

            candle.Extensions.AddRange(this.Extensions);
            candle.OtherArguments = String.Concat("-dTestName=", this.TestName);
            this.PreprocessorVariables.ToList().ForEach(kv => candle.OtherArguments = String.Concat(candle.OtherArguments, " -d", kv.Key, "=", kv.Value));
            candle.OutputFile = String.Concat(objDirectory, @"\");
            candle.SourceFiles.Add(source);
            candle.SourceFiles.AddRange(this.AdditionalSourceFiles);
            candle.WorkingDirectory = this.DataFolder;
            candle.Run();

            // Make sure the output directory is cleaned up.
            this.Artifacts.Add(new DirectoryInfo(objDirectory));

            // Link.
            Light light = new Light();

            light.Extensions.AddRange(this.Extensions);
            light.OtherArguments = String.Concat("-b data=", Environment.ExpandEnvironmentVariables(@"%WIX_ROOT%\test\data\"));
            this.BindPaths.ToList().ForEach(kv => light.OtherArguments = String.Concat(light.OtherArguments, " -b ", kv.Key, "=", kv.Value));
            light.ObjectFiles = candle.ExpectedOutputFiles;
            light.OutputFile  = package;
            light.SuppressMSIAndMSMValidation = true;
            light.WorkingDirectory            = this.DataFolder;
            light.Run();

            // Make sure the output directory is cleaned up.
            this.Artifacts.Add(new DirectoryInfo(msiDirectory));

            this.Output = light.OutputFile;
            return(this);
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Build a setup package from the specified sources
        /// </summary>
        /// <param name="workingDirectory">The working directory from where Candle and Light are run</param>
        /// <param name="sourceFiles">The .wxs files to compile</param>
        /// <param name="outputFile">The name of the output file</param>
        /// <param name="outputToTemp">Save the output to temp</param>
        /// <param name="otherCandleArgs">Additional arguments to pass to Candle.exe</param>
        /// <param name="otherLightArgs">Additional arguments to pass to Light.exe</param>
        /// <returns>The path to the output file</returns>
        public static string BuildPackage(string workingDirectory, string[] sourceFiles, string outputFile, bool outputToTemp, string otherCandleArgs, string otherLightArgs)
        {
            // Determine where to save the output
            string outputDirectory = Environment.CurrentDirectory;

            if (outputToTemp && Path.IsPathRooted(outputFile))
            {
                outputDirectory = FileUtilities.GetUniqueFileName();
            }

            // Create a directory for intermediate wixobj output
            string wixobjDirectory = Path.Combine(outputDirectory, Settings.WixobjFolder);

            FileUtilities.CreateOutputDirectory(wixobjDirectory);

            // Compile
            Candle candle = new Candle();

            candle.WorkingDirectory = workingDirectory;
            candle.SourceFiles      = new List <string>(sourceFiles);
            candle.OutputFile       = String.Concat(wixobjDirectory, @"\");
            candle.OtherArguments   = otherCandleArgs;
            candle.Run();

            // Link
            Light light = new Light();

            light.WorkingDirectory = workingDirectory;
            light.ObjectFiles      = candle.ExpectedOutputFiles;
            light.OutputFile       = Path.Combine(outputDirectory, outputFile);
            FileUtilities.CreateOutputDirectory(Path.GetDirectoryName(light.OutputFile));
            light.OutputFile     = Path.Combine(outputDirectory, outputFile);
            light.OtherArguments = otherLightArgs;
            light.Run();

            return(light.OutputFile);
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Builds a patch using given paths for the target and upgrade packages.
        /// </summary>
        /// <returns>The path to the patch.</returns>
        protected override PatchBuilder BuildItem()
        {
            // Create paths.
            string source        = String.IsNullOrEmpty(this.SourceFile) ? Path.Combine(this.TestDataDirectory, String.Concat(this.Name, ".wxs")) : this.SourceFile;
            string rootDirectory = FileUtilities.GetUniqueFileName();
            string objDirectory  = Path.Combine(rootDirectory, Settings.WixobjFolder);
            string msiDirectory  = Path.Combine(rootDirectory, Settings.MspFolder);
            string wixmsp        = Path.Combine(objDirectory, String.Concat(this.Name, ".wixmsp"));
            string package       = Path.Combine(msiDirectory, String.Concat(this.Name, ".msp"));

            // Add the root directory to be cleaned up.
            this.TestArtifacts.Add(new DirectoryInfo(rootDirectory));

            // Compile.
            Candle candle = new Candle();

            candle.Extensions.AddRange(this.Extensions);
            candle.OtherArguments = String.Concat("-dTestName=", this.TestName);
            this.PreprocessorVariables.ToList().ForEach(kv => candle.OtherArguments = String.Concat(candle.OtherArguments, " -d", kv.Key, "=", kv.Value));
            candle.OutputFile = String.Concat(objDirectory, @"\");
            candle.SourceFiles.Add(source);
            candle.WorkingDirectory = this.TestDataDirectory;
            candle.Run();

            // Make sure the output directory is cleaned up.
            this.TestArtifacts.Add(new DirectoryInfo(objDirectory));

            // Link.
            Light light = new Light();

            light.Extensions.AddRange(this.Extensions);
            light.OtherArguments = String.Concat("-b data=", Environment.ExpandEnvironmentVariables(@"%WIX_ROOT%\test\data\"));
            this.BindPaths.ToList().ForEach(kv => light.OtherArguments = String.Concat(light.OtherArguments, " -b ", kv.Key, "=", kv.Value));
            light.ObjectFiles = candle.ExpectedOutputFiles;
            light.OutputFile  = wixmsp;
            light.SuppressMSIAndMSMValidation = true;
            light.WorkingDirectory            = this.TestDataDirectory;
            light.Run();

            // Make sure the output directory is cleaned up.
            this.TestArtifacts.Add(new DirectoryInfo(msiDirectory));

            // Pyro.
            Pyro pyro = new Pyro();

            Assert.NotNull(this.TargetPaths);
            Assert.NotNull(this.UpgradePaths);
            Assert.Equal <int>(this.TargetPaths.Length, this.UpgradePaths.Length);

            for (int i = 0; i < this.TargetPaths.Length; ++i)
            {
                // Torch.
                Torch torch = new Torch();
                torch.TargetInput        = Path.ChangeExtension(this.TargetPaths[i], "wixpdb");
                torch.UpdatedInput       = Path.ChangeExtension(this.UpgradePaths[i], "wixpdb");
                torch.PreserveUnmodified = true;
                torch.XmlInput           = true;
                torch.OutputFile         = Path.Combine(objDirectory, String.Concat(Path.GetRandomFileName(), ".wixmst"));
                torch.WorkingDirectory   = this.TestDataDirectory;
                torch.Run();

                pyro.Baselines.Add(torch.OutputFile, this.Name);
            }

            pyro.InputFile        = light.OutputFile;
            pyro.OutputFile       = package;
            pyro.WorkingDirectory = this.TestDataDirectory;
            pyro.SuppressWarnings.Add("1079");
            pyro.Run();

            this.Output = pyro.OutputFile;
            return(this);
        }
Ejemplo n.º 35
0
        //public static string Link(string sourceFile, string otherArguments)
        //{
        //    return Light.Link(new string[] { sourceFile }, ootherArguments);
        //}

        //public static string Link(string sourceFile, string otherArguments, WixMessage[] expectedMessages)
        //{
        //    return Light.Link(new string[] { sourceFile }, otherArguments, expectedMessages);
        //}

        //public static string Link(string[] sourceFiles, string otherArguments)
        //{
        //    return Light.Link(sourceFiles, otherArguments, null);
        //}

        //public static string Link(string[] sourceFiles, string otherArguments, WixMessage[] expectedMessages)
        //{
        //    return Light.Link(sourceFiles, otherArguments, false, expectedMessages);
        //}



        public static string Link(
            string[] objectFiles,
            bool allowIdenticalRows       = false,
            bool allowUnresolvedVariables = false,
            string bindPath                  = null,
            bool bindFiles                   = false,
            int cabbingThreads               = 0,
            string cachedCabsPath            = null,
            string cultures                  = null,
            WixMessage[] expectedWixMessages = null,
            string[] extensions              = null,
            bool fileVersion                 = false,
            string[] ices                             = null,
            string[] locFiles                         = null,
            bool noTidy                               = false,
            string otherArguments                     = null,
            bool pedantic                             = false,
            bool reuseCab                             = false,
            bool setOutputFileIfNotSpecified          = true,
            bool suppressACL                          = false,
            bool suppressAdmin                        = false,
            bool suppressADV                          = false,
            bool suppressAllWarnings                  = false,
            bool suppressAssemblies                   = false,
            bool suppressDroppingUnrealTables         = false,
            string[] suppressedICEs                   = null,
            bool suppressFiles                        = false,
            bool suppressFileInfo                     = false,
            bool suppressIntermediateFileVersionCheck = false,
            bool suppressLayout                       = false,
            bool suppressMSIAndMSMValidation          = false,
            bool suppressProcessingMSIAsmTable        = false,
            bool suppressSchemaValidation             = false,
            bool suppressUI                           = false,
            string[] suppressWarnings                 = null,
            bool tagSectionId                         = false,
            bool tagSectionIdAndGenerateWhenNull      = false,
            bool treatAllWarningsAsErrors             = false,
            int[] treatWarningsAsErrors               = null,
            string unreferencedSymbolsFile            = null,
            bool verbose                              = false,
            StringDictionary wixVariables             = null,
            bool xmlOutput                            = false)
        {
            Light light = new Light();

            if (null == objectFiles || objectFiles.Length == 0)
            {
                throw new ArgumentException("objectFiles cannot be null or empty");
            }

            // set the passed arrguments
            light.ObjectFiles.AddRange(objectFiles);
            light.AllowIdenticalRows       = allowIdenticalRows;
            light.AllowUnresolvedVariables = allowUnresolvedVariables;
            light.BindPath       = bindPath;
            light.BindFiles      = bindFiles;
            light.CabbingThreads = cabbingThreads;
            light.CachedCabsPath = cachedCabsPath;
            light.Cultures       = cultures;
            if (null != expectedWixMessages)
            {
                light.ExpectedWixMessages.AddRange(expectedWixMessages);
            }
            if (null != extensions)
            {
                light.Extensions.AddRange(extensions);
            }
            light.FileVersion = fileVersion;
            if (null != ices)
            {
                light.ICEs.AddRange(ices);
            }
            if (null != locFiles)
            {
                light.LocFiles.AddRange(locFiles);
            }
            light.NoTidy         = noTidy;
            light.OtherArguments = otherArguments;
            light.Pedantic       = pedantic;
            light.ReuseCab       = reuseCab;
            light.SetOutputFileIfNotSpecified = setOutputFileIfNotSpecified;
            light.SuppressACL                  = suppressACL;
            light.SuppressAdmin                = suppressAdmin;
            light.SuppressADV                  = suppressADV;
            light.SuppressAllWarnings          = suppressAllWarnings;
            light.SuppressAssemblies           = suppressAssemblies;
            light.SuppressDroppingUnrealTables = suppressDroppingUnrealTables;
            if (null != suppressedICEs)
            {
                light.SuppressedICEs.AddRange(suppressedICEs);
            }
            light.SuppressFiles    = suppressFiles;
            light.SuppressFileInfo = suppressFileInfo;
            light.SuppressIntermediateFileVersionCheck = suppressIntermediateFileVersionCheck;
            light.SuppressLayout = suppressLayout;
            light.SuppressMSIAndMSMValidation   = suppressMSIAndMSMValidation;
            light.SuppressProcessingMSIAsmTable = suppressProcessingMSIAsmTable;
            light.SuppressSchemaValidation      = suppressSchemaValidation;
            light.SuppressUI = suppressUI;
            if (null != suppressWarnings)
            {
                light.SuppressWarnings.AddRange(suppressWarnings);
            }
            light.TagSectionId = tagSectionId;
            light.TagSectionIdAndGenerateWhenNull = tagSectionIdAndGenerateWhenNull;
            light.TreatAllWarningsAsErrors        = treatAllWarningsAsErrors;
            if (null != treatWarningsAsErrors)
            {
                light.TreatWarningsAsErrors.AddRange(treatWarningsAsErrors);
            }
            light.UnreferencedSymbolsFile = unreferencedSymbolsFile;
            light.Verbose = verbose;
            if (null != wixVariables)
            {
                foreach (string key in wixVariables.Keys)
                {
                    if (!light.WixVariables.ContainsKey(key))
                    {
                        light.WixVariables.Add(key, wixVariables[key]);
                    }
                    else
                    {
                        light.WixVariables[key] = wixVariables[key];
                    }
                }
            }
            light.XmlOutput = xmlOutput;

            light.Run();

            return(light.OutputFile);
        }