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 (3)

  1. Ron says:


    Has this been tested?

    I have a AssemblyInfo.cs file into my App_Code directory with the following attributes:

    [assembly: AssemblyVersion("")]

    [assembly: AssemblyFileVersion("")]

    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.



  2. Mike says:

    UI goes *bork* when you try default version such as:


    Even in the 2008 version.

  3. Jason says:

    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)' != ''

Skip to main content