Home > Technology > App version by the deployment method

App version by the deployment method

January 10th, 2010 Leave a comment Go to comments

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.

  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.