安装程序不会覆盖现有应用程序

发布于 2024-11-15 01:28:01 字数 327 浏览 6 评论 0原文

我有一个包含 8 个项目的 Visual Studio 2010 解决方案。它还有一个我构建的安装项目来创建安装。

当首次安装在客户端 PC 上时,它运行良好。但是,然后我修改我的项目,并构建一个新的安装程序,并将其传递给客户端。发生这种情况时,客户端必须首先手动卸载最后一个安装,然后运行安装程序。

如果他们运行安装程序而不卸载,它似乎不会覆盖现有文件(exe 以及 dll)。通常只是 exe 被修改。但是,它不会覆盖它。客户端计算机上的版本似乎保持不变。

有没有办法强制覆盖?

请注意,当我修改主应用程序项目时,我会转到项目属性、程序集信息,并增加程序集版本和文件版本。

I have a Visual Studio 2010 solution with 8 projects. It also has a Setup project which I build to create the installation.

It works fine when it's the first installation on a client PC. However, I then modify my project, and build a new Setup, and pass it onto clients. When this happens, the client has to first, manually, uninstall the last installation, and then run the setup.

If they run the setup, without uninstallaing, it seems it doesn't overwrite existing files (exe as well as the dlls). Usually it's just the exe that gets modified. However, it doesn't overwrite it. The version on the client machine seems to stay the same.

Is there a way to force it to overwrite?

Note that when I modify my main application project, I go to the properties of the project, assembly information, and increase the Assembly Version as well as the File Version.

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

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

发布评论

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

评论(9

野稚 2024-11-22 01:28:01

如果您想对安装进行良好的控制,与商业产品甚至 WiX 相比,Visual Studio 安装程序并不是最用户友好的。

当您有 Visual Studio 安装项目时,升级过程中会涉及多个属性

1) 升级代码 - 这是同类安装程序之间的链接,您不应不必要地更改此代码

2) 版本号 -奇怪的是,只有前 3 个数字(major.minor.build)用于比较(这是很多开发人员常犯的错误)

3)产品代码 - 一旦你更改版本号,VS 就会提示你更改这个数字 - 做它 - 如果您自动进行数字更改,请记住也执行此操作

4)DetectNewerInstalledVersion - 设置为 True

5)RemovePreviousVersions - 设置为 True

就个人而言,我会考虑使用 WiX 进行如此小的安装,即如果您可以在 Visual Studio 中执行此操作然后 WiX 版本

我的 OpenCover 安装程序看起来像这样

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" >

<Product Id="*" Name="OpenCover" Language="1033" Version="!(bind.FileVersion.OPENCOVER_FRAMEWORK_DLL)" 
        Manufacturer="OpenCover @ GitHub" UpgradeCode="2250c3f1-d9ba-44d8-b4db-25f91fe92dc6">

    <Package InstallerVersion="200" Compressed="yes" />

    <Upgrade Id="2250c3f1-d9ba-44d8-b4db-25f91fe92dc6">
        <UpgradeVersion OnlyDetect="no" Property="PREVIOUSFOUND" Minimum="1.0.0.0" IncludeMinimum="yes"
                        Maximum="!(bind.FileVersion.OPENCOVER_FRAMEWORK_DLL)" IncludeMaximum="no" />

        <UpgradeVersion OnlyDetect="yes" Property="NEWERFOUND" Minimum="!(bind.FileVersion.OPENCOVER_FRAMEWORK_DLL)"
                        IncludeMinimum="yes" />
    </Upgrade>

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

...

</Wix>

我希望您发现以上内容有用

The visual studio installer is not the most user friendly compared to commercial products or even WiX if you are after a good level of control over you installation.

When you have a Visual Studio Setup project you have several properties that are involved in the Upgrade process

1) The Upgrade Code - this is the link between installers of the same ilk and you shouldn't change this code needlessly

2) The Version number - strangely only the 1st 3 numbers (major.minor.build) are used for comparison (this is a common mistake that a lot of developers make)

3) The Product Code - As soon as you change the version number VS will prompt you to change this number - do it - if you automate the number change remember to do this as well

4) DetectNewerInstalledVersion - set to True

5) RemovePreviousVersions - set to True

Personally I'd look at using WiX for such a small installation i.e. if you can do it in Visual Studio then the WiX version

My installer for OpenCover looks like this

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" >

