Example #1
0
 public void NoErrorOnSpecifyingMinSizeInFileSearch()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(RegressionTests.TestDataDirectory,@"NoErrorOnSpecifyingMinSizeInFileSearch\FileSearch.wxs"));
     candle.ExpectedExitCode = 0;
     candle.Run();
 }
Example #2
0
 public void SuppressAllWarningsSwitch()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(testFile);
     candle.SuppressAllWarnings = true;
     candle.Run();
 }
Example #3
0
 public void ShortcutDirectoryNotSet()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(RegressionTests.TestDataDirectory, @"ShortcutDirectoryNotSet\ShortcutProduct.wxs"));
     candle.ExpectedExitCode = 0;
     candle.Run();
 }
Example #4
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);
        }
        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();
            }
        }
Example #6
0
 public void NoPedanticSwitch()
 {
     Candle candle = new Candle();
     candle.Pedantic = false;
     candle.SourceFiles.Add(PedanticTests.TestFile);
     candle.Run();
 }
Example #7
0
 public void FileNameWithSpace()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(Tests.WixTests.SharedAuthoringDirectory, "BasicProduct.wxs"));
     candle.OutputFile = Path.Combine(Utilities.FileUtilities.GetUniqueFileName(), "Pro  duct.wixobj");
     candle.Run();
 }
Example #8
0
        public void LongFilePath()
        {
            //the max length of a path is 247 chars, the filepath is 259 chars

            string OutputPath = Utilities.FileUtilities.GetUniqueFileName();
            //add initial 170 chars
            OutputPath = Path.Combine(OutputPath, @"FilePathNewfolder11(20chars)\Newfolder12(20chars)Newfolder12(20chars)Newfolder13(20chars)Newfolder13(20chars)\Newfolder14(20chars)Newfolder15(20chars)Newfolder16(20chars)");

            int i = 245 - OutputPath.Length;
            while (i > 0)
            {
                OutputPath = Path.Combine(OutputPath, @"pt");
                i = 245 - OutputPath.Length;
            }
            if (OutputPath.Length < 246)
            {
                OutputPath = Path.Combine(OutputPath, "T");
            }

            Assert.IsTrue(OutputPath.Length  <248, "The output path is not less than 248 chars");
            Directory.CreateDirectory(OutputPath);

            Candle candle = new Candle();
            candle.SourceFiles.Add(Path.Combine(Tests.WixTests.SharedAuthoringDirectory, "BasicProduct.wxs"));
            candle.OutputFile = Path.Combine(OutputPath, "Prod.wixobj");

            Assert.IsTrue((candle.OutputFile.Length > 256) && (candle.OutputFile.Length < 260), "The output filepath{0} is not between 256 and 260 chars",candle .OutputFile .Length );

            candle.Run();
        }
Example #9
0
 public void MultipleWxsFiles()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(WixTests.SharedAuthoringDirectory, "BasicProduct.wxs"));
     candle.SourceFiles.Add(Path.Combine(Path.Combine(InputTests.TestDataDirectory, @"MultipleWxsFiles\product.wxs")));
     candle.SourceFiles.Add(Path.Combine(Path.Combine(InputTests.TestDataDirectory, @"MultipleWxsFiles\feature.wxs")));
     candle.Run();
 }
Example #10
0
 public void InvalidWxsFile()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(InputTests.TestDataDirectory, @"InvalidWxsFile\Product.wxs"));
     candle.ExpectedWixMessages.Add(new WixMessage(104, "Not a valid source file; detail: Data at the root level is invalid. Line 1, position 1.", WixMessage.MessageTypeEnum.Error));
     candle.ExpectedExitCode = 104;
     candle.Run();
 }
Example #11
0
 public void EmptyWxsFile()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(InputTests.TestDataDirectory, @"EmptyWxsFile\Product.wxs"));
     candle.ExpectedWixMessages.Add(new WixMessage(104, "Not a valid source file; detail: Root element is missing.", WixMessage.MessageTypeEnum.Error));
     candle.ExpectedExitCode = 104;
     candle.Run();
 }
