Beispiel #1
0
        /// <summary>
        /// Build a patch from two admin images
        /// </summary>
        /// <param name="workingDirectory">WiX working directory</param>
        /// <param name="targetMsi">Target admin image</param>
        /// <param name="upgradeMsi">Upgrade admin image</param>
        /// <param name="patchSource">Patch source file</param>
        /// <param name="patchFileName">Name of output file</param>
        /// <param name="baseline">Id of the baseline layout</param>
        public static void BuildPatchFromAdminImages(string workingDirectory, string targetMsi, string upgradeMsi, string patchSource, string patchFileName, string baseline)
        {
            string outputDirectory = Environment.CurrentDirectory;

            // Create directories for intermediate output
            FileUtilities.CreateOutputDirectory(Path.Combine(outputDirectory, Settings.WixobjFolder));
            FileUtilities.CreateOutputDirectory(Path.Combine(outputDirectory, Settings.WixoutFolder));
            FileUtilities.CreateOutputDirectory(Path.Combine(outputDirectory, Settings.MstFolder));
            FileUtilities.CreateOutputDirectory(Path.Combine(outputDirectory, Settings.MspFolder));

            // Build Transforms
            // string transformWixMST = Path.Combine(Settings.WixoutFolder, "transform.wixmst");
            string transformWixMST = "transform.wixmst";

            Builder.BuildTransform(workingDirectory, targetMsi, upgradeMsi, false, transformWixMST, true, "-a");

            // string transformMST = Path.Combine(Settings.MSTFolder, "transform.mst");
            string transformMST = "transform.mst";

            Builder.BuildTransform(workingDirectory, targetMsi, upgradeMsi, false, transformMST, false, "-a");

            // Build Patch
            string patchWixMSP = Path.Combine(Settings.WixoutFolder, "patch.wixmsp");

            Builder.BuildPackage(workingDirectory, patchSource, patchWixMSP, null, "-xo");

            Pyro pyro = new Pyro();

            pyro.WorkingDirectory = workingDirectory;
            pyro.InputFile        = patchWixMSP;
            pyro.OutputFile       = patchFileName;
            pyro.Baselines.Add(transformWixMST, baseline);
            pyro.ExpectedWixMessages.Add(new WixMessage(1079, WixMessage.MessageTypeEnum.Warning));
            pyro.Run();
        }
Beispiel #2
0
        /// <summary>
        /// Build a patch
        /// </summary>
        /// <param name="workingDirectory">WiX working directory</param>
        /// <param name="targetSources">Target source files</param>
        /// <param name="upgradeSources">Upgrade source files</param>
        /// <param name="patchSources">Patch source file</param>
        /// <param name="patchFileName">Name of output file</param>
        /// <param name="baseline">The name of the baseline</param>
        /// <param name="patchCompilerExtension">A Wix extension to pass when compiling the patch</param>
        public static void BuildPatch(string workingDirectory, string[] targetSources, string[] upgradeSources, string[] patchSources, string patchFileName, string baseline, string patchCompilerExtension)
        {
            string outputDirectory = Environment.CurrentDirectory;

            // Create directories for intermediate output
            string wixobjDirectory = Path.Combine(outputDirectory, Settings.WixobjFolder);
            FileUtilities.CreateOutputDirectory(wixobjDirectory);
            string wixoutDirectory = Path.Combine(outputDirectory, Settings.WixoutFolder);
            FileUtilities.CreateOutputDirectory(wixoutDirectory);
            string msiDirectory = Path.Combine(outputDirectory, Settings.MsiFolder);
            FileUtilities.CreateOutputDirectory(msiDirectory);
            string mstDirectory = Path.Combine(outputDirectory, Settings.MstFolder);
            FileUtilities.CreateOutputDirectory(mstDirectory);
            string mspDirectory = Path.Combine(outputDirectory, Settings.MspFolder);
            FileUtilities.CreateOutputDirectory(mspDirectory);

            // Build Target .wixout
            string targetWixout = Path.Combine(wixoutDirectory, "target.wixout");
            string targetMSI = Path.Combine(msiDirectory, @"target\target.msi");
            Builder.BuildPackage(workingDirectory, targetSources, targetWixout, null, "-xo");
            Builder.BuildPackage(workingDirectory, targetSources, targetMSI, null, null);

            // Build Upgrade .wixout
            string upgradeWixout = Path.Combine(wixoutDirectory, "upgrade.wixout");
            string upgradeMSI = Path.Combine(msiDirectory, @"upgrade\upgrade.msi");
            Builder.BuildPackage(workingDirectory, upgradeSources, upgradeWixout, null, "-xo");
            Builder.BuildPackage(workingDirectory, upgradeSources, upgradeMSI, null, null);

            // Build Transform
            string transformWixMST = Path.Combine(wixoutDirectory, "transform.wixmst");
            Builder.BuildTransform(workingDirectory, targetWixout, upgradeWixout, true, transformWixMST, true);

            // Build a transform database from diffing the msis
            string transformMST = Path.Combine(mstDirectory, "transform.mst");
            Builder.BuildTransform(workingDirectory, targetMSI, upgradeMSI, false, transformMST, false);

            string patchWixMSP = Path.Combine(wixoutDirectory, "patch.wixmsp");
            if (!String.IsNullOrEmpty(patchCompilerExtension))
            {
                string extensionArgument = String.Format(@"-ext ""{0}""", patchCompilerExtension);
                Builder.BuildPackage(workingDirectory, patchSources, patchWixMSP, extensionArgument, "-xo");
            }
            else
            {
                Builder.BuildPackage(workingDirectory, patchSources, patchWixMSP, null, "-xo");
            }

            Pyro pyro = new Pyro();
            pyro.WorkingDirectory = workingDirectory;
            pyro.InputFile = patchWixMSP;
            pyro.OutputFile = patchFileName;
            pyro.Baselines.Add(transformWixMST, baseline);
            pyro.ExpectedWixMessages.Add(new WixMessage(1079, WixMessage.MessageTypeEnum.Warning));
            pyro.Run();
        }
