Home > Ramblings > App version by the deployment method

App version by the deployment method

January 10th, 2010 digital

I have several clickonce deployments. And it gets old having to manually increament my version numbers in the AssemblyInfo file especially when my deployment method does that on it’s own.

So… Here’s my solution.

Add Reference:
System.Deployment

using System.Deployment.Application;

...

public string Version { get; private set; }

public MainViewModel()
{
	SetVersion();
}

private void SetVersion()
{
	if ( ApplicationDeployment.IsNetworkDeployed )
		Version = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
	else
		Version = System.Reflection.Assembly.GetCallingAssembly().GetName().Version.ToString();
}

Now when I’m debugging, I can get a local version number and when the app is deployed I can get a meaningful version number as well.

Problem solved.

Comments are closed.