Example #12
0
        /// <summary>
        /// Constructor that uses data from a Candle object to create a Light object
        /// </summary>
        /// <param name="candle">A Candle object</param>
        /// <param name="xmlOutput">False if Light should build an MSI. True if Light should build a wixout.</param>
        public Light(Candle candle, bool xmlOutput)
            : this()
        {
            this.XmlOutput = xmlOutput;

            // The output of Candle is the input for Light
            this.ObjectFiles = candle.ExpectedOutputFiles;
        }
 public void DirectoryAttributeWithPropertyAttribute()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(RemoveFolderTests.TestDataDirectory, @"DirectoryAttributeWithPropertyAttribute\product.wxs"));
     candle.ExpectedWixMessages.Add(new WixMessage(35, "The RemoveFolder/@Property attribute cannot be specified when attribute Directory is present with value 'WixTestFolder'.", WixMessage.MessageTypeEnum.Error));
     candle .ExpectedExitCode = 35;
     candle.Run();
 }
Example #14
0
 public void SuppressSpecificWarnings()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(testFile);
     candle.SuppressWarnings.Add(1075);
     candle.ExpectedWixMessages.Add(new WixMessage(1096, WixMessage.MessageTypeEnum.Warning));
     candle.Run();
 }
Example #15
0
 public void OutSwitch()
 {
     string outputDirectory = Utilities.FileUtilities.GetUniqueFileName();
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(Tests.WixTests.SharedAuthoringDirectory, "BasicProduct.wxs"));
     candle.OutputFile = Path.Combine(outputDirectory, "BasicProduct.wixobj"); ;
     candle.Run();
 }
Example #16
0
 public void VerifyDeprecatedSwitch()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(testFile);
     candle.OtherArguments = "-swall";
     candle.ExpectedWixMessages.Add(new WixMessage(1108, "The command line switch 'swall' is deprecated. Please use 'sw' instead.", WixMessage.MessageTypeEnum.Warning));
     candle.Run();
 }
Example #17
0
 public void NoSuppressWarningsSwitch()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(testFile);
     candle.ExpectedWixMessages.Add(new WixMessage(1096, WixMessage.MessageTypeEnum.Warning));
     candle.ExpectedWixMessages.Add(new WixMessage(1075, WixMessage.MessageTypeEnum.Warning));
     candle.Run();
 }
 public void AuthoringVariableRedefinition()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(VariableTests.TestDataDirectory, @"AuthoringVariableRedefinition\Product.wxs"));
     candle.ExpectedWixMessages.Add(new WixMessage(1118, "The variable 'Var' with value 'value2' was previously declared with value 'value1'.", WixMessage.MessageTypeEnum.Warning));
     candle.ExpectedExitCode = 0;
     candle.Run();
 }
 public void Warning()
 {
     string testFile = Environment.ExpandEnvironmentVariables(Path.Combine(ErrorsAndWarningsTests.TestDataDirectory, @"Warning\Product.wxs"));
     Candle candle = new Candle();
     candle.SourceFiles.Add(testFile);
     candle.ExpectedWixMessages.Add(new WixMessage(1096, "Preprocessor warning", WixMessage.MessageTypeEnum.Warning));
     candle.Run();
 }
Example #20
0
 public void EmbedCabAttrWithoutCabinetAttr()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(RegressionTests.TestDataDirectory,@"EmbedCabAttrWithoutCabinetAttr\EmbedCabProduct.wxs"));
     candle.ExpectedExitCode = 10;
     candle.ExpectedWixMessages.Add(new WixMessage(10, "The Media/@Cabinet attribute was not found; it is required when attribute EmbedCab has a value of 'yes'.", WixMessage.MessageTypeEnum.Error));
     candle.Run();
 }