<Product Id="*" Name="OpenCover" Language="1033" Version="!(bind.FileVersion.OPENCOVER_FRAMEWORK_DLL)" 
        Manufacturer="OpenCover @ GitHub" UpgradeCode="2250c3f1-d9ba-44d8-b4db-25f91fe92dc6">

    <Package InstallerVersion="200" Compressed="yes" />

    <Upgrade Id="2250c3f1-d9ba-44d8-b4db-25f91fe92dc6">
        <UpgradeVersion OnlyDetect="no" Property="PREVIOUSFOUND" Minimum="1.0.0.0" IncludeMinimum="yes"
                        Maximum="!(bind.FileVersion.OPENCOVER_FRAMEWORK_DLL)" IncludeMaximum="no" />

        <UpgradeVersion OnlyDetect="yes" Property="NEWERFOUND" Minimum="!(bind.FileVersion.OPENCOVER_FRAMEWORK_DLL)"
                        IncludeMinimum="yes" />
    </Upgrade>

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

...

</Wix>

I hope you find the above useful

森林迷了鹿 2024-11-22 01:28:01

在安装项目的属性中,更改版本/内部版本号。这将提示您允许生成新的 GUID。这样做会告诉安装程序您有新版本,并将允许旧版本的程序自动删除并由 MSI 系统安装新版本。

In the properties of the setup project, change the version/build numbers. This will prompt you to allow a new GUID to be generated. Doing this tells the installer that you have a new version and will allow the old version of the program to be automatically removed and the new installed by the MSI system.

惜醉颜 2024-11-22 01:28:01

尽管按照上述步骤操作,我也遇到了 .exe 未更新的问题。 .exe 的产品版本似乎不会自动遵循安装属性中设置的版本号。对于运行新安装程序时要替换的 .exe,请按如下方式增加产品版本:

1) 转到项目属性 >应用>>程序集信息...

2) 增加程序集和文件版本号

3) 再次构建安装程序,安装应覆盖旧的 .exe

希望这对某人有帮助。

I also had the problem of the .exe not updating although following the steps above. It would seem that the product version of the .exe does not automatically follow the version number set in the setup properties. For the .exe to be replaced when running the new installers increment the product version as follows:

1) Goto Project Properties > Application > Assembly Information...

2) Increase the Assembly and File version numbers

3) Build the setup again and the install should overwrite the old .exe

Hope this helps someone.

零崎曲识 2024-11-22 01:28:01

程序集版本& AssemblyFileVersion 应该增加程序集(exe/dll)覆盖以及 @shaun Wilde 提到的其他设置

AssemblyVersion & AssemblyFileVersion should be incremented for assembly (exe/dll) overwrite along with other settings what @shaun wilde mentioned

笨笨の傻瓜 2024-11-22 01:28:01

这是一篇旧文章,但为可能来寻找答案的人添加了此内容。

即使在遵循给定的所有内容之后,我也遇到了这个问题 这里到这封信。我的问题是,无论如何,C# 程序的版本都不会在每次构建时增加。即使我手动编辑了AssemblyInfo.cs,生成的exe版本仍然是1.0.0.0。因此,安装程序不会替换该文件。

解决方法是将启动条件添加到安装项目的“XYZ 项目的主输出”(或您想要覆盖的任何内容)节点。这会导致安装程序在运行较新的安装程序时删除该文件。现在,当用户启动应用程序时,会出现一个窗口,显示正在配置应用程序,将较新的文件复制到应用程序文件夹并启动应用程序。这就是简单的尝试和错误。我不知道为什么它会这样工作(在花了整晚试图弄清楚这一点之后我需要一些咖啡:))。

  1. 右键单击您的安装项目>>查看>>启动条件
  2. 右键单击“目标机器上的要求”>>添加文件启动条件
  3. 一个节点(“搜索 File1”)将出现在“搜索目标计算机”下,另一个节点(“条件 1”)将出现在“启动条件”下
  4. 单击“搜索 File1”并将其 FileName 属性更改为绑定到预先存在的(如“Notepad.exe”,几乎总是如此)
  5. 请注意,“文件夹”设置为“[SystemFolder]”,“属性”设置为“FILEEXISTS1”
  6. 现在单击“主输出 ”从 XYZ 项目或任何其他节点,在属性窗口中,将“条件”设置为“FILEEXISTS1”,与上面显示的完全相同

This is an old post but adding this for people who might come looking for an answer.

I ran into this very problem even after following everything given here to the letter. My issue was that the C# program's version will not increment on every build no matter what. Even after I manually edited AssemblyInfo.cs, the generated exe's version would still be 1.0.0.0. As a result, setup won't replace the file.

