【问题标题】:Azure DevOps Pipeline fail build as it can create folder to write the XML documentation fileAzure DevOps Pipeline 构建失败,因为它可以创建文件夹来写入 XML 文档文件
【发布时间】:2021-05-07 16:11:28
【问题描述】:

我有一个带有 swaggerUI 的 .NET 3.1 Web api 项目。在发布此项目期间,我已设置它必须生成 XML 文档,以便 Swagger 可以显示我为每个端点插入的 cmets、返回的对象等...

然后我在 Azure DevOps 中创建了一个管道,以在主分支上触发更改时自动运行构建,但我收到以下错误:


  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)

我还在错误消息中看到它谈论 .Net 5,"C:\Program Files\dotnet\sdk\5.0.102..." 但我已经指定了网络核心 3.1。 这是 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

【问题讨论】:

    标签: c# .net-core azure-devops yaml


    【解决方案1】:

    通过修改.csproj文件中documentfile部分的路径解决。

    设置为“.\documentation-file-name.xml”解决了错误

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-26
      • 2021-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多