views:

505

answers:

3

In Visual Studio 2005, is there an easy way to automatically increment the assembly/file build numbers after a successful build?

Emphasis on easy. I would like to track my build version, without having to set up CruiseControl or some similar tool.

A: 

What about writing a little macro, which increments the version?

Or what about this VS AddIn ?

Louis Haußknecht
What kind of macro, and how is it triggered?
Treb
+2  A: 

You can use this project and include it your .proj file

This url might be of use Updating Porj build number

This didn't fit my needs and I took to adding this as a build.proj which works a treat

<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build"  
         xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;

  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/> <PropertyGroup>
    <Major>1</Major>
    <Minor>0</Minor>
    <Build>0</Build>
    <Revision>0</Revision>   </PropertyGroup>   <PropertyGroup>
    <BuildDir>C:\svn\Infrastructure</BuildDir> </PropertyGroup>

  <ItemGroup>
    <SolutionsToBuild Include="Infrastructure.sln"/>   </ItemGroup>

  <Target Name="Build" DependsOnTargets="ChangeDataAccessAssemblyInfo">
    <RemoveDir Directories="$(BuildDir)\Builds" Condition="Exists('$(BuildDir)\Builds')" />
    <MSBuild Projects="@(SolutionsToBuild)" Properties="Configuration=Debug" Targets="Rebuild" />   </Target>

  <ItemGroup>
    <TestAssemblies Include="Build\Logging\Logging.UnitTests.dll" />   </ItemGroup>



  <Target Name="ChangeDataAccessAssemblyInfo" >
    <Message Text="Writing ChangeDataAccessAssemblyInfo file for 1"/>
    <Message Text="Will update $(BuildDir)\DataAccess\My Project\AssemblyInfo.vb" />
    <AssemblyInfo CodeLanguage="VB"
       OutputFile="$(BuildDir)\DataAccess\My Project\AssemblyInfo_new.vb"          

       AssemblyTitle="Data Access Layer"
       AssemblyDescription="Message1"
       AssemblyCompany="http://somewebiste"
       AssemblyProduct="the project"
       AssemblyCopyright="Copyright notice"
       ComVisible="true"
       CLSCompliant="true"
       Guid="hjhjhkoi-9898989"
       AssemblyVersion="$(Major).$(Minor).1.1"
       AssemblyFileVersion="$(Major).$(Minor).5.7"
       Condition="$(Revision) != '0' "
       ContinueOnError="false" />

    <Message Text="Updated Assembly File Info" 
             ContinueOnError="false"/>   </Target>   </Project>
Dean
+1  A: 

The Publish options might be what you want... (def. available for C#, not sure abuut C++).

In studio, right click on the project file, and go to Properties, then select the "Publish" tab. There is an option there for auto-incrementing revision number.

xan
Does not work for me :-(My project is a module that is compiled to a class library, and you can not publish those. But thanks anyway!
Treb
Ah - sorry that can't help then.
xan