Azure DevOps VSTS .netcore构建失败,但在我的PC上运行正常 [英] Azure DevOps VSTS .netcore build failing, but works fine on my PC
问题描述
我在.net core2.1.1 MVC网站中不断收到依赖项错误.它可以从我的PC上正常运行.但是Azure DevOps无法正确编译参考.
I keep getting dependencies errors in my .net core2.1.1 MVC website. It builds fine from my PC. but Azure DevOps is not compiling refrences properly.
添加一些图片以帮助解决此问题.
DevOps错误.在将更新nuget添加到最新的
nuget命令失败,并显示退出代码(1)和错误(NU1607:检测到Microsoft.Extensions.DependencyInjection.Abstractions的版本冲突.直接从项目中引用该软件包即可解决此问题. CBW.Website(> = 1.0.0)-> Microsoft.VisualStudio.Web.CodeGeneration.Design(> = 2.1.5)-> Microsoft.VisualStudio.Web.CodeGenerators.Mvc(> = 2.1.5)-> Microsoft. VisualStudio.Web.CodeGeneration(> = 2.1.5)-> Microsoft.Extensions.DependencyInjection(> = 2.1.1)-> Microsoft.Extensions.DependencyInjection.Abstractions(> = 2.1.1) CBW.Website(> = 1.0.0)-> Microsoft.AspNetCore.App(> = 2.1.0)-> Microsoft.Extensions.DependencyInjection.Abstractions(> = 2.1.0). D:\ a \ 1 \ s \ CBW.Website \ CBW.Website.csproj中的错误 NU1607:为Microsoft.Extensions.DependencyInjection.Abstractions检测到版本冲突.直接从项目中引用该软件包以解决此问题. CBW.Website(> = 1.0.0)-> Microsoft.VisualStudio.Web.CodeGeneration.Design(> = 2.1.5)-> Microsoft.VisualStudio.Web.CodeGenerators.Mvc(> = 2.1.5)-> Microsoft. VisualStudio.Web.CodeGeneration(> = 2.1.5)-> Microsoft.Extensions.DependencyInjection(> = 2.1.1)-> Microsoft.Extensions.DependencyInjection.Abstractions(> = 2.1.1) CBW.Website(> = 1.0.0)-> Microsoft.AspNetCore.App(> = 2.1.0)-> Microsoft.Extensions.DependencyInjection.Abstractions(> = 2.1.0).)
The nuget command failed with exit code(1) and error(NU1607: Version conflict detected for Microsoft.Extensions.DependencyInjection.Abstractions. Reference the package directly from the project to resolve this issue. CBW.Website (>= 1.0.0) -> Microsoft.VisualStudio.Web.CodeGeneration.Design (>= 2.1.5) -> Microsoft.VisualStudio.Web.CodeGenerators.Mvc (>= 2.1.5) -> Microsoft.VisualStudio.Web.CodeGeneration (>= 2.1.5) -> Microsoft.Extensions.DependencyInjection (>= 2.1.1) -> Microsoft.Extensions.DependencyInjection.Abstractions (>= 2.1.1) CBW.Website (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.Extensions.DependencyInjection.Abstractions (>= 2.1.0). Errors in D:\a\1\s\CBW.Website\CBW.Website.csproj NU1607: Version conflict detected for Microsoft.Extensions.DependencyInjection.Abstractions. Reference the package directly from the project to resolve this issue. CBW.Website (>= 1.0.0) -> Microsoft.VisualStudio.Web.CodeGeneration.Design (>= 2.1.5) -> Microsoft.VisualStudio.Web.CodeGenerators.Mvc (>= 2.1.5) -> Microsoft.VisualStudio.Web.CodeGeneration (>= 2.1.5) -> Microsoft.Extensions.DependencyInjection (>= 2.1.1) -> Microsoft.Extensions.DependencyInjection.Abstractions (>= 2.1.1) CBW.Website (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.Extensions.DependencyInjection.Abstractions (>= 2.1.0).)
包还原失败
***************编辑 我根据csproj中的版本2.1.5传递了nuget错误,并将所有错误都定位为该错误.现在我回到还原错误.
***************Edit I passed the nuget errors based on and targeting the everything to version 2.1.5 in my csproj. Now I am back to the restore error.
我的Csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>
<UserSecretsId>aspnet-AspNetCorePagesIdentity-***************-***-*******-</UserSecretsId>
<TypeScriptToolsVersion>3.0</TypeScriptToolsVersion>
<AutoGenerateBindingRedirects>True</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Content Include="Client\assets\controlbyweb-logo.png" />
<Content Include="Client\assets\webrelay_170.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.5" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.5" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<Folder Include="Areas\Identity\Services\" />
</ItemGroup>
<ItemGroup>
<Content Update="Client\_ViewImports.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
</ItemGroup>
</Project>
****错误**
2018-10-08T14:44:09.2159846Z Restoring packages for D:\a\1\s\CBW.Website\CBW.Website.csproj...
2018-10-08T14:44:09.7085782Z C:\hostedtoolcache\windows\dncs\1.0.4\x64\sdk\1.0.4\NuGet.targets(97,5): error : Package Microsoft.VisualStudio.Web.CodeGeneration.Design 2.1.5 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.VisualStudio.Web.CodeGeneration.Design 2.1.5 supports: [D:\a\1\s\CBW.Website\CBW.Website.csproj]
2018-10-08T14:44:09.7094563Z C:\hostedtoolcache\windows\dncs\1.0.4\x64\sdk\1.0.4\NuGet.targets(97,5): error : - net461 (.NETFramework,Version=v4.6.1) [D:\a\1\s\CBW.Website\CBW.Website.csproj]
2018-10-08T14:44:09.7099570Z C:\hostedtoolcache\windows\dncs\1.0.4\x64\sdk\1.0.4\NuGet.targets(97,5): error : - netstandard2.0 (.NETStandard,Version=v2.0) [D:\a\1\s\CBW.Website\CBW.Website.csproj]
2018-10-08T14:44:09.7102618Z C:\hostedtoolcache\windows\dncs\1.0.4\x64\sdk\1.0.4\NuGet.targets(97,5): error : Package Microsoft.AspNet.WebApi.Client 5.2.6 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.AspNet.WebApi.Client 5.2.6 supports: [D:\a\1\s\CBW.Website\CBW.Website.csproj]
2018-10-08T14:44:09.7103331Z C:\hostedtoolcache\windows\dncs\1.0.4\x64\sdk\1.0.4\NuGet.targets(97,5): error : - net45 (.NETFramework,Version=v4.5) [D:\a\1\s\CBW.Website\CBW.Website.csproj]
2018-10-08T14:44:09.7103534Z C:\hostedtoolcache\windows\dncs\1.0.4\x64\sdk\1.0.4\NuGet.targets(97,5): error : - netstandard2.0 (.NETStandard,Version=v2.0) [D:\a\1\s\CBW.Website\CBW.Website.csproj]
2018-10-08T14:44:09.7103694Z Package Microsoft.Extensions.WebEncoders 2.1.1 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.Extensions.WebEncoders 2.1.1 supports: netstandard2.0 (.NETStandard,Version=v2.0)
2018-10-08T14:44:10.0475303Z Package Microsoft.Net.Http.Headers 2.1.1 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.Net.Http.Headers 2.1.1 supports: netstandard2.0 (.NETStandard,Version=v2.0)
2018-10-08T14:44:10.0475426Z Package Microsoft.VisualStudio.Web.CodeGenerators.Mvc 2.1.5 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.VisualStudio.Web.CodeGenerators.Mvc 2.1.5 supports: netstandard2.0 (.NETStandard,Version=v2.0)
2018-10-08T14:44:10.0475562Z One or more packages are incompatible with .NETCoreApp,Version=v2.1.
2018-10-08T14:44:10.0475666Z
2018-10-08T14:44:10.0475771Z NuGet Config files used:
2018-10-08T14:44:10.0475909Z D:\a\1\Nuget\tempNuGet_13.config
2018-10-08T14:44:10.0476013Z
2018-10-08T14:44:10.0476113Z Feeds used:
2018-10-08T14:44:10.0476241Z https://api.nuget.org/v3/index.json
2018-10-08T14:44:10.1010270Z ##[error]Error: C:\hostedtoolcache\windows\dncs\1.0.4\x64\dotnet.exe failed with return code: 1
2018-10-08T14:44:10.1032411Z ##[error]Packages failed to restore
2018-10-08T14:44:10.1055895Z ##[section]Finishing: Restore
推荐答案
已解决 编辑7/5/19 .netcore SDK版本的YML文件或编辑器存在相同的问题.我已经多次更新了我的.当核心SDK团队将更新推送到Nuget,或者您有时更新VS时,它将随机中断.我的构建是自动的,并且在0代码更改后,它今天和明天都无法使用.但是我总是回到此修复程序,然后再次构建.
Solved it Edit 7/5/19 The YML file or the editor has the same issue with the .netcore SDK version. I have updated mine multiple times now. It will break randomly when the core SDK team pushes updates to Nuget, or you update VS or sometimes.. My builds are automated and it works today and tomorrow it does not, after 0 code changes. But I always come back to this fix and then it builds again.
在VS2017中获取SDK版本
Get your SDK version in VS2017
在DevOps中设置您的版本
Set your version in DevOps
这篇关于Azure DevOps VSTS .netcore构建失败,但在我的PC上运行正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!