views:

221

answers:

2

How do i set the version on a asp.net project? as the properties dont contain any thing...

there is no project file in the folder where the webpage is.

+7  A: 

Assuming you're using a Web Application (rather than a Web Site project) then you should find that you have an AssemblyInfo.cs file in your "properties" folder.

This will contain attributes such as:

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

If you have a Web Site project then you can manually add a new .cs file and put these attributes in it.

You can find more info about these attributes here (on SO):

http://stackoverflow.com/questions/64602/what-are-differences-between-assemblyversion-assemblyfileversion-and-assemblyinf

update

Having just read the above post it might be that AssemblyInformationalVersion is the more appropriate attribute to use if you're just trying to hold info that you'd only display to a user.

update II

This is some "quick and dirty" code that'll grab the InformationalVersion from the attribuite:

string version = Assembly
                .GetExecutingAssembly()
                .GetCustomAttributes(
                   typeof(AssemblyInformationalVersionAttribute), true)
                .Where(x => x.GetType() == 
                   typeof(AssemblyInformationalVersionAttribute))
                .Cast<AssemblyInformationalVersionAttribute>()
                .First()
                .InformationalVersion;

If I were you I'd write a class that holds the attribute value, and the code above that access it, such that you can implement your version number using this attribute or whatever you like and then change the way you implement it over time.

Martin Peck
On a web site project, but the attributes in a .cs in the App_Code folder so it goes into the "main code" assembly. Depending on web.config settings you will get a different number of assemblies for the .as?x files.
Richard
How do i get the value of "AssemblyInformationalVersion"?
Petoj
A: 

An ASP.Net web site is not a project. If you have a source control add-in that requires the project file, then you need to make your site as a web application project.

Web application projects were the only option for ASP.Net in Visual Studio 2003 and 2001, but were removed in 2005 in favour of the web site model, then the feature was re-provided for VS 2005, but you'll need to install an add-in, you can read about it here: http://msdn.microsoft.com/en-us/asp.net/aa336618.aspx In VS 2008, the web application projects are built in the ide.

Ashraf Sabry