Question

Background

In Visual Studio 2013, targeting a TFS 2012 instance, I have 2 projects within my solution:

  1. a .sqlproj database project ("Project D"). This project outputs a .dll and a .dacpac file.
  2. a WPF project ("Project W") that holds a project reference to the database project.

The build output folder of Project W must contain the .dll and the .dacpac file from Project D--in addition to its own .exe. As expected, the project reference only causes the .dll from Project D to be copied to Project W's output folder. To get the .dacpac file as well, I include a linked file reference in Project W to the .dacpac file from Project D's output.

Problem

This works well in Visual Studio, but fails in TFS build, with the following error:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (3686): Could not copy the file "d:\TfsBuilds\2\...\ProjectD\bin\debug\ProjectD.dacpac" because it was not found.

Things I've tried (unsuccessfully)

Similar questions, like this and this, have different causes, and don't help me resolve the issue.

Solutions that:

  1. control the folder structure of the binaries output folder, or
  2. combine all the output for the solution's build into a single folder

still fail, because in every case, Project D's build output--including the .dacpac file--is placed below the build agent's folder in the drop folder, while project W's linked file reference is expecting the .dacpac file to be in a folder beneath Project D's source files within the build agent's mapped workspace, relative to Project W (i.e., "..\ProjectD\bin\debug\ProjectD.dacpac".) (paragraph edited for accuracy.)

Question

How can I configure my solution/projects in this particular scenario, so that they work both in Visual Studio and TFS Build?

(In my mind, the ideal would be if there was some special sort of "project reference" that would grab all the output of a referenced project, instead of just the .dlls.)

Was it helpful?

Solution

When you are packaging your WPF app just copy the dacpac into the package. If you just xcopy deploy, make sure to copy over the dacpac from the build outputs in addition to your WPF app. I usually have a powershell script I call from my TFSBuild that pulls together all the files I need into a package for deployment.

OTHER TIPS

Have your build tasks that execute SqlPackage use the $(OutputPath) variable to locate the dacpac file. TfsBuild overrides this MSBuild variable to instruct projects where to place their outputs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top