Beispiel #3
0
        /// <summary>
        /// Build a patch from two admin images
        /// </summary>
        /// <param name="workingDirectory">WiX working directory</param>
        /// <param name="targetMsi">Target admin image</param>
        /// <param name="upgradeMsi">Upgrade admin image</param>
        /// <param name="patchSource">Patch source file</param>
        /// <param name="patchFileName">Name of output file</param>
        /// <param name="baseline">Id of the baseline layout</param>
        public static void BuildPatchFromAdminImages(string workingDirectory, string targetMsi, string upgradeMsi, string patchSource, string patchFileName, string baseline)
        {
            string outputDirectory = Environment.CurrentDirectory;

            // Create directories for intermediate output
            FileUtilities.CreateOutputDirectory(Path.Combine(outputDirectory, Settings.WixobjFolder));
            FileUtilities.CreateOutputDirectory(Path.Combine(outputDirectory, Settings.WixoutFolder));
            FileUtilities.CreateOutputDirectory(Path.Combine(outputDirectory, Settings.MstFolder));
            FileUtilities.CreateOutputDirectory(Path.Combine(outputDirectory, Settings.MspFolder));

            // Build Transforms
            // string transformWixMST = Path.Combine(Settings.WixoutFolder, "transform.wixmst");
            string transformWixMST = "transform.wixmst";
            Builder.BuildTransform(workingDirectory, targetMsi, upgradeMsi, false, transformWixMST, true, "-a");

            // string transformMST = Path.Combine(Settings.MSTFolder, "transform.mst");
            string transformMST = "transform.mst";
            Builder.BuildTransform(workingDirectory, targetMsi, upgradeMsi, false, transformMST, false, "-a");

            // Build Patch
            string patchWixMSP = Path.Combine(Settings.WixoutFolder, "patch.wixmsp");
            Builder.BuildPackage(workingDirectory, patchSource, patchWixMSP, null, "-xo");

            Pyro pyro = new Pyro();
            pyro.WorkingDirectory = workingDirectory;
            pyro.InputFile = patchWixMSP;
            pyro.OutputFile = patchFileName;
            pyro.Baselines.Add(transformWixMST, baseline);
            pyro.ExpectedWixMessages.Add(new WixMessage(1079, WixMessage.MessageTypeEnum.Warning));
            pyro.Run();
        }
