I have a separate database project that Id would like to build in one solution and then reference the created dacpac. When I try to add a database project, it builds fine, and the dll is added to the secondary project file, but dacpac is not.
Is there a way that dacpac can be copied to my main project via msbuild? I keep thinking that there must be a way to modify the sqlproj file or the csproj file so that dacpac is included as one of the project outputs. My knowledge of msbuild is small, Ive been unable to figure it out.
It seems to me that I need to add dacpac to say the element '@ (ReferenceCopyLocalPaths), but I could not understand it. Any advice or suggestions would be appreciated.
I tried to do something a bit like the one mentioned here MSBuild - ItemGroup of all bin directories in subdirectories by doing:
<Target Name="AfterBuild">
<Message Text="@(MainAssembly)" />
<ItemGroup>
<DacPacs Include="%(ProjectReference.Directory)**/*bin*/*.dac" />
</ItemGroup>
<Message Text="@(ReferenceCopyLocalPaths)" />
<Message Text="DacPacs: @(DacPacs)" />
<Message Text="Target Database: $(TargetDatabase)" />
</Target>
which gives nothing for DacPacs (when adding a template). I also tried to reference one of the element groups from the sqlproj file, but it comes out empty:
source
share