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?

newbiewebSr. Software EngineerAsked:
Who is Participating?
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, 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)
newbiewebSr. Software EngineerAuthor 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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.