• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1016
  • Last Modified:

Automatic version increment on a C# program?

I have a web service I'd like to deploy and would like to remotely check the version number.  But I do not want to take the risk that I forgot to increment some value before deployment.  I want to be certain that a new version arrived and was deployed.

Is therea build number or some other unique value (or string) that the program can reference and return when I create a Getersion() web method?

2 Solutions
Gary DavisDir Internet SvcsCommented:
See this article. Note you have AssemblyInfo.cs in your project.

How to auto-increment assembly version using a custom MSBuild task
The assembly version string has the format major.minor.build.revision, such as 2.0.50727.42.  Here is a sample on how to create a custom MSBuild task for Web Deployment Projects  to auto-increment the build and revision portion of your version strings with each build.

Another idea I use is to use the datestamp from the web site's dll which is the last compile date/time.

            DateTime timestamp = System.IO.File.GetCreationTime("your.dll");

Gary Davis
generally you do want to version a webservice like this. generally you want to only 'publicly' chane versions when you have a material change to the contract (as thats all the client really cares about)
newbiewebAuthor Commented:

Maybe I'll have a public version like you say, but a private version as well, so I can be sure that multiple servers running the same web service in fact have the same build.


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now