【问题标题】:Dot net test fails to restore EnterpriseLibrary.Logging Nuget in Azure DevOps点网测试无法在 Azure DevOps 中恢复 EnterpriseLibrary.Logging Nuget
【发布时间】:2021-08-23 19:40:30
【问题描述】:

我的 AzureDevOps YML 如下所示:

- task: NuGetCommand@2
      displayName: "Restore Test Solution"
      inputs:
        restoreSolution: $(Build.SourcesDirectory)\TestSln\*.sln
        feedsToUse: config
        nugetConfigPath: NuGet.config
        allowPackageConflicts: true
        includeNuGetOrg: true

    - task: VSBuild@1
      displayName: 'Build Test Solution'
      inputs:
        solution: $(Build.SourcesDirectory)\TestSln\*.sln
        platform: x64
        configuration: $(buildConfiguration)
        clean: false

    - task: DotNetCoreCLI@2
      inputs:
        command: 'test'
        projects: |
          $(Build.SourcesDirectory)\TestSln\**\*.csproj
        arguments: '--filter TestCategory=RunOnServerBuild'
        testRunTitle: 'TestSln Dot Net Test'

EnterpriseLibrary.Logging 是托管在 nuget.org 上的 Nuget 包:https://www.nuget.org/packages/EnterpriseLibrary.Logging/

我的 azure dev ops 使用的 Nuget.config 确实有以下条目:

恢复解决方案工作正常:

2021-08-19T13:43:51.5771525Z WARNING: NU1603: EnterpriseLibrary.Logging 6.0.1304 depends on EnterpriseLibrary.Common (>= 6.0.0) but EnterpriseLibrary.Common 6.0.0 was not found. An approximate best match of EnterpriseLibrary.Common 6.0.1304 was resolved.

构建工作正常

在 Dot Net 测试运行期间,当它尝试恢复 .Net Core 3.1 测试时,它无法从 nuget.org 恢复相同的库。它正在尝试访问其他私人提要并失败并出现 401 未经授权的错误

--- :出于隐私目的隐藏我们的域。

2021-08-19T13:45:58.9657200Z   Restored D:\a\1\s\TestSln\SomeProject\SomeProject.csproj (in 609 ms).
2021-08-19T13:45:58.9658040Z   Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/---/_packaging/428bdd6d-11e8-4a49-b9c9-63fec137af86/nuget/v3/flat2/enterpriselibrary.common/index.json'.
2021-08-19T13:45:58.9659145Z   Response status code does not indicate success: 401 (Unauthorized).
2021-08-19T13:45:58.9660077Z   Retrying 'FindPackagesByIdAsync' for source 'https://pkgs.dev.azure.com/---/_packaging/428bdd6d-11e8-4a49-b9c9-63fec137af86/nuget/v3/flat2/enterpriselibrary.common/index.json'.
2021-08-19T13:45:58.9661165Z   Response status code does not indicate success: 401 (Unauthorized).
2021-08-19T13:45:58.9662152Z C:\Program Files\dotnet\sdk\5.0.400\NuGet.targets(131,5): error : Failed to retrieve information about 'EnterpriseLibrary.Common' from remote source 'https://pkgs.dev.azure.com/---/_packaging/428bdd6d-11e8-4a49-b9c9-63fec137af86/nuget/v3/flat2/enterpriselibrary.common/index.json'. [D:\a\1\s\TestSln\SomeProject\SomeProject.csproj]
2021-08-19T13:45:58.9664792Z C:\Program Files\dotnet\sdk\5.0.400\NuGet.targets(131,5): error :   Response status code does not indicate success: 401 (Unauthorized). [D:\a\1\s\TestSln\SomeProject\SomeProject.csproj]
2021-08-19T13:45:59.0226475Z ##[debug]Exit code 1 received from tool 'C:\Program Files\dotnet\dotnet.exe'
2021-08-19T13:45:59.0444559Z ##[debug]STDIO streams have closed for tool 'C:\Program Files\dotnet\dotnet.exe'
2021-08-19T13:45:59.0458377Z ##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
2021-08-19T13:45:59.0459252Z ##[debug]Processed: ##vso[task.issue type=error;]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1

用于恢复解决方案的我的 Nuget.config 包含指向 nuget json 的链接

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageRestore>
        <!-- Allow NuGet to download missing packages -->
        <add key="enabled" value="True" />

        <!-- Automatically check for missing packages during build in Visual Studio -->
        <add key="automatic" value="True" />
    </packageRestore>
     
    <packageSources>
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
        <add key="PrivateFeed1" value="https://pkgs.dev.azure.com/---/_packaging/PrivateFeed1/nuget/v3/index.json" />
    <add key="PrivateFeed2" value="https://pkgs.dev.azure.com/---/_packaging/PrivateFeed2/nuget/v3/index.json" />
    </packageSources>
</configuration>

即使在调试模式下,在 dotnet 测试运行期间,它也从未显示它试图访问 nuget.org 以恢复 Enterpriselibrary.common

请帮忙,我已经尝试了几乎所有的解决方案,但测试项目仍然失败

谢谢

【问题讨论】:

    标签: azure-devops enterprise-library nuget-package-restore dotnet-test


    【解决方案1】:

    根据警告和错误消息,任务正在尝试恢复Enterpriselibrary.common 6.0.0

    您可以参考 Nuget Org 中的 nuget 包:EnterpriseLibrary.Common

    支持的版本是 6.0.1304 和 5.0.505。

    由于在 nuget.org 中找不到 6.0.0 包,所以他会在私人提要中查找。

    要解决此问题,您需要在项目中引用6.0.1304 的版本EnterpriseLibrary.Common

    然后任务将从 nuget.org 恢复包。

    【讨论】:

      猜你喜欢
      • 2020-06-27
      • 2019-08-17
      • 2019-10-30
      • 2022-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-21
      • 1970-01-01
      相关资源
      最近更新 更多