Azure DevOps VSTS .netcore 构建失败,但在我的 PC 上运行良好 [英] Azure DevOps VSTS .netcore build failing, but works fine on my PC

查看:17
本文介绍了Azure DevOps VSTS .netcore 构建失败,但在我的 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:a1sCBW.WebsiteCBW.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:a1sCBW.WebsiteCBW.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).)

软件包无法恢复

***************编辑我传递了基于 nuget 错误并将所有内容定位到我的 csproj 中的 2.1.5 版.现在我又回到了恢复错误.

***************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="Clientassetscontrolbyweb-logo.png" />
    <Content Include="Clientassetswebrelay_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="AreasIdentityServices" />
  </ItemGroup>

  <ItemGroup>
    <Content Update="Client\_ViewImports.cshtml">
      <Pack>$(IncludeRazorContentInPack)</Pack>
    </Content>
  </ItemGroup>


</Project>

**** 错误**

2018-10-08T14:44:09.2159846Z   Restoring packages for D:a1sCBW.WebsiteCBW.Website.csproj...
2018-10-08T14:44:09.7085782Z C:hostedtoolcachewindowsdncs1.0.4x64sdk1.0.4NuGet.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:a1sCBW.WebsiteCBW.Website.csproj]
2018-10-08T14:44:09.7094563Z C:hostedtoolcachewindowsdncs1.0.4x64sdk1.0.4NuGet.targets(97,5): error :   - net461 (.NETFramework,Version=v4.6.1) [D:a1sCBW.WebsiteCBW.Website.csproj]
2018-10-08T14:44:09.7099570Z C:hostedtoolcachewindowsdncs1.0.4x64sdk1.0.4NuGet.targets(97,5): error :   - netstandard2.0 (.NETStandard,Version=v2.0) [D:a1sCBW.WebsiteCBW.Website.csproj]
2018-10-08T14:44:09.7102618Z C:hostedtoolcachewindowsdncs1.0.4x64sdk1.0.4NuGet.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:a1sCBW.WebsiteCBW.Website.csproj]
2018-10-08T14:44:09.7103331Z C:hostedtoolcachewindowsdncs1.0.4x64sdk1.0.4NuGet.targets(97,5): error :   - net45 (.NETFramework,Version=v4.5) [D:a1sCBW.WebsiteCBW.Website.csproj]
2018-10-08T14:44:09.7103534Z C:hostedtoolcachewindowsdncs1.0.4x64sdk1.0.4NuGet.targets(97,5): error :   - netstandard2.0 (.NETStandard,Version=v2.0) [D:a1sCBW.WebsiteCBW.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:a1Nuget	empNuGet_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:hostedtoolcachewindowsdncs1.0.4x64dotnet.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/19YML 文件或编辑器与 .netcore SDK 版本存在相同的问题.我已经多次更新我的了.当核心 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