bornfromanegg
bornfromanegg

Reputation: 2928

Headless build .sqlproj file on TFS build server

I'm attempting to build a .sqlproj on a TFS Build Server. I've followed the instructions here:

http://sqlproj.com/index.php/2012/03/headless-msbuild-support-for-ssdt-sqlproj-projects/

which I was directed to from here:

How to build .sqlproj projects on a build server?

But I still cannot build. The error is:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets (441): The "SqlModelResolutionTask" task could not be instantiated from "C:\Program Files (x86)\Common7\IDE\Extensions\Microsoft\SQLDB\Dac\120\Microsoft.Data.Tools.Schema.Tasks.Sql.11.dll". System.TypeInitializationException: The type initializer for 'Microsoft.Data.Tools.Schema.Tasks.Sql.DataTask' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Data.Tools.Schema.Sql, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. at Microsoft.Data.Tools.Schema.Sql.Extensibility.ToolingShim.ConfigureExtensions() --- End of inner exception stack trace --- at Microsoft.Data.Tools.Schema.Tasks.Sql.DataTask..ctor()

The SqlTasks.targets file, used by the SQL project, references this:

C:\Program Files (x86)\Common7\IDE\Extensions\Microsoft\SQLDB\Dac\120\Microsoft.Data.Tools.Schema.Tasks.Sql.11.dll

which in turn references the invalid version mentioned above.

However, the files installed by the process in the link above don't install this version. They do install version 10.3.0.0, which is referenced by

C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\Microsoft.Data.Tools.Schema.Tasks.Sql.12.dll

but this file is not the one used by the .targets file.

I don't know what the numbers at the end of this dll mean, but it seems odd to me that the one ending 12.dll references an earlier version of the one ending 11.dll.

I'm using Visual Studio 2013 and SQL Server 2012 - neither of which are installed on the build server, which I believe is the recommended situation. I don't know what the IDE folder is, or why the .targets file is using it.

I've spent about two days now trying to get this to build, but I'm out of ideas. Anyone know what's going on?

Upvotes: 3

Views: 4219

Answers (2)

ccoutinho
ccoutinho

Reputation: 4626

I was having this issue building a SQL Server project on an Azure DevOps CI/CD pipeline. None of the pre-built build tasks would work for me. And it is not possible to install a VS instance on the build server, I guess.

I solved this by avoiding to add a SQL Server project to the solution.

I achieved this by using an MSBuild SDK, capable of producing a SQL Server Data-Tier Application package (.dacpac) from the set of SQL scripts. By adding this second project to the solution, I managed to continue taking advantage of linking the project to a live database through SQL Server Object Explorer on Visual Studio. I gave a more detailed explanation in this answer.

Upvotes: 0

Just TFS
Just TFS

Reputation: 4787

If you are running VS2013 SSDT is built into VS as long as you select it on the install screen. Install VS2013 with SSDT onto your build server. create a build definition and under Process > Build > Advanced Add the following to the MSBuild arguments to build the sql proj

/t:Build

if you have a publish profile and want to test publishing to SQL then add the publish switch and provide the link to the profile file

/t:Publish /p:SqlPublishProfilePath=MyDB.publish.xml.

this will publish the db to the server specified in the publish file.

the publish profile file can be created by opening the project in Visual Studio, right click on the project and select publish. Select save once you are happy with the publish options and then check in the file to source control so the build can find it, (project Root).

Upvotes: 3

Related Questions