MSBuild.Sdk.SqlProj icon indicating copy to clipboard operation
MSBuild.Sdk.SqlProj copied to clipboard

SQL generated script is not copied when referenced a MSBuild.Sdk.SqlProj

Open GillesTourreau opened this issue 7 months ago • 3 comments

When we activate the generation of SQL Script with the <GenerateCreateScript> property, the generated script is not copied if the database project is referenced by an other project.

To reproduce the issue:

  • Create a MSBuild.Sdk.SqlProj database project with one SQL object (a table for example) : MyDatabase.csproj
  • Set the following MSBuild properties:
<Project Sdk="MSBuild.Sdk.SqlProj/3.2.0">
  <PropertyGroup>
      <GenerateCreateScript>True</GenerateCreateScript>
  </PropertyGroup>
</Project>
  • Create a C# project (unit test for example) : MyUnitTests.csproj
  • Add a reference to the MyDatabase.csproj project previously created.
  • Set the ReferenceOutputAssembly property to false in the <ProjectReference> added.
<ItemGroup>
   <ProjectReference Include="..\MyDatabase\MyDatabase.csproj" ReferenceOutputAssembly="False" />
</ItemGroup>
  • Compile the MyUnitTests.csproj project.

The MyDatabase_Create.sql is generated in the bin output folder of the MyDatabase.csproj project. But it is not copied in the MyUnitTests.csproj output bin folder.

NB: For the MyDatabase.dacpac, it is generated in the output bin folder of the MyDatabase.csproj and copied in the MyUnitTests.csproj output bin folder.

GillesTourreau avatar Sep 23 '25 09:09 GillesTourreau

That does not look like a documented or supported usage of project references.

ErikEJ avatar Oct 03 '25 15:10 ErikEJ

@jmezach Thoughts?

ErikEJ avatar Oct 07 '25 06:10 ErikEJ

I agree that this is not a documented feature currently, but I guess we could add the generate script to this MSBuild target so that it would be copied over to the referenced projects output folder.

jmezach avatar Oct 07 '25 07:10 jmezach