How To: Use the AssemblyInfoTask With ASP.NET Web Deployment Projects
About once a week we get a question from someone who wants to know how to set the assembly version information on ASP.NET projects. I spoke with Bradley, a development lead over in the ASP.NET team who worked on the Web Deployment Projects, and it turns there are two ways you can do this.
If the only thing you're interested in doing is setting the version number on the web deployment project you can do that directly through UI properties on the deployment project instead of editing MSBuild files and downloading another task. For more information look at their walkthrough documentation.
If you want to set the version number as part of a larger build process that includes desktop assemblies and other class libraries you can use the AssemblyInfoTask and custom MSBuild XML. To make this work you need to add an assemblyinfo.cs (or .vb) to a folder called app_code under your top level directory. Once that file is there you can use the AssemblyInfoTask as you normally would to set the version number, and then use the Web Deployment Project to do the compliation of the assembly for the web.
[ Author: Neil Enns ]
Comments
Anonymous
August 20, 2007
Neil, Has this been tested? I have a AssemblyInfo.cs file into my App_Code directory with the following attributes: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] My WDP is set to merge all outputs to a single assembly. My WDP file has the following entry: <Import Project="$(MSBuildExtensionsPath)MicrosoftAssemblyInfoTaskMicrosoft.VersionNumber.Targets" /> I have an AfterBuild task but it never runs because: Target "AfterBuild" skipped, due to false condition; ($(MaxAssemblyVersion) != '') was evaluated as ( != ''). Please advise. Thanks, RonAnonymous
February 28, 2008
UI goes bork when you try default version such as: 1.0.* Even in the 2008 version.Anonymous
January 13, 2012
For reference, MSbuild doesn't evaluate empty strings nicely. If you have a property that might be evaluate to an empty string, quote the property, i.e. '$(MaxAssemblyVersion)' != ''