2015-04-25 120 views
7

我有一個非常簡單的安裝程序 - 將一個dll複製到Program Files子文件夾並使用regsvr32.exe進行註冊。效果很好,但如果安裝了舊版本的dll,「修復」不會覆蓋現有的dll。該DLL已簽名,其版本號(版本號)始終遞增(例如2.0.0.123 - > 2.0.0.124)。Wix安裝程序不會覆蓋以前版本的可執行文件

看看以前的類似帖子,我添加了RemoveExistingProducts並指定ProductId爲「*」。卸載並安裝較新的版本可以正常工作,但我真的需要修復來更新現有的dll。

還有什麼我需要做的嗎?

謝謝!

<?xml version="1.0" encoding="UTF-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> 

    <!-- 
When creating a new install for the next version, these fields must be modified 
--> 
    <?define ProductVersion = "2.0.00" ?> 

    <?define ProductId64 = "*" ?> 
    <?define ProductId32 = "*" ?> 

    <?define PackageId = "45F34788-66AC-441C-B666-707FFA7F1EE9" ?> 


    <!-- Product name as you want it to appear in Add/Remove Programs--> 
    <?if $(var.Platform) = x64 ?> 
    <?define ProductName = "XYZ (64 bit)" ?> 
    <?define Win64 = "yes" ?> 
    <?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?> 
    <?define ProductId = "$(var.ProductId64)" ?> 
    <?define MainDllName = "XYZ64.dll" ?> 
    <?define MainDllSource = "..\..\bin\Win64\Release\XYZ64.dll" ?> 
    <?else ?> 
    <?define ProductName = "XYZ (32 bit)" ?> 
    <?define Win64 = "no" ?> 
    <?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?> 
    <?define ProductId = "$(var.ProductId32)" ?> 
    <?define MainDllName = "XYZ.dll" ?> 
    <?define MainDllSource = "..\..\bin\Win32\Release\XYZ.dll" ?> 
    <?endif ?> 


    <?define UpgradeCode = "{C3763742-7C1C-4AB7-A404-F030B7550E97}" ?> 


    <Product Id="$(var.ProductId)" Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="Advanced Messaging Systems LLC" UpgradeCode="$(var.UpgradeCode)"> 

    <Package Id="$(var.PackageId)" InstallerVersion="200" Compressed="yes" Description="XYZ Installer package" InstallPrivileges="elevated"/> 

    <!-- No restore point --> 
    <Property Id="MSIFASTINSTALL" Value="3" /> 

    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" /> 

    <Directory Id="TARGETDIR" Name="SourceDir"> 
     <Directory Id="$(var.PlatformProgramFilesFolder)"> 
     <Directory Id="INSTALLLOCATION" Name="XYZ"> 

      <Component Id="XYZDll" Guid="E2CBEE41-6C0E-4A84-95C1-7282747B4A3D"> 
      <File Id='MainDll' Name="$(var.MainDllName)" DiskId='1' Source="$(var.MainDllSource)" SelfRegCost="0" /> 

      <!-- TODO: Insert files, registry keys, and other resources here. --> 
      </Component> 

     </Directory> 
     </Directory> 
    </Directory> 

    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION" /> 

    <!-- Note: Custom actions to install/uninstall the dll using regsvr32.exe --> 
    <CustomAction Id="RegisterDll" 
         Directory="INSTALLLOCATION" 
         ExeCommand='regsvr32.exe /s "[INSTALLLOCATION]$(var.MainDllName)"' 

         Return="check"> 
    </CustomAction> 
    <CustomAction Id="UnregisterDll" 
        Directory="INSTALLLOCATION" 
        ExeCommand='regsvr32.exe /s /u "[INSTALLLOCATION]$(var.MainDllName)"'> 
    </CustomAction> 


    <Feature Id="ProductFeature" Title="XYZ" Level="1"> 
     <ComponentRef Id="XYZDll" /> 
     <!-- Note: The following ComponentGroupRef is required to pull in generated authoring from project references. --> 
     <ComponentGroupRef Id="Product.Generated" /> 
    </Feature> 

    <InstallUISequence> 
     <Custom Action="WixCloseApplications" Before="AppSearch"/> 
    </InstallUISequence> 

    <InstallExecuteSequence> 

     <!-- Uninstall previous version before installing this one. --> 
     <RemoveExistingProducts Before="InstallInitialize"/> 


     <SelfRegModules/> 
    </InstallExecuteSequence> 

    <Icon Id="XYZ.ico" SourceFile="..\Graphics\XYZ.ico"/> 
    <Property Id="ARPPRODUCTICON" Value="XYZ.ico" /> 

    <!-- UI --> 
    <UIRef Id="WixUI_InstallDir"/> 
    <UIRef Id="WixUI_ErrorProgressText" /> 

    <WixVariable Id="WixUILicenseRtf" Value="..\EULA\license.rtf" /> 
    <WixVariable Id="WixUIBannerBmp" Value="..\Graphics\banner.jpg" /> 
    <WixVariable Id="WixUIDialogBmp" Value="..\Graphics\logo.jpg" /> 


    <!-- End UI --> 
    </Product> 
