How to synchronise the publish version to the assembly version in a .NET ClickOnce application?

后端 未结 5 1418
甜味超标
甜味超标 2020-12-14 01:10

In my C# ClickOnce application, there is an auto-incremented publish version in the Project -> Properties -> Publish tab. I\'d like to display that version

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-14 01:33

    sylvanaar's last line looks like the way to go, in my experience; but with the caveat that it is only available to deployed versions of the application. For debugging purposes, you might want something like:

        static internal string GetVersion()
        {
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                return ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
            }
    
            return "Debug";
        }
    

提交回复
热议问题