Nuget还原对于构建服务器上的ASP.NET Core 2.0项目失败

编程入门 行业动态 更新时间:2024-10-24 21:23:53
本文介绍了Nuget还原对于构建服务器上的ASP.NET Core 2.0项目失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用Windows Server 2012R2上的TeamCity为.NET Framework 4.6.2(不是.NET Core)构建ASP.NET Core 2.0应用程序.

I am trying to build an ASP.NET Core 2.0 application for .NET Framework 4.6.2 (not .NET Core) with TeamCity on Windows Server 2012R2.

服务器中安装了以下组件:

The following components are installed in the server:

  • Microsoft .Net Core SDK-2.0.0.0
  • Microsoft .Net Framework(4.5.2,4.6,4.6.2)
  • Microsoft构建工具(2013、2015、2017)
  • Windows SDK 10.0
  • ...

TeamCity使用nuget版本4.1和解决方案文件来还原依赖程序包(有关详细信息,请参见下面的完整日志).

TeamCity uses nuget version 4.1 and the solution file to restore dependent packages (see full log below for details).

错误:

[22:57:51] [22:57:51]Errors in C:\path\to\project\Server\Server.csproj [22:57:51] Package Microsoft.AspNetCore 2.0.0 is not compatible with net462 (.NETFramework,Version=v4.6.2). Package Microsoft.AspNetCore 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51] Package Microsoft.AspNetCore.Mvc 2.0.0 is not compatible with net462 (.NETFramework,Version=v4.6.2). Package Microsoft.AspNetCore.Mvc 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51] One or more packages are incompatible with .NETFramework,Version=v4.6.2. [22:57:51] Package Microsoft.AspNetCore 2.0.0 is not compatible with net462 (.NETFramework,Version=v4.6.2) / win7-x86. Package Microsoft.AspNetCore 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51] Package Microsoft.AspNetCore.Mvc 2.0.0 is not compatible with net462 (.NETFramework,Version=v4.6.2) / win7-x86. Package Microsoft.AspNetCore.Mvc 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51] One or more packages are incompatible with .NETFramework,Version=v4.6.2 (win7-x86). [22:57:51] [22:57:51]Errors in C:\path\to\project\Server\Server.csproj [22:57:51] Package Microsoft.Extensions.FileProviders.Physical 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.Extensions.FileProviders.Physical 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51] Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51] One or more packages are incompatible with .NETCoreApp,Version=v2.0. [22:57:51]Process exited with code 1

问题:

我认为.NET Framework 4.6.2实现了.NET Standard 2.0,因此我不理解为什么这些软件包不兼容.在我的本地计算机上(使用Visual Studio 2017 Update 3(15.3)),nuget restore可以正常工作.

I thought that .NET Framework 4.6.2 implements .NET Standard 2.0, therefore I don't understand why the packages are incompatible. On my local machine (with Visual Studio 2017 Update 3 (15.3)) nuget restore works fine.

任何想法如何解决该错误/如何进一步分析问题?

Any ideas how to solve that error / how to further analyze the problem?

项目文件(包含nuget程序包):

Project File (containing the nuget packages):

<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net462</TargetFramework> </PropertyGroup> <ItemGroup> <Folder Include="wwwroot\" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" /> <PackageReference Include="Newtonsoft.Json" Version="10.0.3" /> </ItemGroup> <ItemGroup> <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\Server.Common\Server.Common.csproj" /> </ItemGroup> </Project>

完整日志输出

