MSBuild.Sdk.SqlProj: master dacpac reference fails while deploys

master dacpac reference works during builds but fails during deploys - similar issue related to https://github.com/rr-wfm/MSBuild.Sdk.SqlProj/issues/51 but the DatabaseVariableLiteralValue doesn’t help with sqlpackage deploy for some reason.

The major difference I see is the old way the master.dacpac is attached as separate dacpac in the zip for deploy where as with new SDK style it is embedded into one.

Adding both dacpacs for reference

CustomerScoringDatabase.zip

CustomerScoringDatabase.zip is the zip we use for deploy from old way

CustomerScoringDatabaseNewSDK.zip

New SDK is created with MSBuild.Sdk.SqlProj

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18

Most upvoted comments

I am lookin at the TestSdk branch now, and there are multiple issue:

  • The project file should be a .csproj, not a .sqlproj
  • You should remove package.nuspec, if this is the main .dacpac you want to publish
  • You .sqlproj does not conform to the format described in the readme here, it should look something like this:
<Project Sdk="MSBuild.Sdk.SqlProj/2.7.2">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <SqlServerVersion>Sql150</SqlServerVersion>
    <SuppressTSqlWarnings>71558,71502</SuppressTSqlWarnings>
    <TargetName>CustomerScoringDatabase</TargetName>
    <RunScriptsFromReferences>True</RunScriptsFromReferences>
  </PropertyGroup>
  <ItemGroup>
    <None Include="SchemaComparisons\SchemaComparison.scmp" />
    <None Include="shared.publish.xml" />
  </ItemGroup>
  <ItemGroup>
    <PreDeploy Include="Scripts\Script.PreDeployment.sql" />
    <PostDeploy Include="Scripts\Script.PostDeployment.sql" />
    <None Include="package.nuspec">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Private>true</Private>
    </None>
  </ItemGroup>
  <ItemGroup>
    <Content Remove="Scripts\Script.PreDeployment.sql" />
    <Content Remove="Scripts\Script.PostDeployment.sql" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.SqlServer.Dacpacs.Master" Version="150.0.0" DacpacName="master" />
  </ItemGroup>
</Project>

OK, I will have a look

Your master .dacpac reference looks fine - again, with a repro project, I can actually confirm