Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my Azure Pipeline job failing with error NU1101?

I'm running a CD/CI Pipeline in Azure DevOps and recently my pipeline jobs have begun to fail with the following errors:

##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
##[warning]Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x (3.0 and 3.1) SDK/Runtime along with 2.1.
Unless you have locked down a SDK version for your project(s), 3.x SDK
might be picked up which might have breaking behavior as compared to
previous versions. 
Some commonly encountered changes are: 
If you're using `Publish` command with -o or --Output argument, you will see that the output folder is now being created at root
directory rather than Project File's directory. 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#troubleshooting
##[error]Dotnet command failed with non-zero exit code on the following projects : D:\a\1\s\MyProject\MyProject.UI.csproj

As well as the above, there are errors pertaining to the location of resources:

D:\a\1\s\MyProject.Repo\MyProject.Repo.csproj : warning NU1603: System.Memory 4.5.1 depends on System.Buffers (>= 4.4.0) but System.Buffers 4.4.0 was not found. An approximate best match of System.Buffers 4.5.0 was resolved. [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Services\MyProject.Services.csproj : warning NU1603: System.Memory 4.5.1 depends on System.Buffers (>= 4.4.0) but System.Buffers 4.4.0 was not found. An approximate best match of System.Buffers 4.5.0 was resolved. [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Repo\MyProject.Repo.csproj : warning NU1603: System.Net.WebSockets.WebSocketProtocol 4.5.1 depends on System.Buffers (>= 4.4.0) but System.Buffers 4.4.0 was not found. An approximate best match of System.Buffers 4.5.0 was resolved. [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Services\MyProject.Services.csproj : warning NU1603: System.Net.WebSockets.WebSocketProtocol 4.5.1 depends on System.Buffers (>= 4.4.0) but System.Buffers 4.4.0 was not found. An approximate best match of System.Buffers 4.5.0 was resolved. [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Repo\MyProject.Repo.csproj : warning NU1603: System.Memory 4.5.1 depends on System.Numerics.Vectors (>= 4.4.0) but System.Numerics.Vectors 4.4.0 was not found. An approximate best match of System.Numerics.Vectors 4.5.0 was resolved. [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Repo\MyProject.Repo.csproj : warning NU1603: System.Net.WebSockets.WebSocketProtocol 4.5.1 depends on System.Numerics.Vectors (>= 4.4.0) but System.Numerics.Vectors 4.4.0 was not found. An approximate best match of System.Numerics.Vectors 4.5.0 was resolved. [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Services\MyProject.Services.csproj : warning NU1603: System.Memory 4.5.1 depends on System.Numerics.Vectors (>= 4.4.0) but System.Numerics.Vectors 4.4.0 was not found. An approximate best match of System.Numerics.Vectors 4.5.0 was resolved. [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Repo\MyProject.Repo.csproj : warning NU1603: System.Threading.Channels 4.5.0 depends on System.Threading.Tasks.Extensions (>= 4.5.0) but System.Threading.Tasks.Extensions 4.5.0 was not found. An approximate best match of System.Threading.Tasks.Extensions 4.5.1 was resolved. [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Services\MyProject.Services.csproj : warning NU1603: System.Net.WebSockets.WebSocketProtocol 4.5.1 depends on System.Numerics.Vectors (>= 4.4.0) but System.Numerics.Vectors 4.4.0 was not found. An approximate best match of System.Numerics.Vectors 4.5.0 was resolved. [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Services\MyProject.Services.csproj : warning NU1603: System.Threading.Channels 4.5.0 depends on System.Threading.Tasks.Extensions (>= 4.5.0) but System.Threading.Tasks.Extensions 4.5.0 was not found. An approximate best match of System.Threading.Tasks.Extensions 4.5.1 was resolved. [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Services\MyProject.Services.csproj : error NU1101: Unable to find package Azure.Storage.Blobs. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Services\MyProject.Services.csproj : error NU1101: Unable to find package Microsoft.Azure.KeyVault.Core. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Services\MyProject.Services.csproj : error NU1101: Unable to find package WindowsAzure.Storage. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Services\MyProject.Services.csproj : error NU1101: Unable to find package Microsoft.AspNetCore.Hosting. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Services\MyProject.Services.csproj : error NU1101: Unable to find package Microsoft.AspNetCore.Mvc.Core. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Services\MyProject.Services.csproj : error NU1101: Unable to find package Microsoft.EntityFrameworkCore.SqlServer. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Services\MyProject.Services.csproj : error NU1101: Unable to find package Microsoft.AspNetCore.SignalR.Client. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Services\MyProject.Services.csproj : error NU1101: Unable to find package SixLabors.ImageSharp. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Repo\MyProject.Repo.csproj : error NU1101: Unable to find package Microsoft.AspNetCore.SignalR.Client. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Repo\MyProject.Repo.csproj : error NU1101: Unable to find package Microsoft.EntityFrameworkCore.SqlServer. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Repo\MyProject.Repo.csproj : error NU1101: Unable to find package Microsoft.EntityFrameworkCore.Tools. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Repo\MyProject.Repo.csproj : error NU1101: Unable to find package SixLabors.ImageSharp. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Repo\MyProject.Repo.csproj : error NU1101: Unable to find package Microsoft.AspNetCore.Hosting. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Repo\MyProject.Repo.csproj : error NU1101: Unable to find package Microsoft.AspNetCore.Mvc.Core. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
D:\a\1\s\MyProject.Repo\MyProject.Repo.csproj : error NU1101: Unable to find package WindowsAzure.Storage. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\1\s\MyProject\MyProject.UI.csproj]
  Restore failed in 3.8 sec for D:\a\1\s\MyProject.Repo\MyProject.Repo.csproj.
  Restore failed in 3.8 sec for D:\a\1\s\MyProject.Services\MyProject.Services.csproj.
  Restore completed in 1.07 min for D:\a\1\s\MyProject.Data\MyProject.Data.csproj.
  Restore completed in 1.13 min for D:\a\1\s\MyProject\MyProject.UI.csproj.

What I'm noticing here is that it's looking in Microsoft Visual Studio Offline Packages for these packages and I'm not sure why or if that's acceptable or not. Locally the solution builds fine, it's only once we are trying to build on the pipeline that these errors occur. Researching the error brought around a couple of options but none have worked.

  • The first thing I tried was to clear my package cache and update my sources, that didn't change anything.
  • I then updated those sources but again, that didn't change anything.

My application is using .NET Core 3.1.101 and is fully up to date. I have three packages sources defined, NuGet, Microsoft Visual Studio Offline, and Telerik.

Package Sources

Here is my nuget.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
  <packageSources>
    <add key="NuGet" value="https://api.nuget.org/v3/index.json" />
    <add key="Telerik" value="https://nuget.telerik.com/nuget" />
    <add key="MyGet" value="https://www.myget.org/F/sixlabors/api/v3/index.json" />
  </packageSources>
<packageSourceCredentials>   
    <Telerik>
      <add key="Username" value="xxx" />
      <add key="ClearTextPassword" value="xxx" />
    </Telerik>
  </packageSourceCredentials>  
</configuration>

My pipeline, which I built a little while ago now and the one area that could be responsible for problems, looks like this, I'm happy to take feedback on this:

# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
  dotnetSdkVersion: '3.1.101'

steps:
- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    publishWebProjects: true
    arguments: '--configuration $(buildConfiguration) --output $(Build.artifactStagingDirectory)'
    zipAfterPublish: true

# Build and test ASP.NET Core projects targeting the full .NET Framework.
- task: UseNode@1

- task: PublishBuildArtifacts@1
  displayName: 'publish artifacts'
- task: NuGetToolInstaller@1

# Restore #
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'config'
    nugetConfigPath: 'MyProject/nuget.config'
    externalFeedCredentials: 'Telerik NuGet'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

So, a frustrating problem that I can't pin down, hopefully, someone can help me get to the bottom of it.

Update

Just to add some additional context to my question, my solution is separated into MyProject.Repo, MyProject.Services, MyProject.Data and MyProject.UI.

In terms of the target framework for these, they are as follows:

  • MyProject.Repo (Class Library) - .NET Standard 2.1
  • MyProject.Services (Class Library) - .NET Standard 2.1
  • MyProject.Data (Class Library) - .NET Standard 2.1
  • MyProject.UI - .NET Core 3.1

The build fails on the job DotNetCoreCLI

enter image description here

like image 646
Yanayaya Avatar asked May 18 '20 09:05

Yanayaya


People also ask

How do I enable debug mode in Azure pipeline?

To configure verbose logs for a single run, you can start a new build by choosing Run pipeline and selecting Enable system diagnostics, Run. To configure verbose logs for all runs, you can add a variable named system. debug and set its value to true .

How do I connect to Azure pipeline Service?

To authorize any pipeline to use the service connection, go to Azure Pipelines, open the Settings page, select Service connections, and enable the setting Allow all pipelines to use this connection option for the connection.


1 Answers

error NU1101: Unable to find package Microsoft.AspNetCore.Mvc.Core. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages.

According to the error message, the package couldn’t be found in Private Nuget resource. These packages exist in nuget.org.

For this, you can try to add a “dotnet restore” task before “dotnet publish” task. Then you could reference the nuget.config file in the task.

For example:

- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: restore
    projects: '**/*.csproj'
    feedsToUse: config
    nugetConfigPath: 'nuget.config'

Hope this helps.

like image 88
Kevin Lu-MSFT Avatar answered Oct 02 '22 07:10

Kevin Lu-MSFT