The workaround is to add a launch condition to the "Primary Output from XYZ Project" (or whatever you want to be overwritten) node of setup project. This causes the installer to delete the file when the newer setup is run. Now when user launches the app, a window appears saying application is being configured, newer files are copied to the app folder and app is launched. This is plain trial and error. I have no clue why it works this way (and I need some coffee after spending the whole night trying to figure this out :)).

  1. Right click on your setup project >> View >> Launch Conditions
  2. Right click on "Requirements on Target Machine" >> Add File Launch Condition
  3. A node ("Search for File1") will appear under "Search Target Machine" and another node ("Condition1") will appear under "Launch Conditions"
  4. Click on Search for File1 and change its FileName property to something which is bound to pre-exist (like "Notepad.exe", well almost always)
  5. Note that "Folder" is set to "[SystemFolder]" and "Property" is set to "FILEEXISTS1"
  6. Now click on Primary Output from XYZ Project or any other node and in the properties window, set "Condition" to "FILEEXISTS1" exactly as it appeared above
浮生面具三千个 2024-11-22 01:28:01

稍微细化一下答案,您必须增加文件版本才能让 Windows Installer 在更新期间覆盖。这不一定与某些人指出的增加程序集版本相同。只有文件版本需要递增,对于托管代码,您可以使用 AssemblyFileVersion 来执行此操作。文件版本默认为程序集版本,但当您具有依赖于特定 AssemblyFileVersion 的客户端程序集时,AssemblyFileVersion 允许您使它们不同。

Refining the answers a little, you must increment the File version to get Windows Installer to overwrite during an update. This is not necessarily the same as incrementing the assembly version as some have indicated. Only the file version needs incrementing, and with managed code you do this with AssemblyFileVersion. The file version defaults to assembly version, but AssemblyFileVersion lets you make them different when you have client assemblies that depend on a specific AssemblyFileVersion.

悲欢浪云 2024-11-22 01:28:01

与文件不覆盖有类似的问题。检查了版本号、产品/升级代码,一切。最终帮助我的是 此帖子位于MSDN。特别是这里的部​​分,当使用 Orca 检查 msi 文件时:

我还将>InstallExecuteSequence表中RemoveExistingProducts的顺序从6550更改为1525(在InstallExecute之后到>InstallInitialize之后)。

不知道为什么,但安装程序似乎在安装新版本后运行了以前版本的卸载。也许这是有原因的,但改变它似乎是我强制我的应用程序升级的唯一方法。

如果其他人像我最近一样偶然发现这个问题,希望这个解决方法能有所帮助。

Had similar problems with files not overwriting. Checked version numbers, product/upgrade codes, everything. What finally helped me was this post at MSDN. Specifically the part here, when using Orca to examine the msi file:

I also changed the sequence of RemoveExistingProducts in the >InstallExecuteSequence table from 6550 to 1525 (after InstallExecute to after >InstallInitialize).

Not sure why, but the installer seems to run the uninstall of previous version after it's already installed the new version. Maybe there's a reason for it, but changing it seemed to be the only way I could force my application to upgrade.

If anyone else stumbles across this problem like I have recently, hope this workaround helps.

握住我的手 2024-11-22 01:28:01

我也有同样的问题。确保这一点的最佳方法是确保您的可执行文件(即 Application.exe 本身)的版本高于前一个文件。

只需单击项目属性(不是安装项目),然后将应用程序版本设置为更高版本即可。

I had the same problem. The best way to ensure this is to make sure your executable file, i.e. the Application.exe itself has a higher version than the preceeding one.

Just click on the project properties (not the setup project), and set the Application version to a higher one.

傲鸠 2024-11-22 01:28:01
  • 经过长时间的研发,我找到了解决方案:

我面临的问题:

  1. 每当我从本地安装该工具的新版本时,都不会更新现有工具(在控制面板中检查),并为该工具安装新版本相同的工具。

原因:

  1. 无法将我本地发布的工具版本映射到实时位置的版本。

解决方案:

  1. 请确保您在实时驱动器上拥有该工具的最新发布副本。

注意:如果您已尝试了所有可能的方法但仍未为解决方案提供资金,请也尝试一下。

  • After a long R&D, I found the solution:

Issue I faced:

  1. Whenever I was installing a new version of the tool from my local, is not updating the existing tool (checked in control panel), and installing a new version for the same tool.

Cause:

  1. Unable to map my locally published tool version to Live location's version.

Solution:

  1. Please insure, you are having the latest published copy of the tool on the live drive.

Note: If you have tried all the possible ways and still not fund the solution, try it also.

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