1

I have created several SQL projects in visual studio, I want to manage the version of the dacpac in a centralized way. In order to fulfill that I want to reuse a props file using the answer this post :

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition="$(MSBuildProjectExtension) == '.csproj'">
    <CommonPlatform>$(Platform)</CommonPlatform>
    <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)myfile.snk</AssemblyOriginatorKeyFile>
    <LinkKeyFile>$(MSBuildThisFileDirectory)myfile.snk</LinkKeyFile>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
      </PropertyGroup>
  <ItemGroup Condition="$(MSBuildProjectExtension) == '.csproj'">
    <Compile Include="$(MSBuildThisFileDirectory)CommonAssemblyInfo.cs">
      <Link>Properties\CommonAssemblyInfo.cs</Link>
    </Compile>
  </ItemGroup>
    <Import Project="StyleCop\StyleCop.Targets" Condition="$(MSBuildProjectExtension) == '.csproj'"/>

  <!--Version management for DACPAC projects -->
  <PropertyGroup Condition="$(MSBuildProjectExtension) == '.sqlproj'">
    <DacVersion>15.1.0.0</DacVersion>
    <DacDescription>Release 15.1</DacDescription>
  </PropertyGroup>
</Project>

in the sql project I add the following import sentence:

<Import Project="..\..\Environment\MyPropsFile.props" />

If I check the properties of the project in visual studio I got this:

enter image description here

I build the project and unpack the dacpac file, I check the DacMetadata.xml and got this:

<?xml version="1.0" encoding="utf-8"?>
    <DacType xmlns="http://schemas.microsoft.com/sqlserver/dac/Serialization/2012/02">
      <Name>MyDB</Name>
      <Version>1.0.0.0</Version>
    </DacType>

If I build the MSBuild for the sql project and unpack the dacpac file, I check the DacMetadata.xml and got this:

 <?xml version="1.0" encoding="utf-8"?>
        <DacType xmlns="http://schemas.microsoft.com/sqlserver/dac/Serialization/2012/02">
          <Name>MyDB</Name>
          <Version>15.1.0.0</Version>
          <Description>Release 15.1</Description>
        </DacType>

What should I do to see the changes in the version and description from Visual Studio?

Community
  • 1
  • 1
XtianGIS
  • 967
  • 16
  • 39

1 Answers1

2

This approach can work in Visual Studio, but the DAC version metadata is unfortunately cached when the solution is loaded. This means that if you want the metadata to be reloaded from the props file, you must close and re-open the entire solution. (Unloading and reloading the database project isn't sufficient).

Steven Green
  • 3,387
  • 14
  • 17