使用 ClickOnce exe 作为 Visual Studio 外部工具

发布于 2024-12-08 17:11:03 字数 440 浏览 0 评论 0原文

我有一个我构建的命令行可执行文件,它通过 ClickOnce 在网络上发布。该工具的主要用途是通过 Visual Studio 作为外部工具。当我在 Visual Studio 中进行设置时,我可以将命令路径设置为我的配置文件的漫游数据下的快捷方式。

但是,Visual Studio 会将其解析为如下路径: C:\Users\ME\AppData\Local\Apps\2.0\CGR50YPV.W5E\RXBXM176.HH8\creat..tion_f423fce0316e1dfa_0001.0000_adecafbe6c6acba3\MyAppp.exe

那么如果我启动 exe 并获取新版本 Visual Studio 会发生什么仍然指向旧版本(如上所述)。我可以通过将外部工具的命令值重新指向 exe 的快捷方式来解决此问题,但这处理起来有点令人沮丧。

如何才能完成这项工作而不必每次都更新我的命令路径?

I have a command line executable I built which is published on the network via ClickOnce. The main use of this tool is through Visual Studio as an external tool. When I set this up in Visual Studio I am able to set the command path to the shortcut under roaming data for my profile.

However, Visual Studio resolves this to a path such as:
C:\Users\ME\AppData\Local\Apps\2.0\CGR50YPV.W5E\RXBXM176.HH8\crea..tion_f423fce0316e1dfa_0001.0000_adecafbe6c6acba3\MyAppp.exe

So what happens is if I launch the exe and grab a new version, Visual Studio is still pointing at the old version (as indicated above). I can fix this by re-pointing the command value of my external tool to the shortcut of my exe, but this is a bit frustrating to deal with.

How can I make this work without having to update my command path every time?

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

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

发布评论

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

评论(1

煞人兵器 2024-12-15 17:11:03

您不应通过 exe 文件访问 ClickOnce 应用程序。如果您打算这样做,只需将应用程序的 \bin 文件夹复制到另一台计算机即可。如果要使用更新功能,则应始终通过使用快捷方式或调用 Web 服务器上部署清单的链接来调用 ClickOnce 应用程序。 (部署清单是应用程序文件)。您可以在该链接上执行 process.start 。

[编辑--添加新信息]
哦哦哦,那么您正在访问用户个人资料下文件夹中的快捷方式?我明白了吗?您可以指向开始菜单上的快捷方式,而不是寻找该快捷方式吗?如果应用程序在线/离线,当用户安装应用程序时,它会自动添加一个。使用“选项”对话框中的这些字段,快捷方式将添加到开始菜单中发布公司/产品名称的位置。

我通过将程序集信息设置为相同的值并以编程方式检索程序集信息来实现此目的。我总是将装配描述设置为与产品名称相同,并将装配公司设置为与出版公司相同。然后我可以这样做:(

Assembly code = Assembly.GetExecutingAssembly();
string company = string.Empty;
string description = string.Empty;
if (Attribute.IsDefined(code, typeof(AssemblyCompanyAttribute)))
{
        AssemblyCompanyAttribute ascompany =
          (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(code, 
       typeof(AssemblyCompanyAttribute));
    company = ascompany.Company;
}
if (Attribute.IsDefined(code, typeof(AssemblyDescriptionAttribute)))
{
    AssemblyDescriptionAttribute asdescription =
    (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(code, 
    typeof(AssemblyDescriptionAttribute));
    description = asdescription.Description;
}
if (company != string.Empty && description != string.Empty)
{
    string shortcutName = 
      string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
        \", company, "\\", description, ".appref-ms");
}

抱歉,我不知道如何使代码格式更漂亮并正确显示缩进,但你明白了。)

You shouldn't access a ClickOnce application via the exe file. If you're going to do that, just xcopy the \bin folder of the application to the other machine. If you want to use the update features, you should always invoke the ClickOnce application by using the shortcut or by invoking the link to the deployment manifest on the webserver. (The deployment manifest is the application file). You can do a process.start on that link.

[edit -- add new info]
Ohhhhh, so you're accessing the shortcut in the folder under the user's profile? Am I getting that? Instead of looking for that one, can you point to the shortcut on the start menu? It will add one automatically when the user installs the application, if the application is online/offline. The shortcut is added to the start menu to the location of the Publishing Company / Product Name using those fields from the Options dialog.

I do this by setting the assembly information to the same values, and retrieving the assembly information programmatically. I always set the assembly description to be identical to the product name, and the assembly company to be the same as the publishing company. Then I can do this:

Assembly code = Assembly.GetExecutingAssembly();
string company = string.Empty;
string description = string.Empty;
if (Attribute.IsDefined(code, typeof(AssemblyCompanyAttribute)))
{
        AssemblyCompanyAttribute ascompany =
          (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(code, 
       typeof(AssemblyCompanyAttribute));
    company = ascompany.Company;
}
if (Attribute.IsDefined(code, typeof(AssemblyDescriptionAttribute)))
{
    AssemblyDescriptionAttribute asdescription =
    (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(code, 
    typeof(AssemblyDescriptionAttribute));
    description = asdescription.Description;
}
if (company != string.Empty && description != string.Empty)
{
    string shortcutName = 
      string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
        \", company, "\\", description, ".appref-ms");
}

(Sorry, I can't figure out how to make the code format prettier and show the indents properly, but you get the idea.)

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