public IOfficeInstallReturn Generate(IOfficeInstallProperties installProperties, string remoteLogPath = "") { var msiPath = installProperties.ExecutablePath; var exePath = Path.GetDirectoryName(installProperties.ExecutablePath) + @"\InstallOfficeProPlus.exe"; try { var tmpDir = Environment.ExpandEnvironmentVariables(@"%temp%"); var wixDirectory = tmpDir + @"\wixTools"; var wixZip = ZipExtractor.AssemblyDirectory + @"\wixTools.zip"; if (!File.Exists(wixZip)) { var projectPath = Directory.GetCurrentDirectory() + @"\Project\wixTools.zip"; if (File.Exists(projectPath)) { wixZip = projectPath; } } if (!Directory.Exists(wixDirectory)) { ZipExtractor.Extract(wixZip, tmpDir); } var exeGenerator = new OfficeInstallExecutableGenerator(); installProperties.ExecutablePath = exePath; string version = null; if (installProperties.Version != null) { version = installProperties.Version.ToString(); } var exeReturn = exeGenerator.Generate(installProperties, remoteLogPath); var exeFilePath = exeReturn.GeneratedFilePath; var msiCreatePath = Regex.Replace(msiPath, ".msi$", "", RegexOptions.IgnoreCase); var msiInstallProperties = new MsiGeneratorProperties() { MsiPath = msiCreatePath, ExecutablePath = exePath, Manufacturer = "Microsoft Corporation", Name = installProperties.ProductName, ProgramFilesPath = installProperties.ProgramFilesPath, ProgramFiles = new List<string>() { installProperties.ConfigurationXmlPath }, ProductId = new Guid(installProperties.ProductId), WixToolsPath = wixDirectory, Version = installProperties.Version, UpgradeCode = new Guid(installProperties.UpgradeCode), Language = installProperties.Language, SourceFilePath = installProperties.SourceFilePath }; var msiGenerator = new MsiGenerator(); msiGenerator.Generate(msiInstallProperties); var installDirectory = new OfficeInstallReturn { GeneratedFilePath = msiPath }; return installDirectory; } finally { try { if (File.Exists(exePath)) { File.Delete(exePath); } } catch { } } }
public MsiGeneratorReturn Generate(MsiGeneratorProperties installProperties) { var project = new ManagedProject(installProperties.Name) { UI = WUI.WixUI_ProgressOnly, Actions = new WixSharp.Action[] { new SetPropertyAction("InstallDirectory", installProperties.ProgramFilesPath), new ElevatedManagedAction(CustomActions.InstallOffice, Return.check, When.After, Step.InstallFiles, Condition.NOT_Installed), new ElevatedManagedAction(CustomActions.UninstallOffice, Return.check, When.Before, Step.RemoveFiles, Condition.BeingRemoved), }, Properties = new[] { new Property("InstallDirectory", "empty"), new Property() { Name = "ProductGuid", Value = installProperties.ProductId.ToString() } } }; project.Media.AttributesDefinition += ";CompressionLevel=high"; var files = new List <WixSharp.File>(); foreach (var filePath in installProperties.ProgramFiles) { files.Add(new WixSharp.File(filePath)); } files.Add(new WixSharp.File(installProperties.ExecutablePath)); var rootDir = new Dir(installProperties.ProgramFilesPath, files.ToArray()); project.Dirs = new[] { rootDir }; project.GUID = installProperties.ProductId; project.ControlPanelInfo = new ProductInfo() { Manufacturer = installProperties.Manufacturer, Comments = installProperties.ProductId.ToString() }; project.OutFileName = installProperties.MsiPath; project.UpgradeCode = installProperties.UpgradeCode; project.Version = installProperties.Version; project.MajorUpgrade = new MajorUpgrade() { DowngradeErrorMessage = "A later version of [ProductName] is already installed. Setup will now exit.", AllowDowngrades = false, AllowSameVersionUpgrades = false }; //project.Platform = Platform.x64; //project.MajorUpgradeStrategy.RemoveExistingProductAfter = null; project.Load += project_Load; project.AfterInstall += project_AfterInstall; //project.InstallScope = InstallScope.perMachine; if (!string.IsNullOrEmpty(installProperties.Language)) { project.Language = installProperties.Language; } if (!string.IsNullOrEmpty(installProperties.WixToolsPath)) { Compiler.WixLocation = installProperties.WixToolsPath + @"\"; Compiler.WixSdkLocation = installProperties.WixToolsPath + @"\sdk\"; } else { Compiler.WixLocation = @"wixTools\"; Compiler.WixSdkLocation = @"wixTools\sdk\"; } var returnValue = Compiler.BuildMsi(project); var installDirectory = new MsiGeneratorReturn { GeneratedFilePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) }; return(installDirectory); }
public IOfficeInstallReturn Generate(IOfficeInstallProperties installProperties, string remoteLogPath = "") { var msiPath = installProperties.ExecutablePath; var exePath = Path.GetDirectoryName(installProperties.ExecutablePath) + @"\InstallOfficeProPlus.exe"; try { var tmpDir = Environment.ExpandEnvironmentVariables(@"%temp%"); var wixDirectory = tmpDir + @"\wixTools"; var wixZip = ZipExtractor.AssemblyDirectory + @"\wixTools.zip"; if (!File.Exists(wixZip)) { var projectPath = Directory.GetCurrentDirectory() + @"\Project\wixTools.zip"; if (File.Exists(projectPath)) { wixZip = projectPath; } } if (!Directory.Exists(wixDirectory)) { ZipExtractor.Extract(wixZip, tmpDir); } var exeGenerator = new OfficeInstallExecutableGenerator(); installProperties.ExecutablePath = exePath; string version = null; if (installProperties.Version != null) { version = installProperties.Version.ToString(); } var exeReturn = exeGenerator.Generate(installProperties, remoteLogPath); var exeFilePath = exeReturn.GeneratedFilePath; var msiCreatePath = Regex.Replace(msiPath, ".msi$", "", RegexOptions.IgnoreCase); var msiInstallProperties = new MsiGeneratorProperties() { MsiPath = msiCreatePath, ExecutablePath = exePath, Manufacturer = "Microsoft Corporation", Name = installProperties.ProductName, ProgramFilesPath = installProperties.ProgramFilesPath, ProgramFiles = new List <string>() { installProperties.ConfigurationXmlPath }, ProductId = new Guid(installProperties.ProductId), WixToolsPath = wixDirectory, Version = installProperties.Version, UpgradeCode = new Guid(installProperties.UpgradeCode), Language = installProperties.Language, SourceFilePath = installProperties.SourceFilePath }; var msiGenerator = new MsiGenerator(); msiGenerator.Generate(msiInstallProperties); var installDirectory = new OfficeInstallReturn { GeneratedFilePath = msiPath }; return(installDirectory); } finally { try { if (File.Exists(exePath)) { File.Delete(exePath); } } catch { } } }