1
我有一個自定義操作應該在.msi安裝的安裝部分執行。我有一個使用InstallShield安裝的以前的版本(這是過度的),並且想要轉移到更簡單的VS安裝程序Proj,因爲我不需要.isproj提供的所有控件。但是,使用新的.msi進行直接安裝似乎與以前的版本並行安裝。這是我迄今發現:在使用VS 2005安裝新組件之前卸載以前的組件安裝項目
- 我有我的產品ID
- 我寫的代碼,將通過創建使用msiexec.exe的進程卸載以前的版本(代碼將遵循)
- 嘗試實施自定義操作在安裝過程中卸載,但似乎你一次只能運行一個MsiExec.exe實例。
- 已經到這篇文章(http://stackoverflow.com/questions/197365/vs-setup-project-uninstall-other-component-on-install),這沒有幫助。
自定義操作代碼:
//Exe used to uninstall
string fileName = "MsiExec.exe";
//Product ID of versions installed using InstallShield
string productID = "{DC625BCF-5E7B-4FEF-96DD-3CDBA7FC02C1}";
//Use /x for uninstall and use /qn to supress interface
ProcessStartInfo startInfo = new ProcessStartInfo(fileName, string.Format("/x{0}", productID));
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.UseShellExecute = false;
//Start process
Process uninstallProcess = Process.Start(startInfo);
//Wait until uninstall is complete
uninstallProcess.WaitForExit();
我的希望是通過ClickOnce的最終部署我的.msi,所以我希望這將適用於部署選項一個選項。目前所有內容都是用.NET 2.0和VS 2005編寫的,但如果有新的選項可用,我可以使用.NET 4.0和VS 2010。
任何幫助表示讚賞。