How to include dacpac file from build in Solution Output Path

3.6k views Asked by At

Tools: Visual Studio 2015, SSDT

I have an Visual Studio SQL Project which works fine on it's own. I run my build and the dacpac file is in debug\bin\*.dacpac as expected.

The problem is this SQL project is part of a WinForms solution.

I have included the SQL project as a project reference in the Winforms Project.

It looks like visual studio only copies dlls from project reference bin folders into the output path bin\debug folder.

How can I configure Visual Studio to ALSO copy the dacpac file to the winform project's bin\debug folder (outputpath)?

With other files that are included in the project itself, this is easy. I can just edit the file properties to copy always to output path. For BIN output you cannot do that since the dacpac file is a build output, not part of the project itself.

1

There are 1 answers

3
Leo Liu On

How can I configure Visual Studio to ALSO copy the dacpac file to the winform project's bin\debug folder (outputpath)?

You can add a copy task in the Pre-build event of Winforms Project or in the Post-build event of SQL project.

Post-build event in SQL project:

xcopy /y "$(ProjectDir)$(OutDir)*.dacpac" "$(SolutionDir)YourWindowsFormsProjectName\$(OutDir)"

Pre-build event in Winform project:

xcopy /y "$(SolutionDir)YourSQLProjectName\$(OutDir)*.dacpac" "$(ProjectDir)$(OutDir)"

Here are some commonly used switches with xcopy:

/I - treat as a directory if copying multiple files
/Q - Do not display the files being copied.
/S - Copy subdirectories unless empty.
/E - Copy empty subdirectories.
/Y - Do not prompt for overwrite of existing files.
/R - Overwrite read only files.

Hope this help.