使用 Azure DevOps 任务构建使用外部包源的 .Net 核心应用程序

问题描述 投票:0回答:1

使用 Azure DevOps 任务,我正在尝试构建使用外部包源的 .net 核心应用程序,如下所述

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <clear />
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
        <add key="Public" value="https://microsofthealthoss.pkgs.visualstudio.com/FhirServer/_packaging/Public/nuget/v3/index.json" />
        <add key="local" value="./lib" />
    </packageSources>
</configuration>

我定义了以下任务

        - task: NuGetCommand@2
          displayName: 'NuGet restore'
          inputs:
            restoreSolution: '**\*.sln'
            feedsToUse: config
            nugetConfigPath: 'NuGet.config'
        - task: DotNetCoreCLI@2
          displayName: "Restore dotnet packages"
          inputs:
            command: restore
            projects: "**/*.csproj"
            feedsToUse: 'config'
            nugetConfigPath: 'NuGet.config'
        - task: DotNetCoreCLI@2
          displayName: "Build with Development configuration"
          inputs:
            projects: "**/ProductX.HIS.WebApi/**/*.csproj"
            arguments: "--configuration Development"

抛出以下错误

Build FAILED.

       "/home/vsts/work/1/s/lib/FHIR-Converter-main/src/Microsoft.Health.Fhir.Liquid.Converter/Microsoft.Health.Fhir.Liquid.Converter.csproj" (Restore target) (1) ->
       (Restore target) -> 
         /home/vsts/work/1/s/lib/FHIR-Converter-main/src/Microsoft.Health.Fhir.Liquid.Converter/Microsoft.Health.Fhir.Liquid.Converter.csproj : error NU1301: The local source '/home/vsts/work/1/Nuget/lib' doesn't exist.
         /home/vsts/work/1/s/lib/FHIR-Converter-main/src/Microsoft.Health.Fhir.Liquid.Converter/Microsoft.Health.Fhir.Liquid.Converter.csproj : error NU1301: The local source '/home/vsts/work/1/Nuget/lib' doesn't exist.
         /home/vsts/work/1/s/lib/FHIR-Converter-main/src/Microsoft.Health.Fhir.Liquid.Converter/Microsoft.Health.Fhir.Liquid.Converter.csproj : error NU1301: The local source '/home/vsts/work/1/Nuget/lib' doesn't exist.
         /home/vsts/work/1/s/lib/FHIR-Converter-main/src/Microsoft.Health.Fhir.Liquid.Converter/Microsoft.Health.Fhir.Liquid.Converter.csproj : error NU1301: The local source '/home/vsts/work/1/Nuget/lib' doesn't exist.
         /home/vsts/work/1/s/lib/FHIR-Converter-main/src/Microsoft.Health.Fhir.Liquid.Converter/Microsoft.Health.Fhir.Liquid.Converter.csproj : error NU1301: The local source '/home/vsts/work/1/Nuget/lib' doesn't exist.
         /home/vsts/work/1/s/lib/FHIR-Converter-main/src/Microsoft.Health.Fhir.Liquid.Converter/Microsoft.Health.Fhir.Liquid.Converter.csproj : error NU1301: The local source '/home/vsts/work/1/Nuget/lib' doesn't exist.
         /home/vsts/work/1/s/lib/FHIR-Converter-main/src/Microsoft.Health.Fhir.Liquid.Converter/Microsoft.Health.Fhir.Liquid.Converter.csproj : error NU1301: The local source '/home/vsts/work/1/Nuget/lib' doesn't exist.
         /home/vsts/work/1/s/lib/FHIR-Converter-main/src/Microsoft.Health.Fhir.Liquid.Converter/Microsoft.Health.Fhir.Liquid.Converter.csproj : error NU1301: The local source '/home/vsts/work/1/Nuget/lib' doesn't exist.

    0 Warning(s)
    8 Error(s)

我在 Azure DevOps Repo 中有 lib 文件夹,如下所示

我该如何解决这个问题?

asp.net-core azure-devops azure-pipelines azure-pipelines-release-pipeline azure-pipelines-yaml
1个回答
0
投票

我已经使用以下任务来解决这个问题

    strategy:
      runOnce:
        deploy:
          steps:
            - checkout: self
            - task: CopyFiles@2
              inputs:
                SourceFolder: '$(System.DefaultWorkingDirectory)/lib'
                Contents: '**'
                TargetFolder: '$(Agent.BuildDirectory)/Nuget/lib'
                OverWrite: true
            - task: DotNetCoreCLI@2
              displayName: "Restore dotnet packages"
              inputs:
                command: restore
                projects: "**/*.csproj"
                feedsToUse: 'config'
                nugetConfigPath: 'NuGet.config'
            - task: DotNetCoreCLI@2
              displayName: "Build with Development configuration"
              inputs:
                projects: "**/ProjectX.WebApi/**/*.csproj"
                arguments: "--configuration Development"
© www.soinside.com 2019 - 2024. All rights reserved.