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

时间:2011-10-07 15:36:03

标签: visual-studio clickonce

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

但是,Visual Studio会将此解析为以下路径: C:\用户\ ME \应用程序数据\本地\应用\ 2.0 \ CGR50YPV.W5E \ RXBXM176.HH8 \ crea..tion_f423fce0316e1dfa_0001.0000_adecafbe6c6acba3 \ MyAppp.exe

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

如何在不必每次更新命令路径的情况下完成此工作?

1 个答案:

答案 0 :(得分:1)

您不应该通过exe文件访问ClickOnce应用程序。如果您要这样做,只需将应用程序的\ bin文件夹xcopy到另一台机器。如果要使用更新功能,则应始终使用快捷方式或通过调用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");
}

(抱歉,我无法弄清楚如何使代码格式更漂亮并正确显示缩进,但你明白了。)