为什么我的 Azure Pipeline 作业失败时出现错误 NU1101?

问题描述 投票:0回答:1

我正在 Azure DevOps 中运行 CDCI 管道,最近我的管道作业开始出现以下错误而失败。

##[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

除上述情况外,还有与资源位置有关的错误。

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.

我在这里注意到的是,它正在寻找在: Microsoft Visual Studio Offline Packages 我不知道为什么,也不知道这是否可以接受。 本地的解决方案构建得很好,只是当我们试图在管道上构建时,才会出现这些错误。 研究这个错误带来了几个选项,但都没有成功。

  • 我试过的第一件事是清除我的包缓存并更新mysources,但没有任何改变。
  • 然后我又更新了这些资源,但同样没有任何改变。

我的应用程序使用的是 .NET Core 3.1.101 并且是完全最新的。 我定义了三个包源。NuGet, Microsoft Visual Studio OfflineTelerik.

Package Sources

这是我的 nuget.config 文件。

<?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>

我的管道,是我不久前建立的,也是可能会出现问题的地方,是这样的,我很乐意接受反馈。

# 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)'

所以,一个令人沮丧的问题,我无法确定, 希望有人能帮助我找到问题的根源。

更新

只是为了给我的问题增加一些额外的背景,我的解决方案分为 MyProject.Repo, MyProject.Services, MyProject.DataMyProject.UI.

就这些目标框架而言,它们如下。

  • MyProject.Repo(类库)--.NET标准2.1。
  • MyProject.Services(类库)--.NET Standard 2.1。
  • MyProject.Data(类库)--.NET Standard 2.1。
  • MyProject.UI - .NET Core 3.1

构建失败的工作 DotNetCoreCLI

enter image description here

asp.net-core azure-devops continuous-integration azure-pipelines
1个回答
1
投票

错误NU1101:无法找到包Microsoft.AspNetCore.Mvc.Core。在源码中没有与此id相关的包。Microsoft Visual Studio Offline Packages。

根据错误信息,在 Private Nuget 资源中找不到该包。这些包存在于 nuget.org.

为此,你可以尝试添加 "dotnet restore "任务。之前 "dotnet publish "任务。 然后你可以在任务中引用nuget.config文件。

例如:"点网发布 "任务。

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

希望能帮到你

© www.soinside.com 2019 - 2024. All rights reserved.