我的 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 Test 运行期间,当它尝试恢复 .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
请帮忙,我已经尝试了几乎所有的解决方案,但测试项目仍然失败
谢谢