Reputation: 7228
I have Windows Server 2012 R2 which I want to use to build .sqlproj
projects from SSDT in a CI pipeline. This is what I've done so far:
Microsoft.Data.Tools.Msbuild
When I build my solution with
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe database.solution.sln /p:tv=14 /p:SSDTPath=D:\Nuget\Microsoft.Data.Tools.Msbuild\lib\net40 /p:SQLDBExtensionsRefPath=D:\Nuget\Microsoft.Data.Tools.Msbuild\lib\net40 /p:Configuration=Debug
I get an error saying Could not load file or assembly 'Microsoft.Build.Utilities.Core
Any ideas what I've missed? The goal is to have build server to be as light as possible so don't want to install Visual Studio or SSDT on it.
Here's the full output from MsBuild:
Microsoft (R) Build Engine version 4.6.1586.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 18/01/2017 17:00:19.
Project "D:\Jenkins\workspace\hcg\database.solution\database.solution.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Project "D:\Jenkins\workspace\hcg\database.solution\database.solution.sln" (1) is building "D:\Jenkins\workspace\hcg\database.solution\database.solution\database.solution.sqlproj" (2) on node 1 (default targets).
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(983,5): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [D:\Jenkins\workspace\hcg\database.solution\database.solution\database.solution.sqlproj]
GenerateSqlTargetFrameworkMoniker:
Skipping target "GenerateSqlTargetFrameworkMoniker" because all output files are up-to-date with respect to the input files.
CoreCompile:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:x64 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll /debug+ /debug:full /optimize- /out:obj\Debug\database.solution.dll /subsystemversion:6.00 /target:library /warnaserror- /utf8output "C:\Users\svc_jenkins\AppData\Local\Temp\.NETFramework,Version=v4.5.2.SqlClrAttributes.cs"
D:\Nuget\Microsoft.Data.Tools.Msbuild\lib\net40\Microsoft.Data.Tools.Schema.SqlTasks.targets(477,5): error MSB4062: The "SqlModelResolutionTask" task could not be loaded from the assembly D:\Nuget\Microsoft.Data.Tools.Msbuild\lib\net40\Microsoft.Data.Tools.Schema.Tasks.Sql.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\Jenkins\workspace\hcg\database.solution\database.solution\database.solution.sqlproj]
Done Building Project "D:\Jenkins\workspace\hcg\database.solution\database.solution\database.solution.sqlproj" (default targets) -- FAILED.
Done Building Project "D:\Jenkins\workspace\hcg\database.solution\database.solution.sln" (default targets) -- FAILED.
Build FAILED.
"D:\Jenkins\workspace\hcg\database.solution\database.solution.sln" (default target) (1) ->
"D:\Jenkins\workspace\hcg\database.solution\database.solution\database.solution.sqlproj" (default target) (2) ->
(GetReferenceAssemblyPaths target) ->
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(983,5): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [D:\Jenkins\workspace\hcg\database.solution\database.solution\database.solution.sqlproj]
"D:\Jenkins\workspace\hcg\database.solution\database.solution.sln" (default target) (1) ->
"D:\Jenkins\workspace\hcg\database.solution\database.solution\database.solution.sqlproj" (default target) (2) ->
(_SetupSqlBuildInputs target) ->
D:\Nuget\Microsoft.Data.Tools.Msbuild\lib\net40\Microsoft.Data.Tools.Schema.SqlTasks.targets(477,5): error MSB4062: The "SqlModelResolutionTask" task could not be loaded from the assembly D:\Nuget\Microsoft.Data.Tools.Msbuild\lib\net40\Microsoft.Data.Tools.Schema.Tasks.Sql.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\Jenkins\workspace\hcg\database.solution\database.solution\database.solution.sqlproj]
1 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.51
Upvotes: 3
Views: 3136
Reputation: 3507
The SSDT NuGet package expects MSBuild version 14.0 Update 3 or newer (i.e. the 15.0 RC). That's available here: https://www.microsoft.com/en-us/download/details.aspx?id=48159
You'll also need to set some environment variables to reference the NuGet package location, like so:
setx SQLDBExtensionsRefPath C:\agent\Microsoft.Data.Tools.Msbuild\lib\net40 /M
setx SSDTPath C:\agent\Microsoft.Data.Tools.Msbuild\lib\net40 /M
Reference link: https://blogs.msdn.microsoft.com/ssdt/2016/08/22/releasing-ssdt-with-visual-studio-15-preview-4-and-introducing-ssdt-msbuild-nuget-package/
Upvotes: 5