예제 #1
0
        public static ProductStandard Create(Product product)
        {
            ProductStandard newProduct = null;

            if (product != null)
            {
                newProduct = new ProductStandard(product);
            }

            return(newProduct);
        }
예제 #2
0
        private void UpdateDeployManifest(ProductStandard product, Instance instance, bool onlyUpdate, string certificatePassword)
        {
            // Deploy Manifestfile
            string deployManifestFile = Path.Combine(product.InstallPath, instance.DeployManifestFile);

            // Check if only update of existing file is necessary
            if (!onlyUpdate)
            {
                // Temp filename to use
                string tempTemplateFile = Path.Combine(Path.GetTempPath(), Constants.DeployManifestTemplateTemporaryName);

                // Get the template file from the assembly and overwrite the template in temp directory
                if (!FileHandler.GetFileFromAssembly(tempTemplateFile, Assembly.Load("Imi.SupplyChain.Deployment"), Constants.DeployManifestTemplateResource))
                {
                    throw new Exception("Could not copy the deployment manifest to the temporary directory.");
                }

                // Move and rename the template to the correct place.
                try
                {
                    File.Move(tempTemplateFile, deployManifestFile);
                }
                catch
                {
                    throw new Exception("Could not move the deployment manifest.");
                }
            }

            string providerURL = "http://" + _config.GetWebserverName() + "/" + product.VirtualDirectoryName + "/" + instance.Name + ".application";

            // Build the arguments for updating the deploy template with mage.exe
            string argument = string.Format("-Update \"{0}\" " +
                                            "-AppManifest \"{1}\" " +
                                            "-Name \"{2}\" " +
                                            "-Version {3} " +
                                            "-p x86 " +
                                            "-CertFile \"{4}\"{5} " +
                                            "-ProviderUrl \"{6}\" ",
                                            deployManifestFile,
                                            instance.ApplicationManifestFile,
                                            product.ProductName,
                                            instance.ProductVersion,
                                            _certificateFile,
                                            !string.IsNullOrEmpty(certificatePassword) ? string.Format(" -Password {0}", certificatePassword) : string.Empty,
                                            providerURL);


            Regex regEx = new Regex(Constants.DeployManifestSuccessfulPattern);

            string result = RunConsoleApp.Run(Path.Combine(_executablePath, Constants.MageExeFilename), argument);

            // Check if result was successful
            if (!regEx.Match(result).Success)
            {
                if (!onlyUpdate)
                {
                    // Remove the unsigned manifest file.
                    // Only if we're not updating an existing working manifest
                    File.Delete(deployManifestFile);
                }

                if (result.Contains("The specified network password is not correct."))
                {
                    throw new Exception("Invalid password.");
                }
                else
                {
                    throw new Exception(string.Format("Error when running mage.exe.\n\nArgument:\n\t{0}\n\nResult:\n\t{1}", argument, result));
                }
            }
        }