[Step 1/4] restore: Restoring NuGet packages for Server.sln (24s) [22:57:27][restore] NuGet command: C:\path\to\buildagent\tools\NuGet.CommandLine.4.1.0\tools\NuGet.exe restore C:\path\to\project\Server.sln [22:57:27][restore] Starting: C:\path\to\teamcity\temp\agentTmp\custom_script710236021428854.cmd [22:57:27][restore] in directory: C:\path\to\project [22:57:28][restore] MSBuild auto-detection: using msbuild version '15.3.409.57025' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin'. [22:57:31][restore] Alle in "packages.config" aufgef�hrten Pakete sind bereits installiert. [22:57:31][restore] Restoring packages for C:\path\to\project\Server\Server.csproj... [22:57:31][restore] Restoring packages for C:\path\to\project\Server\Server.csproj... [22:57:32][restore] GET api.nuget/v3-flatcontainer/microsoft.visualstudio.web.codegeneration.tools/index.json [22:57:32][restore] GET api.nuget/v3-flatcontainer/microsoft.aspnetcore.mvc/index.json [22:57:32][restore] GET api.nuget/v3-flatcontainer/microsoft.aspnetcore/index.json [...] [22:57:41][restore] OK api.nuget/v3-flatcontainer/microsoftcore.dotnetapphost/index.json 475ms [22:57:41][restore] GET api.nuget/v3-flatcontainer/microsoftcore.dotnetapphost/2.0.0/microsoftcore.dotnetapphost.2.0.0.nupkg [22:57:41][restore] OK api.nuget/v3-flatcontainer/microsoftcore.dotnetapphost/2.0.0/microsoftcore.dotnetapphost.2.0.0.nupkg 453ms [22:57:42][restore] Installing System.Xml.XmlSerializer 4.0.11. [22:57:42][restore] Installing System.Threading.Overlapped 4.0.1. [22:57:42][restore] Installing System.Security.Principal 4.0.1. [22:57:42][restore] Installing System.Dynamic.Runtime 4.0.11. [22:57:42][restore] Installing System.Private.DataContractSerialization 4.1.1. [22:57:42][restore] Installing Microsoft.Win32.Registry 4.0.0. [...] [22:57:48][restore] Installing System.Diagnostics.Contracts 4.0.1. [22:57:48][restore] Installing System.Threading.Tasks.Dataflow 4.6.0. [22:57:48][restore] Installing System.IO.Pipes 4.0.0. [22:57:51][restore] Package Microsoft.Extensions.FileProviders.Physical 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.Extensions.FileProviders.Physical 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51][restore] Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51][restore] One or more packages are incompatible with .NETCoreApp,Version=v2.0. [22:57:51][restore] Committing restore... [22:57:51][restore] Restore failed in 19,33 sec for C:\path\to\project\Server\Server.csproj. [22:57:51][restore] [22:57:51][restore] Errors in C:\path\to\project\Server\Server.csproj [22:57:51][restore] Package Microsoft.AspNetCore 2.0.0 is not compatible with net462 (.NETFramework,Version=v4.6.2). Package Microsoft.AspNetCore 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51][restore] Package Microsoft.AspNetCore.Mvc 2.0.0 is not compatible with net462 (.NETFramework,Version=v4.6.2). Package Microsoft.AspNetCore.Mvc 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51][restore] One or more packages are incompatible with .NETFramework,Version=v4.6.2. [22:57:51][restore] Package Microsoft.AspNetCore 2.0.0 is not compatible with net462 (.NETFramework,Version=v4.6.2) / win7-x86. Package Microsoft.AspNetCore 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51][restore] Package Microsoft.AspNetCore.Mvc 2.0.0 is not compatible with net462 (.NETFramework,Version=v4.6.2) / win7-x86. Package Microsoft.AspNetCore.Mvc 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51][restore] [22:57:51][restore] One or more packages are incompatible with .NETFramework,Version=v4.6.2 (win7-x86). [22:57:51][restore] NuGet Config files used: [22:57:51][restore] [22:57:51][restore] C:\Windows\system32\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config [22:57:51][restore] Errors in C:\path\to\project\Server\Server.csproj [22:57:51][restore] [22:57:51][restore] Package Microsoft.Extensions.FileProviders.Physical 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.Extensions.FileProviders.Physical 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51][restore] Feeds used: [22:57:51][restore] api.nuget/v3/index.json [22:57:51][restore] Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) [22:57:51][restore] One or more packages are incompatible with .NETCoreApp,Version=v2.0. [22:57:51][restore] [22:57:51][restore] Installed: [22:57:51][restore] 151 package(s) to C:\path\to\project\Server\Server.csproj [22:57:51][restore] Process exited with code 1 [22:57:51][restore] Process exited with code 1 [22:57:51][Step 1/4] Step Nuget Restore (NuGet Installer) failed

推荐答案

使用Nuget版本4.3对其进行了修复:).

Using Nuget Version 4.3 fixed it :).

更多推荐

Nuget还原对于构建服务器上的ASP.NET Core 2.0项目失败

本文发布于:2023-11-15 12:32:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1594471.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:器上   项目   ASP   Nuget   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!