7

In the project settings of a database project I can set the version number form my data-tier application, however setting this manually is a bit inefficient. I would like to automatically increment the build number, as with other VS projects. How can this be done ? At the same time I would like to see this version number in the generated dacpac file.

nojetlag
  • 2,927
  • 9
  • 34
  • 42

1 Answers1

5

I found this forum thread had an answer that worked well: Automatic Version increment on Data-Tier Applications

Minimum steps are:

  1. Create Properties\AssemblyInfo.cs if it doesn't already exist, and make sure it's included in the project and contains at least this code: using System.Reflection; [assembly: AssemblyVersion("1.0.*")] Or however you want your version number to go.

  2. Edit the *.sqlproj file in an outside editor (notepad etc) and add the following XML:

    <Target Name="SetDacVersionToAssemblyVersion" AfterTargets="CoreCompile">
        <GetAssemblyIdentity AssemblyFiles="$(IntermediateTargetFullFileName)">
            <Output TaskParameter="Assemblies" PropertyName="IntermediateTargetAssembly" />
        </GetAssemblyIdentity>
        <PropertyGroup>
            <DacVersion>$(IntermediateTargetAssembly.Split(',')[1].Split('=')[1])
            </DacVersion>
        </PropertyGroup>
        <Message Text="DacVersion set to $(DacVersion)" Importance="high" />
    </Target>
Paul White
  • 94,921
  • 30
  • 437
  • 687
CrazyPyro
  • 241
  • 4
  • 7