Wix - 升级始终运行较旧的安装程序 msi,并且在尝试读取旧的 msi 时失败

发布于 2024-09-01 07:56:05 字数 1090 浏览 4 评论 0原文

我在安装程序的 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>

我收到的错误是:

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

谢谢,

I'm having a problem though with the Windows caching of the installer. I'm trying to do an upgrade and each time the Windows installer is launching the installer of the older version. And when I do the upgrade it is complaining about problems with reading the older version's msi file (because its not in the same directory anymore).

I did change the UpgradeCode and the ProductCode but kept the PackageCode the same. I also have different ProductVersion codes (2.2.3 vs 2.3.0).

Here's a sample of my code:

<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>

This is the Install Sequence:

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

The error I am getting is:

A network error occurred while attempting to read from the file:

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

荒路情人 2024-09-08 07:56:05

不要不要保留相同的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 团队在另一个“构建”之上安装一个“构建”,并且您还需要确保在任何公开发布之后立即手动增加前三个版本字段之一。

Do NOT keep the same PackageCode.

You really want to have this automatically generated... refer the documentation:

Nonidentical .msi files should not
have the same package code. It is
important to change the package code
because it is the primary identifier
used by the installer to search for
and validate the correct package for a
given installation. If a package is
changed without changing the package
code, the installer may not use the
newer package if both are still
accessible to the installer.

Here's an example from our production environment...

<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)" />

Now the downside of this approach is it means you probably also want to enforce major upgrades, which only care about the upgrade code being referenced. Now we can take advantage of the fact that for Windows Installer packages only the first three fields are significant, e.g. 1.0.0.1 and 1.0.0.2 both are interpreted as 1.0.0 (this is explicitly mentioned in the documentation, so we can rely on it.)

Extending this logic, we can auto-increment the (ignored) fourth version field with every build but prevent upgrade when the first three are the same.

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

The upside is this is completely transparent to customers, but prevents internal test/QA teams from installing one "build" on top of another and you also need to ensure that immediately following any public release you manually increment one of the first three version fields.

辞取 2024-09-08 07:56:05

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

在 InstallExecuteSequence 中,您需要以下行,

<RemoveExistingProducts After="InstallInitialize" />

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

这是一个很好的参考

You need to keep the upgrade code the same and change the product code (if you want an upgrade).

In the InstallExecuteSequence you need the following line

<RemoveExistingProducts After="InstallInitialize" />

I have chosen to put the action after the installInitialize sequence in this example however you can place them in other locations which will give you different effects.

This is a good reference

囍孤女 2024-09-08 07:56:05

这是源代码(或者我能提供的尽可能多的源代码):

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>

Here's the source code (or as much of it as I can give):

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>

酒解孤独 2024-09-08 07:56:05

您的产品元素说明了什么?

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

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

它也需要在原始表中,如果最初没有在其中指定,那么也许您可以运行 CA 使用 shell 命令将其删除。

除此之外,一切看起来都不错。

日志中的“查找相关产品”部分是否有任何内容?

What does your product element say?

You need to specify the same upgrade code in the upgrade table and the product table ie

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

and it needs to be in the original one aswell if it wasnt originally specified there then maybe you can run a CA to remove it with shell command.

Apart from that it all looks ok.

In the log does it say anything in the "Findrelatedproducts" section?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文