My AzureDevOps YML Looks like this:
- 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 is Nuget Package hosted at nuget.org : https://www.nuget.org/packages/EnterpriseLibrary.Logging/
My Nuget.config that is used by azure dev ops does have the entry:
Restore Solution works fine:
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.
Build Works fine
During Dot Net Test run , when it's trying to restore .Net Core 3.1 Tests, it fails to restore the same library from nuget.org. it's trying to access other private feeds and fails with 401 unauthorized error
--- : hiding our domain for privacy purposes.
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
My Nuget.config that is used to restore solution contains link to 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>
even in debug mode, during dotnet test run ,it never shows it tried to access nuget.org to restore Enterpriselibrary.common
Please help, i have tried almost all the solutions but the test project still fails
thanks