예제 #1
0
파일: PatchBuilder.cs 프로젝트: fyisa/wix3
        /// <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.test.TestDataDirectory2, 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.test.TestArtifacts.Add(new DirectoryInfo(rootDirectory));

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

            candle.Extensions.AddRange(this.Extensions);
            candle.OtherArguments = String.Concat("-dTestName=", this.test.TestContext.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.test.TestDataDirectory2;
            candle.Run();

            // Make sure the output directory is cleaned up.
            this.test.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.test.TestDataDirectory2;
            light.Run();

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

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

            Assert.IsNotNull(this.TargetPaths);
            Assert.IsNotNull(this.UpgradePaths);
            Assert.AreEqual <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.test.TestDataDirectory2;
                torch.Run();

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

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

            this.Output = pyro.OutputFile;
            return(this);
        }
        /// <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(this.TestContext.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 = this.TestContext.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 = this.TestContext.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 = this.TestContext.TestDataDirectory;
            torch.Run();

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

            return pyro.OutputFile;
        }
        /// <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);
        }