首页 文章

Wix - 升级总是运行较旧的安装程序msi,并且尝试读取旧的msi失败

提问于
浏览
4

我遇到了安装程序的Windows缓存问题 . 我正在尝试进行升级,每次Windows安装程序都启动旧版本的安装程序 . 当我进行升级时,它会抱怨读取旧版本的msi文件时出现问题(因为它不再位于同一目录中) .

我确实更改了UpgradeCode和ProductCode,但保持PackageCode相同 . 我也有不同的ProductVersion代码(2.2.3对2.3.0) .

这是我的代码示例:

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

这是安装顺序:

<InstallExecuteSequence>
    <Custom Action='SetUpgradeParams' After='InstallFiles'>Installed AND NEWAPPFOUND</Custom>
      <Custom Action='Upgrade' After='SetUpgradeParams'>Installed AND NEWAPPFOUND</Custom>
   </InstallExecuteSequence>

我得到的错误是:

尝试从文件读取时发生网络错误:

谢谢,

4 回答

  • 2

    不要保持相同的PackageCode .

    你真的希望自动生成这个...参考文档:

    不相同的.msi文件不应具有相同的包代码 . 更改包代码非常重要,因为它是安装程序用于搜索和验证给定安装的正确包的主要标识符 . 如果在不更改软件包代码的情况下更改软件包,则安装程序仍可访问安装程序时,安装程序可能不会使用较新的软件包 .

    以下是我们 生产环境 环境的一个例子......

    <Product Id="*"
             UpgradeCode="$(var.Property_UpgradeCode)"
             Name="!(loc.ApplicationName)"
             Language="!(loc.Property_ProductLanguage)"
             Version="$(var.version)"
             Manufacturer="!(loc.ManufacturerName)" > 
    
    <Package Description="!(loc.Package_Description) $(var.version)"
       Comments="!(loc.Package_Comments)"
       Manufacturer="!(loc.ManufacturerName)"
       InstallerVersion="301"
       Compressed="yes"
       InstallPrivileges="elevated"
       InstallScope="perMachine"
       Platform="$(var.ProcessorArchitecture)" />
    

    现在这种方法的缺点是它意味着您可能还希望强制执行主要升级,这只需要关注所引用的升级代码 . 现在我们可以利用以下事实:对于Windows Installer程序包,只有前三个字段是重要的,例如1.0.0.1和1.0.0.2都被解释为1.0.0(这在文档中明确提到,所以我们可以依赖它 . )

    扩展此逻辑,我们可以在每次构建时自动递增(忽略)第四个版本字段,但在前三个相同时阻止升级 .

    <UpgradeVersion Property="ANOTHERBUILDINSTALLED"
                 Maximum="$(var.version)" Minimum="$(var.version)"
                 IncludeMinimum="yes" IncludeMaximum="yes" OnlyDetect="yes" />
    

    好处是对客户完全透明,但是防止内部测试/ QA团队在另一个上面安装一个“构建”,您还需要确保在任何公开发布后立即手动增加前三个版本字段之一 .

  • 0

    您需要保持升级代码相同并更改产品代码(如果您想要升级) .

    在InstallExecuteSequence中,您需要以下行

    <RemoveExistingProducts After="InstallInitialize" />
    

    我已经选择在此示例中的installInitialize序列之后执行操作,但是您可以将它们放在其他位置,这将给您不同的效果 .

    This is a good reference

  • 0

    这是源代码(或者尽我所能):

    http://schemas.microsoft.com/wix/2003/01/wi“>

    .....

    <Package Id='$(var.PackageCode)'
             Comments='$(var.App_LongName)'
             Description='$(var.App_LongName) setup package'
             Manufacturer='$(var.Manufacturer)'
             InstallerVersion='200'
             Languages='1033'
             SummaryCodepage='1252'
             Compressed='yes'
             Keywords='Installer,$(var.App_ShortName)' />
    
    <FragmentRef Id='AppInstaller.UI' />
    
    <!-- Upgrade table -->
    <Upgrade Id="$(var.UpgradeCode)">
    
      <UpgradeVersion Minimum="$(var.ProductVersion)"
                      IncludeMinimum="no"
                      OnlyDetect="yes"
                      Property="NEWPRODUCTFOUND" />
      <UpgradeVersion Minimum="$(var.RTMProductVersion)"
                      IncludeMinimum="yes"
                      Maximum="$(var.ProductVersion)"
                      IncludeMaximum="no"
                      Property="UPGRADEFOUND" />
    
    </Upgrade>
    
    .....
    
    
    <!-- Prevent downgrading -->
    <CustomAction Id="NewerVersionDetected" Error="$(loc.App_WixUI_NewerVersionDetected)" />
    
    ......
    
    <CustomAction Id="SetDeployParams" Return="check" Property="Deploy" Value="Deploy|[DB_USER]|[DB_PW]|[DB_PORT]|[WS_USER]|[WS_PW]|[WS_PORT]|[PROTOCOL]|[HOST]|[TIMEOUT]|[#App.WAR]|[#CONTEXT.XML]" />
    <CustomAction Id="Deploy" JScriptCall="main" Property="Script" Execute="deferred" Return="check" />
    <CustomAction Id="SetRollbackParams" Return="check" Property="RollbackDeploy" Value="Rollback|[DB_USER]|[DB_PW]|[DB_PORT]|[WS_USER]|[WS_PW]|[WS_PORT]|[PROTOCOL]|[HOST]|[TIMEOUT]|[#App.WAR]|[#CONTEXT.XML]" />
    <CustomAction Id="RollbackDeploy" JScriptCall="main" Property="Script" Execute="rollback" />
    <CustomAction Id="SetUnDeployParams" Return="check" Property="UnDeploy" Value="Undeploy|[DB_USER]|[DB_PW]|[DB_PORT]|[WS_USER]|[WS_PW]|[WS_PORT]|[PROTOCOL]|[HOST]|[TIMEOUT]|[#App.WAR]|[#CONTEXT.XML]" />
    <CustomAction Id="UnDeploy" JScriptCall="main" Property="Script" Execute="deferred" Return="check" />
    <CustomAction Id="SetRepairParams" Return="check" Property="Repair" Value="Repair|[DB_USER]|[DB_PW]|[DB_PORT]|[WS_USER]|[WS_PW]|[WS_PORT]|[PROTOCOL]|[HOST]|[TIMEOUT]|[#App.WAR]|[#CONTEXT.XML]" />
    <CustomAction Id="Repair" JScriptCall="main" Property="Script" Execute="deferred" Return="check" />
    <CustomAction Id="SetUpgradeParams" Return="check" Property="Upgrade" Value="Upgrade|[DB_USER]|[DB_PW]|[DB_PORT]|[WS_USER]|[WS_PW]|[WS_PORT]|[PROTOCOL]|[HOST]|[TIMEOUT]|[#App.WAR]|[#CONTEXT.XML]" />
    <CustomAction Id='Upgrade' JScriptCall="main" Property="Script" Execute="deferred" Return="check" />
    <CustomAction Id="PreventDowngrading" Error="Newer version already installed." />
    
    <InstallUISequence>
      <FindRelatedProducts Sequence="200" />
      <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
    </InstallUISequence>
    
    <InstallExecuteSequence>
      <LaunchConditions After='AppSearch'></LaunchConditions>
      <RemoveExistingProducts After='InstallFinalize' />
    
      <Custom Action='SetUrl' Before='InstallFiles' />
      <Custom Action='SetSecurePort' After='LaunchConditions'>PROTOCOL = "secure"</Custom>
      <Custom Action='SetNonSecurePort' After='LaunchConditions'>NOT (PROTOCOL = "secure") OR NOT PROTOCOL</Custom>
    
      <Custom Action='SetDeployParams' After='InstallFiles'>NOT Installed AND NOT PATCH</Custom>
      <Custom Action='Deploy' After='SetDeployParams'>NOT Installed AND NOT PATCH</Custom>
    
      <Custom Action='SetRollbackParams' Before='RollbackDeploy'>NOT Installed AND NOT PATCH</Custom>
      <Custom Action='RollbackDeploy' Before='Deploy'>NOT Installed AND NOT PATCH</Custom>
    
      <Custom Action='SetUpgradeParams' After='InstallFiles'>Installed AND UPGRADEFOUND</Custom>
      <Custom Action='Upgrade' After='SetUpgradeParams'>Installed AND UPGRADEFOUND</Custom>
    
      <Custom Action='SetRepairParams' After='InstallFiles'>Installed AND NOT REMOVE="ALL" AND NOT NEWAPPFOUND</Custom>
      <Custom Action='Repair' After='SetRepairParams'>Installed AND NOT REMOVE="ALL" AND NOT NEWAPPFOUND</Custom>
    
      <Custom Action='SetUnDeployParams' After='MsiUnpublishAssemblies'>Installed AND REMOVE="ALL" AND NOT NEWAPPFOUND</Custom>
      <Custom Action='UnDeploy' After='SetUnDeployParams'>Installed AND REMOVE="ALL" AND NOT NEWAPPFOUND</Custom>
    
      <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
    
    </InstallExecuteSequence>
    
  • 3

    您的产品元素说什么?

    您需要在升级表和产品表中指定相同的升级代码,即

    <Product 
       Id="..." 
       Language="..." 
       Manufacturer="..." 
       Name="..." 
       UpgradeCode="$(var.UpgradeCode)" 
       Version="..."
    >
    

    并且它需要在原始的那个,如果它最初没有在那里指定那么也许你可以运行CA以使用shell命令将其删除 .

    一切都看起来不错 .

    在日志中它是否在“Findrelatedproducts”部分中说了什么?

相关问题