Azure DevOps Pipeline fail build as it can create folder to write the XML documentation file

Viewed 631

I have a .NET 3.1 web api project with swaggerUI. During the Publish of this project I've set that it must generate the XML documentation so Swagger can show the comments I've inserted for each endpoint, objects returned, etc...

Then I've created a pipeline in Azure DevOps to automatically run the build on trigger changes on the master branch, but I get the following error:


  Determining projects to restore...
  Restored D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj (in 48.44 sec).
C:\Program Files\dotnet\sdk\5.0.102\Microsoft.Common.CurrentVersion.targets(1129,5): warning MSB3191: Unable to create directory "E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\". Could not find a part of the path 'E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\'. [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
C:\Program Files\dotnet\sdk\5.0.102\Microsoft.Common.CurrentVersion.targets(1129,5): warning MSB4181: The "MakeDir" task returned false but did not log an error. [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
D:\a\1\s\XXX-DataBridges-API\Models\Context\ReportingContext.cs(58,10): warning CS1030: #warning: 'To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.' [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
CSC : error CS0016: Could not write to output file 'E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\XXX-DataBridges-API.xml' -- 'Could not find a part of the path 'E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\XXX-DataBridges-API.xml'.' [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]

Build FAILED.

C:\Program Files\dotnet\sdk\5.0.102\Microsoft.Common.CurrentVersion.targets(1129,5): warning MSB3191: Unable to create directory "E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\". Could not find a part of the path 'E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\'. [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
C:\Program Files\dotnet\sdk\5.0.102\Microsoft.Common.CurrentVersion.targets(1129,5): warning MSB4181: The "MakeDir" task returned false but did not log an error. [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
D:\a\1\s\XXX-DataBridges-API\Models\Context\ReportingContext.cs(58,10): warning CS1030: #warning: 'To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.' [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
CSC : error CS0016: Could not write to output file 'E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\XXX-DataBridges-API.xml' -- 'Could not find a part of the path 'E:\Progetti\XXX\Xyz-MyProjectName-PublicAPI\XXX-DataBridges-API\XXX-DataBridges-API.xml'.' [D:\a\1\s\XXX-DataBridges-API\XXX-DataBridges-API.csproj]
    3 Warning(s)
    1 Error(s)

I also see in the error message that it talks about .Net 5, "C:\Program Files\dotnet\sdk\5.0.102..." but I've specified that is Net Core 3.1. Here is the YAML:

trigger:
- master


pool:
  vmImage: 'windows-2019'

variables:
  buildConfiguration: 'Release'

steps:
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build'
  
- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    publishWebProjects: true
    zipAfterPublish: true
    arguments: '--output $(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts@1
  inputs:
    pathToPublish: $(Build.ArtifactStagingDirectory)
    artifactName: MyProject_Build
1 Answers

Solved by modifying the path of the documentfile section in .csproj file.

setting as ".\documentation-file-name.xml" solved the error

Related