Search code examples
visual-studioazure-devopssql-server-data-toolsssdt-2019

Azure Devops - SSDT DB build error - writing model.xml


I get the following build error for my SSDT project in Azure DevOps:

System.IO.DirectoryNotFoundException: Could not find a part of the path 'd:\a\1\s\SSDTPROJECTNAME\SSDTPROJECTNAMEobj\Release\Model.xml'.

Earlier in the build it attempts to write the Model.xml file to an invalid path:

SqlBuild:
  Creating a model to represent the project...
    Loading project references...
    Loading project files...
    Building the project model and resolving object interdependencies...
    Validating the project model...
    Writing model to SSDTPROJECTNAMEobj\Release\Model.xml...

For some reason it fails to concatenate my project folder name with obj\Release\Model.xml. But when I build locally it writes the model.xml to a valid location. For the project folder I'm using a variable called $(projectDir) set to my project folder name.

I'm using VSBuild@1 with the windows-latest vmImage.

Here's my task:

- task: VSBuild@1
  displayName: "Build DB project"
    inputs:
      solution: "$(projectDir)\SSDTPROJECTNAME.sqlproj"
      msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:DeleteExistingFiles=True /p:PackageLocation="$(Build.ArtifactStagingDirectory)\\"'
      configuration: "$(BuildConfiguration)"
      clean: true

Solution

  • The 'projectDir' variable is preserved key word for VS Build. If you change to a different variable should fix the problem.

    https://learn.microsoft.com/en-us/cpp/build/reference/common-macros-for-build-commands-and-properties?view=vs-2019