</Wix> 

UPDATE。隨後的修改升級項目後,爲我工作:

<?xml version="1.0" encoding="UTF-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> 

    <!-- 
When creating a new install for the next version, these fields must be modified 
--> 
    <?define ProductVersion = "2.0.4" ?> 

    <?define ProductId64 = "*" ?> 
    <?define ProductId32 = "*" ?> 

    <?define PackageId = "*" ?> 


    <!-- Product name as you want it to appear in Add/Remove Programs--> 
    <?if $(var.Platform) = x64 ?> 
    <?define ProductName = "XYZ (64 bit)" ?> 
    <?define Win64 = "yes" ?> 
    <?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?> 
    <?define ProductId = "$(var.ProductId64)" ?> 
    <?define MainDllName = "XYZ64.dll" ?> 
    <?define MainDllSource = "..\..\bin\Win64\Release\XYZ64.dll" ?> 
    <?else ?> 
    <?define ProductName = "XYZ (32 bit)" ?> 
    <?define Win64 = "no" ?> 
    <?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?> 
    <?define ProductId = "$(var.ProductId32)" ?> 
    <?define MainDllName = "XYZ.dll" ?> 
    <?define MainDllSource = "..\..\bin\Win32\Release\XYZ.dll" ?> 
    <?endif ?> 


    <?define UpgradeCode = "{C3763742-7C1C-4AB7-A404-F030B7550E97}" ?> 


    <Product 
    Id="$(var.ProductId)" 
    Name="$(var.ProductName)" 
    Language="1033" 
    Version="$(var.ProductVersion)" 
    Manufacturer="Advanced Messaging Systems LLC" 
    UpgradeCode="$(var.UpgradeCode)" 
    > 

    <Package Id="$(var.PackageId)" 
      InstallerVersion="200" 
      Compressed="yes" 
      Description="XYZ Installer package" 
      InstallPrivileges="elevated" 
    /> 

    <!-- No restore point --> 
    <Property Id="MSIFASTINSTALL" Value="3" /> 


    <Upgrade Id="$(var.UpgradeCode)"> 
     <UpgradeVersion Minimum="1.0.0" 
         IncludeMinimum="yes" 
         OnlyDetect="no" 
         Maximum="$(var.ProductVersion)" 
         IncludeMaximum="no" 
         Property="PREVIOUSFOUND" /> 
    </Upgrade> 


    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" /> 

    <Directory Id="TARGETDIR" Name="SourceDir"> 
     <Directory Id="$(var.PlatformProgramFilesFolder)"> 
     <Directory Id="INSTALLLOCATION" Name="XYZ"> 

      <Component Id="XYZDll" Guid="E2CBEE41-6C0E-4A84-95C1-7282747B4A3D"> 
      <File Id='MainDll' Name="$(var.MainDllName)" DiskId='1' Source="$(var.MainDllSource)" SelfRegCost="0" /> 

      <!-- TODO: Insert files, registry keys, and other resources here. --> 
      </Component> 

     </Directory> 
     </Directory> 
    </Directory> 

    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION" /> 

    <!-- Note: Custom actions to install/uninstall the dll using regsvr32.exe --> 
    <CustomAction Id="RegisterDll" 
         Directory="INSTALLLOCATION" 
         ExeCommand='regsvr32.exe /s "[INSTALLLOCATION]$(var.MainDllName)"' 

         Return="check"> 
    </CustomAction> 
    <CustomAction Id="UnregisterDll" 
        Directory="INSTALLLOCATION" 
        ExeCommand='regsvr32.exe /s /u "[INSTALLLOCATION]$(var.MainDllName)"'> 
    </CustomAction> 


    <Feature Id="ProductFeature" Title="XYZ" Level="1"> 
     <ComponentRef Id="XYZDll" /> 
     <!-- Note: The following ComponentGroupRef is required to pull in generated authoring from project references. --> 
     <ComponentGroupRef Id="Product.Generated" /> 
    </Feature> 

    <InstallUISequence> 
     <Custom Action="WixCloseApplications" Before="AppSearch"/> 
    </InstallUISequence> 

    <InstallExecuteSequence> 

    <RemoveExistingProducts After="InstallInitialize"/> 

     <SelfRegModules/> 

    </InstallExecuteSequence> 

    <Icon Id="XYZ.ico" SourceFile="..\Graphics\XYZ.ico"/> 
    <Property Id="ARPPRODUCTICON" Value="XYZ.ico" /> 

    <!-- UI --> 
    <UIRef Id="WixUI_InstallDir"/> 
    <UIRef Id="WixUI_ErrorProgressText" /> 

    <WixVariable Id="WixUILicenseRtf" Value="..\EULA\license.rtf" /> 
    <WixVariable Id="WixUIBannerBmp" Value="..\Graphics\banner.jpg" /> 
    <WixVariable Id="WixUIDialogBmp" Value="..\Graphics\logo.jpg" /> 


    <!-- End UI --> 
    </Product> 
