Azure Devops failing to build sql server database project

Copper Contributor

I have a sql database project in Visual Studio (2019). I am trying to deploy it via azure devops.

 

The pipeline is failing due to the below error:

 

 

##[error]C:\azagent\A1_work\r1\a_Transcripts-SQLDeployment\SampleDatabaseProject\SampleDatabaseProject\
SampleDatabaseProject.sqlproj(117,3): Error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.
Data.Tools.Schema.SqlTasks.targets" was not found. 
Confirm that the path in the declaration is correct, and that the file exists on disk

 

The project builds without issue on my pc. In the pipeline I have tried both the MSBuild and Visual Studio Build tasks, but the result is the same in each case.


In the sqlproj file xml, i can see reference to ssdt, but I'm not sure what to alter here to allow this to build in azure devops:

 

<SSDTExists Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\
Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExists> 
<VisualStudioVersion Condition="'$(SSDTExists)' == ''">11.0</VisualStudioVersion> </PropertyGroup> 
<Import Condition="'$(SQLDBExtensionsRefPath)' != ''" Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets" /> 

<Import Condition="'$(SQLDBExtensionsRefPath)' == ''" Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" /> <ItemGroup> 

 

Its clear that MSBuild in azure devops cannot see the ssdt dll's, but i dont know how to resolve this problem.


Appreciate any advice.

 

 

 

3 Replies

Hello @wilson_smyth  I have the same problem,  Did you resolve it?

@sebasmoreno14 
Hi.

I didnt find an exact fix, but i got round the issue.

instead of doing the build in the release pipeline i do it in the build pipeline. for some reason it works without issue in there.

Hi !@wilson_smyth Thanks  very much for the reply.

 

After fight a little bit with all this problem I could resolve it with the next steps (I hope it helps someone):

 

  1. Create a build Pipeline with the next set of tasks, this pipeline is responsible about generate the build of the solution in which you can find the project of type “Database SQL Server Project”,  This build will generate the artifact DACPAC.   

sebasmoreno14_0-1638395925717.png

2. In my release Pipeline I put one task of type  Azure SQL DacpacTask, in this task you have to configure the target database the  .dacpac file (generate in the build - step  1.)   

 

sebasmoreno14_1-1638395989289.png

 

sebasmoreno14_2-1638396041692.pngsebasmoreno14_3-1638396050386.png