我正在 Azure DevOps 中运行 CD/CI 管道,最近我的管道作业开始失败并出现以下错误:
##[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
对于这些包,我不确定为什么或者这是否可以接受。本地解决方案构建良好,只有在我们尝试在管道上构建时才会发生这些错误。研究错误带来了几个选项,但都没有奏效。来源,这并没有改变任何东西。
我的应用程序正在使用
.NET Core 3.1.101
并且完全是最新的。我定义了三个包源,NuGet
, Microsoft Visual Studio Offline
, 和 Telerik
.这是我的
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.Data
和 MyProject.UI
.就这些目标框架而言,它们如下:
构建在工作中失败
DotNetCoreCLI
最佳答案
error NU1101: Unable to find package Microsoft.AspNetCore.Mvc.Core. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages.
根据错误消息,在 Private Nuget 资源中找不到该包。这些包存在于 nuget.org .
为此,您可以尝试添加“dotnet restore”任务 之前 “dotnet 发布”任务。然后你可以在任务中引用 nuget.config 文件。
例如:
- task: DotNetCoreCLI@2
displayName: 'dotnet restore'
inputs:
command: restore
projects: '**/*.csproj'
feedsToUse: config
nugetConfigPath: 'nuget.config'
希望这可以帮助。
关于asp.net-core - 为什么我的 Azure Pipeline 作业失败并显示错误 NU1101?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61866257/