Example #21
0
 public void NoTraceSwitch()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(testFile);
     candle.Trace = false;
     candle.ExpectedWixMessages.Add(new WixMessage(1075, "The Product/@UpgradeCode attribute was not found; it is strongly recommended to ensure that this product can be upgraded.", WixMessage.MessageTypeEnum.Warning));
     candle.Run();
 }
Example #22
0
 public void ProductVersionAttributeNotPopulated()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(RegressionTests.TestDataDirectory,@"ProductVersionAttributeNotPopulated\ProductVersionAttributeMissing.wxs"));
     candle.ExpectedWixMessages.Add(new WixMessage(10, "The Product/@Version attribute was not found; it is required.", WixMessage.MessageTypeEnum.Error));
     candle.ExpectedExitCode = 10;
     candle.Run();
 }
 public void Error()
 {
     string testFile = Environment.ExpandEnvironmentVariables(Path.Combine(ErrorsAndWarningsTests.TestDataDirectory, @"Error\Product.wxs"));
     Candle candle = new Candle();
     candle.SourceFiles.Add(testFile);
     candle.ExpectedWixMessages.Add(new WixMessage(250, "Preprocessor error", WixMessage.MessageTypeEnum.Error));
     candle.ExpectedExitCode = 250;
     candle.Run();
 }
        public void SuppressSchemaValidation()
        {
            Candle candle = new Candle();
            candle.SourceFiles.Add(testFile);

            // The authoring does not contain a package element which is normally a schema validation error
            candle.SuppressSchemaValidation = true;
            candle.Run();
        }
 public void DoNotSuppressSchemaValidation()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(testFile);
     candle.SuppressSchemaValidation = false;
     candle.ExpectedWixMessages.Add(new WixMessage(107, "Schema validation failed with the following error at line 1, column 542: The element 'Product' in namespace 'http://schemas.microsoft.com/wix/2006/wi' has invalid child element 'Media' in namespace 'http://schemas.microsoft.com/wix/2006/wi'. List of possible elements expected: 'Package'.", WixMessage.MessageTypeEnum.Error));
     candle.ExpectedExitCode = 107;
     candle.Run();
 }
 public void SqlScript_DeprecatedBinaryElement()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(SqlScriptTests.TestDataDirectory, @"DeprecatedBinaryElement.wxs"));
     candle.Extensions.Add("WixSqlExtension");
     candle.ExpectedWixMessages.Add(new WixMessage(5103, @"The sql:SqlScript element contains a deprecated child Binary element.  Please move the Binary element under a Fragment, Module, or Product element and set the sql:SqlScript/@BinaryKey attribute to the value of the Binary/@Id attribute.", WixMessage.MessageTypeEnum.Error));
     candle.ExpectedExitCode = 5103;
     candle.Run();
 }
 public void CommandlineVariableRedefinition()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(WixTests.BasicProductWxs);
     candle.OtherArguments = " -dVar=value1 -dVar=value2";
     candle.ExpectedWixMessages.Add(new WixMessage(288, "The variable 'Var' with value 'value2' was previously declared with value 'value1'.", WixMessage.MessageTypeEnum.Error));
     candle.ExpectedExitCode = 288;
     candle.Run();
 }
 public void WxAndSw()
 {
     string testFile = Environment.ExpandEnvironmentVariables(@"%WIX_ROOT%\test\data\Tools\Candle\MultipleInputSwitchesTests\WxAndSw\Product.wxs");
     Candle candle = new Candle();
     candle.TreatAllWarningsAsErrors = true;
     candle.SuppressAllWarnings = true;
     candle.SourceFiles.Add(testFile);
     candle.Run();
 }
 public void PermissionEx_GroupRefMissingParentComponent()
 {
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(PermissionExTests.TestDataDirectory, @"GroupRefMissingParentComponent.wxs"));
     candle.Extensions.Add("WixUtilExtension");
     candle.ExpectedWixMessages.Add(new WixMessage(5051, @"The util:GroupRef element cannot be specified unless the element has a Component as an ancestor. A util:GroupRef that does not have a Component ancestor is not installed.", WixMessage.MessageTypeEnum.Error));
     candle.ExpectedExitCode = 5051;
     candle.Run();
 }
 public void MissingRequiredAttributes()
 {
     // Run Candle
     Candle candle = new Candle();
     candle.SourceFiles.Add(Path.Combine(CustomActionTests.TestDataDirectory, @"MissingRequiredAttributes\product.wxs"));
     candle.ExpectedWixMessages.Add(new WixMessage(37, "The CustomAction/@ExeCommand attribute cannot be specified without attribute BinaryKey, Directory, FileKey, or Property present.", WixMessage.MessageTypeEnum.Error));
     candle.ExpectedExitCode = 37;
     candle.Run();
 }
