3

I can't seem to find a way to grab the ClickOnce publish version of a .NET (not Framework) WPF app. I can get the the publish version from the assembly but that's a hard coded value that gets set in the project's .csproj.

I need the auto-incremented publish version from the ClickOnce at runtime in C#.

In .NET Framework I could do the following:

            ApplicationDeployment AD = ApplicationDeployment.CurrentDeployment;
            PublishVersion = AD.CurrentVersion.ToString();

I can't find anything analagous in .NET

Intensivist
  • 767
  • 2
  • 7
  • 19

2 Answers2

1

Looks like it doesn't exist in .net core or .NET 5(though it might get ported), but this might offer what you need -> https://github.com/derskythe/WpfSettings

newky2k
  • 419
  • 5
  • 12
0

Based on this answer it is as easy as

string versionString = Environment.GetEnvironmentVariable("ClickOnce_CurrentVersion") ?? "0.0.0.0";
Version version= Version.Parse(versionString);
MessageBox.Show(version.ToString());

I haven't tried it, but came across this issue and read literally 5 seconds before the answer given by @NineBerry and thus thought to link it here.

Jan Suchotzki
  • 1,406
  • 12
  • 24