如何在 VS2010 安装项目中添加不重新评估已安装文件的快捷方式

发布于 2024-11-13 07:37:46 字数 741 浏览 5 评论 0原文

情况:我有一个 Windows 桌面应用程序,它连接到各种服务(一次一个)以执行各种调用。无论我的应用程序连接到哪个服务,它的工作方式都是相同的。它应该随时连接到哪个服务是在 application.config 文件中定义的。

为了在服务之间切换,我创建了几个 Windows .bat 文件,每个文件都用新文件(服务端点)替换现有的 .config 文件以供使用。

为此,我创建了一个安装程序(一个 MSI,使用 Visual Studio 2010 中的“安装项目”模板)。此安装程序还创建以下快捷方式:

  1. 应用程序本身
  2. 第一个 .bat 文件(使用“默认”服务端点设置配置文件)
  3. 第二个 .bat 文件。 (用替代文件替换配置文件)

问题:每次我通过快捷方式运行其中任何一个(应用程序或bat文件)时,它们似乎都会“重新评估”之前安装的文件实际运行目标。只要我使用默认的 .config 文件,这就没问题,因为这就是它的安装方式。但是,如果我已经运行了第二个 .bat 文件,并且尝试运行该应用程序以便它连接到第二个服务,那么通过快捷方式启动应用程序会导致 .config 文件被还原,并且我最终会连接到而是第一个服务。

我可以手动创建自己的快捷方式,无论是 .bat 文件还是应用程序本身,而且它们工作得很好。不过,我希望这种情况能够自动发生,而不会扰乱对其他文件的任何更改。

任何想法将不胜感激! 预先感谢,
-基尔坦

The situation: I've got a Windows Desktop application that connects to various services (one at a time) to perform various calls. My application works the same way no matter which service it connects to. Which service it should connect to at any time is defined in an application.config file.

In order to switch between services, I've created a couple of windows .bat-files, each of which replaces the existing .config file with the new one (service endpoint) to use.

For all of this, I've created an installer (an MSI, using the "Setup Project" template in Visual Studio 2010). This installer also creates shortcuts to:

  1. the application itself
  2. the first .bat file (which sets the config file with the "default" service endpoint)
  3. the second .bat file. (which replaces the config file with the alternative one)

The problem: Each time I run any of these (the app or the bat files) via the shortcuts, they seem to "reevalueate" the installed files before actually running the target. This is no problem as long as I'm using the default .config file, as that was the way it was installed. If I've run the second .bat file however, and am trying to run the application so it connects to the second service, then starting the application via the shortcut causes the .config-file to be reverted, and I end up connecting to the first service instead.

I'm able to create my own shortcuts manually, both to the .bat files and to the application itself, and they work fine. I'd like this to happen automatically however, without messing up any changes to other files.

Any ideas would be greatly appreciated!
Thanks in advance,
-Kjartan

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

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

发布评论

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

评论(2

凝望流年 2024-11-20 07:37:46

您的部署项目具有所谓的“广告快捷方式”。有多种方法可以禁用这些功能,请参阅以下链接:

http://social.msdn.microsoft.com/Forums/en/vssetup/thread/b57f1d84-9b0c-4c29-b140-0555f92ffed8

Your deployment project has what is known as an "advertised shortcut". There are several ways to disable those, see the following link:

http://social.msdn.microsoft.com/Forums/en/vssetup/thread/b57f1d84-9b0c-4c29-b140-0555f92ffed8

我很OK 2024-11-20 07:37:46

谢谢乔治。这有点烦人,我很惊讶似乎没有一个好的方法来默认禁用它。我想我最终会分享我们采用的解决方案,即使它并不完美:我们将使用以下参数从命令提示符运行安装程序,从而生成“正常”快捷方式。

Setup.exe DISABLEADVTSHORTCUTS=1

这意味着我们无法让用户像平常那样通过简单的双击来安装该应用程序。然而,这确实意味着我们(程序员)每次进行新部署时都不必使用某些外部工具来编辑生成的安装程序;这是一个可以接受的权衡,因为这是一个仅限内部的应用程序。

再次感谢,
-基尔坦

Thanks George. This was kind of annoying, and I'm surprised there does not seem to be a good way to disable this by default. Thought I'd share the solution we went with in the end, even if it is not perfect: We will run the installer from command prompt with the following parameter, thus generating "normal" shortcuts.

Setup.exe DISABLEADVTSHORTCUTS=1

This means that we can't let our users install the app as they normally would, with a simple double-click. It does however mean that we (the programers) won't have to edit the generated installer using some external tool each time we do a new deployment; an acceptable trade-off, since this is an in-house only application.

Thanks again,
-Kjartan

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