We have an Azure DevOps nuget package that another service which is a net api uses without a problem. However, when this package is added to the worker service, pr pipeline fails at the "Restore Dependencies" step with NU1100 error.
Pipeline file
trigger: branches: exclude: - '*' paths: include: - '*'pr: branches: include: - '*'pool: vmImage: ubuntu-latestvariables: - name: vmImageName value: 'ubuntu-latest'stages: - stage: PR displayName: Build and test jobs: - job: Build displayName: Build pool: vmImage: $(vmImageName) steps: - task: UseDotNet@2 displayName: 'Install .NET Core SDK' inputs: packageType: 'sdk' version: '8.x' performMultiLevelLookup: true - task: NuGetToolInstaller@1 displayName: 'Install NuGet' inputs: versionSpec: '6.8.0' - task: NuGetAuthenticate@1 displayName: 'NuGet Authenticate' - task: DotNetCoreCLI@2 displayName: 'Restore Dependencies' inputs: command: 'restore' projects: '**/*.csproj' feedsToUse: 'config' nugetConfigPath: 'nuget.config' includeNuGetOrg: true noCache: true - task: DotNetCoreCLI@2 displayName: 'Build' inputs: command: 'build' projects: '**/*.csproj' arguments: '--configuration $(buildConfiguration) --no-restore' - job: Test displayName: Test pool: vmImage: $(vmImageName) steps: - task: NuGetAuthenticate@1 displayName: 'NuGet Authenticate' - task: DotNetCoreCLI@2 displayName: "Run Unit Tests" inputs: command: test projects: '**/*.UnitTests.csproj' arguments: '--configuration $(buildConfiguration)'
nuget.config:
<?xml version="1.0" encoding="utf-8"?><configuration><packageRestore><add key="enabled" value="True" /><add key="automatic" value="True" /></packageRestore><packageSources><clear /><add key="nuget.org" value="https://api.nuget.org/v3/index.json" /><add key="Custom" value="https://pkgs.dev.azure.com/acme/guid/_packaging/Custom/nuget/v3/index.json" /></packageSources><packageSourceCredentials><NxPro><add key="Username" value="build" /><add key="ClearTextPassword" value="%PAT%" /></NxPro></packageSourceCredentials><packageSourceMapping><packageSource key="Custom"><package pattern="Custom.*" /></packageSource><packageSource key="nuget.org"><package pattern="*" /></packageSource></packageSourceMapping></configuration>
error:
Build FAILED."/home/vsts/work/1/s/src/Infrastructure/ServiceWorker.Infrastructure.csproj" (Restore target) (1) -> (Restore target) -> /home/vsts/work/1/s/src/Infrastructure/ServiceWorker.Infrastructure.csproj : error NU1100: Unable to resolve 'Custom.Contracts (>= 1.0.31)' for 'net8.0'. PackageSourceMapping is enabled, the following source(s) were not considered: feed-Custom, nuget.org. 0 Warning(s) 1 Error(s)Time Elapsed 00:00:07.64##[error]Error: The process '/opt/hostedtoolcache/dotnet/dotnet' failed with exit code 1##[error]Packages failed to restoreInfo: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshootingFinishing: Restore Dependencies
The other service that uses the same package has a different pipline file where instead of DotNetCoreCli@2 restore NuGetCommand@2 is used. This approach for a reason that I couldn't understand didn't work with this service and kept ending up with MsBuild version error.