Beispiel #4
0
        /// <summary>
        /// Build a patch
        /// </summary>
        /// <param name="workingDirectory">WiX working directory</param>
        /// <param name="targetSources">Target source files</param>
        /// <param name="upgradeSources">Upgrade source files</param>
        /// <param name="patchSources">Patch source file</param>
        /// <param name="patchFileName">Name of output file</param>
        /// <param name="baseline">The name of the baseline</param>
        /// <param name="patchCompilerExtension">A Wix extension to pass when compiling the patch</param>
        public static void BuildPatch(string workingDirectory, string[] targetSources, string[] upgradeSources, string[] patchSources, string patchFileName, string baseline, string patchCompilerExtension)
        {
            string outputDirectory = Environment.CurrentDirectory;

            // Create directories for intermediate output
            string wixobjDirectory = Path.Combine(outputDirectory, Settings.WixobjFolder);
            FileUtilities.CreateOutputDirectory(wixobjDirectory);
            string wixoutDirectory = Path.Combine(outputDirectory, Settings.WixoutFolder);
            FileUtilities.CreateOutputDirectory(wixoutDirectory);
            string msiDirectory = Path.Combine(outputDirectory, Settings.MsiFolder);
            FileUtilities.CreateOutputDirectory(msiDirectory);
            string mstDirectory = Path.Combine(outputDirectory, Settings.MstFolder);
            FileUtilities.CreateOutputDirectory(mstDirectory);
            string mspDirectory = Path.Combine(outputDirectory, Settings.MspFolder);
            FileUtilities.CreateOutputDirectory(mspDirectory);

            // Build Target .wixout
            string targetWixout = Path.Combine(wixoutDirectory, "target.wixout");
            string targetMSI = Path.Combine(msiDirectory, @"target\target.msi");
            Builder.BuildPackage(workingDirectory, targetSources, targetWixout, null, "-xo");
            Builder.BuildPackage(workingDirectory, targetSources, targetMSI, null, null);

            // Build Upgrade .wixout
            string upgradeWixout = Path.Combine(wixoutDirectory, "upgrade.wixout");
            string upgradeMSI = Path.Combine(msiDirectory, @"upgrade\upgrade.msi");
            Builder.BuildPackage(workingDirectory, upgradeSources, upgradeWixout, null, "-xo");
            Builder.BuildPackage(workingDirectory, upgradeSources, upgradeMSI, null, null);

            // Build Transform
            string transformWixMST = Path.Combine(wixoutDirectory, "transform.wixmst");
            Builder.BuildTransform(workingDirectory, targetWixout, upgradeWixout, true, transformWixMST, true);

            // Build a transform database from diffing the msis
            string transformMST = Path.Combine(mstDirectory, "transform.mst");
            Builder.BuildTransform(workingDirectory, targetMSI, upgradeMSI, false, transformMST, false);

            string patchWixMSP = Path.Combine(wixoutDirectory, "patch.wixmsp");
            if (!String.IsNullOrEmpty(patchCompilerExtension))
            {
                string extensionArgument = String.Format(@"-ext ""{0}""", patchCompilerExtension);
                Builder.BuildPackage(workingDirectory, patchSources, patchWixMSP, extensionArgument, "-xo");
            }
            else
            {
                Builder.BuildPackage(workingDirectory, patchSources, patchWixMSP, null, "-xo");
            }

            Pyro pyro = new Pyro();
            pyro.WorkingDirectory = workingDirectory;
            pyro.InputFile = patchWixMSP;
            pyro.OutputFile = patchFileName;
            pyro.Baselines.Add(transformWixMST, baseline);
            pyro.ExpectedWixMessages.Add(new WixMessage(1079, WixMessage.MessageTypeEnum.Warning));
            pyro.Run();
        }
        /// <summary>
        /// Builds a patch using given paths for the target and upgrade packages.
        /// </summary>
        /// <param name="targetPath">The path to the target MSI.</param>
        /// <param name="upgradePath">The path to the upgrade MSI.</param>
        /// <param name="name">The name of the patch to build.</param>
        /// <param name="version">Optional version for the bundle.</param>
        /// <returns>The path to the patch.</returns>
        private string BuildPatch(string targetPath, string upgradePath, string name, string version)
        {
            // Get the name of the calling method.
            StackTrace stack = new StackTrace();
            string caller = stack.GetFrame(1).GetMethod().Name;

            // Create paths.
            string source = Path.Combine(TestDataDirectory, String.Concat(name, ".wxs"));
            string rootDirectory = FileUtilities.GetUniqueFileName();
            string objDirectory = Path.Combine(rootDirectory, Settings.WixobjFolder);
            string msiDirectory = Path.Combine(rootDirectory, Settings.MSIFolder);
            string wixmst = Path.Combine(objDirectory, String.Concat(name, ".wixmst"));
            string wixmsp = Path.Combine(objDirectory, String.Concat(name, ".wixmsp"));
            string package = Path.Combine(msiDirectory, String.Concat(name, ".msp"));

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

            // Compile.
            Candle candle = new Candle();
            candle.Extensions.AddRange(DependencyExtensionTests.Extensions);
            candle.OtherArguments = String.Concat("-dTestName=", caller);
            if (!String.IsNullOrEmpty(version))
            {
                candle.OtherArguments = String.Concat(candle.OtherArguments, " -dVersion=", version);
            }
            candle.OutputFile = String.Concat(objDirectory, @"\");
            candle.SourceFiles.Add(source);
            candle.WorkingDirectory = 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(DependencyExtensionTests.Extensions);
            light.ObjectFiles = candle.ExpectedOutputFiles;
            light.OutputFile = wixmsp;
            light.SuppressMSIAndMSMValidation = true;
            light.WorkingDirectory = TestDataDirectory;
            light.Run();

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

            // Torch.
            Torch torch = new Torch();
            torch.TargetInput = Path.ChangeExtension(targetPath, "wixpdb");
            torch.UpdatedInput = Path.ChangeExtension(upgradePath, "wixpdb");
            torch.PreserveUnmodified = true;
            torch.XmlInput = true;
            torch.OutputFile = wixmst;
            torch.WorkingDirectory = TestDataDirectory;
            torch.Run();

            // Pyro.
            Pyro pyro = new Pyro();
            pyro.Baselines.Add(torch.OutputFile, name);
            pyro.InputFile = light.OutputFile;
            pyro.OutputFile = package;
            pyro.WorkingDirectory = TestDataDirectory;
            pyro.SuppressWarnings.Add("1079");
            pyro.Run();

            return pyro.OutputFile;
        }
Beispiel #6
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);
        }