SQL generated script is not copied when referenced a MSBuild.Sdk.SqlProj
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.csprojproject previously created. - Set the
ReferenceOutputAssemblyproperty tofalsein the<ProjectReference>added.
<ItemGroup>
<ProjectReference Include="..\MyDatabase\MyDatabase.csproj" ReferenceOutputAssembly="False" />
</ItemGroup>
- Compile the
MyUnitTests.csprojproject.
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 outputbinfolder of theMyDatabase.csprojand copied in theMyUnitTests.csprojoutputbinfolder.
That does not look like a documented or supported usage of project references.
@jmezach Thoughts?
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.