我在 Visual Studio 中创建了几个 SQL 项目,我想集中管理 dacpac 的版本。为了实现这一点,我想使用这篇文章的答案重用道具文件:
<?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>
在 sql 项目中,我添加以下导入语句:
<Import Project="..\..\Environment\MyPropsFile.props" />
如果我在 Visual Studio 中检查项目的属性,我得到了这个:
我构建项目并解压缩 dacpac 文件,检查 DacMetadata.xml 并得到以下信息:
<?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>
如果我为 sql 项目构建 MSBuild 并解压缩 dacpac 文件,我检查 DacMetadata.xml 并得到以下信息:
<?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>
我应该怎么做才能从 Visual Studio 中看到版本和描述的变化?