</Wix> 

回答

7

如果你想有一個大uprade,開始與維克斯MajorUpgrade元素。升級的一般規則是:

  1. 舊產品的不同ProductCode和PackageCode。
  2. 在前三個字段的某處增加ProductVersion。
  3. 與舊產品相同的UpgradeCode。
  4. 做一些事情(像維克斯MajorUprade或升級元素),以確保您有到位的升級。
  5. 每個用戶安裝將不升級每個系統安裝,反之亦然。

在您的原始案例中,未遵循規則1和2意味着Windows認爲已安裝相同的產品並進入修復模式。這應該是你的第一個警告,因爲重大升級看起來像是全新安裝,而不是修復。如果您在程序&功能中有兩個條目,則表示這四個條件中的一個或多個未滿足。如果您收到「此產品的另一個版本已經安裝」,則表示您沒有遵循規則1,並且與已安裝產品相比,行爲變化與ProductCode和PackageCode值有關。

+0

是的,這對我有效。謝謝! –

+0

對我而言,這是第二點。產品版本在前三個字段中未更改。這條線上的** joshstechnij **也是這樣說的。 https://community.flexerasoftware.com/archive/index.php?t-197700.html –

+0

我假設在你的規則1中,ProductCode應該是'Product Id',PackageCode應該是'Package Id'。它們都應該是'「*」'並自動生成。 – Felix

5

我很驚訝的是,這條線實際上是由維克斯編譯連接允許:

<?define PackageId = "45F34788-66AC-441C-B666-707FFA7F1EE9" ?> 

如果這種情況真的工作,並通過,我沒有測試,這意味着你的包有一個硬編碼包編號爲。我認爲威克斯提供保護以防止這個問題?也許它呢?我們應該檢查Wix社區是否允許硬編碼包guid。我認爲它可能是必要的調試和測試目的 - 但至少應該有一個編譯器警告。

一個包GUID的想法是,它應該是每個編譯MSI文件是唯一的。它只是在那裏唯一標識一個文件。 具有相同包guid的兩個不同的MSI文件將按照定義由Windows安裝程序處理爲同一文件。各種各樣的x文件問題導致。因此,包GUID應始終自動生成,因爲它應該是唯一的。請嘗試首先解決此問題,以檢查是否可以解決您的整體問題。將它設爲等於*。

我的建議是自動生成包ID產品ID設置一個硬編碼升級代碼。升級代碼標識「產品系列」,並且可用於識別產品的任何實例,而不考慮語言和版本。對於64位和32位設置使用單獨的升級代碼可能會很有用,因爲這兩個版本可以在某些系統上同時安裝。

您可能還需要消除自注冊使用regsvr32.exe的,並從您的DLL中提取COM數據進行適當的MSI支持:MSI register dll - Self-Registration considered harmful。也許還請檢查:Register ActiveX exe server using WiX(如果Heat不起作用,請檢查RegSpy2)。

還要注意的是you can leave out a lot of source attributes from your Wix xml file和依靠維克斯違約而不是硬編碼值。

上的GUID和文件替換一些進一步的細節:

+0

我安裝使用regsvr32.exe的,因爲DLL的實現中的DllRegisterServer/DllUnregisterServer的是足夠聰明的dll - 它知道如何在有限的權利的環境中工作,並在HKCU而非HKLM自行安裝。 –

2

簡答題(另一個變得太亂):嘗試刪除這條線,讓包ID是自動生成的通過將其設定「*」:

<?define PackageId = "45F34788-66AC-441C-B666-707FFA7F1EE9" ?> 

注意卸載所有之前,您必須停止使用先前的所有MSI版本。這是由於錯誤的硬編碼軟件包guid造成的,這可能會導致不可預知的和無法預料的問題。

+0

如果PackageId爲「*」,我的安裝程序現在會覆蓋舊文件,但它始終作爲新安裝運行,因此沒有修復和卸載按鈕,並且「程序和功能」中有多個條目。 –

+0

如果我硬編碼的ProductId GUID,我得到「該產品的另一個版本已安裝」的錯誤提示我,菲爾指出你現在有一個**重大升級,先刪除它... –

+0

**這需要照顧這些問題。這裏有[**一些建議的資源來熟悉Wix **](http://stackoverflow.com/a/25005864/129130)。 –

相關問題