Example #31
0
 /// <summary>
 /// Constructor that uses data from a Candle object to create a Light object
 /// </summary>
 /// <param name="candle">A Candle object</param>
 public Light(Candle candle)
     : this(candle, false)
 {
 }
Example #32
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);
        }
        public static string[] Compile(
            string[] sourceFiles,
            bool fips = false,
            WixMessage[] expectedWixMessages = null,
            string[] extensions         = null,
            string[] includeSearchPaths = null,
            bool onlyValidateDocuments  = false,
            string otherArguments       = null,
            bool pedantic         = false,
            string preProcessFile = null,
            Dictionary <string, string> preProcessorParams = null,
            bool setOutputFileIfNotSpecified = true,
            bool suppressAllWarnings         = false,
            bool suppressMarkingVitalDefault = false,
            bool suppressSchemaValidation    = false,
            int[] suppressWarnings           = null,
            bool trace = false,
            int[] treatWarningsAsErrors   = null,
            bool treatAllWarningsAsErrors = false,
            bool verbose = false)
        {
            Candle candle = new Candle();

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

            // set the passed arrguments
            candle.SourceFiles.AddRange(sourceFiles);
            if (null != expectedWixMessages)
            {
                candle.ExpectedWixMessages.AddRange(expectedWixMessages);
            }
            if (null != extensions)
            {
                candle.Extensions.AddRange(extensions);
            }
            candle.FIPS = fips;
            if (null != includeSearchPaths)
            {
                candle.IncludeSearchPaths.AddRange(includeSearchPaths);
            }
            candle.OnlyValidateDocuments = onlyValidateDocuments;
            candle.OtherArguments        = otherArguments;
            candle.Pedantic       = pedantic;
            candle.PreProcessFile = preProcessFile;
            if (null != preProcessorParams)
            {
                candle.PreProcessorParams = preProcessorParams;
            }
            candle.SetOutputFileIfNotSpecified = setOutputFileIfNotSpecified;
            candle.SuppressAllWarnings         = suppressAllWarnings;
            candle.SuppressMarkingVitalDefault = suppressMarkingVitalDefault;
            candle.SuppressSchemaValidation    = suppressSchemaValidation;
            if (null != suppressWarnings)
            {
                candle.SuppressWarnings.AddRange(suppressWarnings);
            }
            candle.Trace = trace;
            if (null != treatWarningsAsErrors)
            {
                candle.TreatWarningsAsErrors.AddRange(treatWarningsAsErrors);
            }
            candle.TreatAllWarningsAsErrors = treatAllWarningsAsErrors;
            candle.Verbose = verbose;

            candle.Run();

            return(candle.ExpectedOutputFiles.ToArray());
        }
Example #34
0
 /// <summary>
 /// Constructor that uses data from a Candle object to create a Lit object
 /// </summary>
 /// <param name="candle">A Candle object</param>
 public Lit(Candle candle)
     : this()
 {
     // The output of Candle is the input for Lit
     this.ObjectFiles = candle.ExpectedOutputFiles;
 }