Сбой восстановления Nuget для проекта ASP.NET Core 2.0 на сервере сборки

Я пытаюсь создать приложение ASP.NET Core 2.0 для .NET Framework 4.6.2 (не .NET Core) с помощью TeamCity на Windows Server 2012R2.

На сервере установлены следующие компоненты:

  • Пакет SDK для Microsoft .Net Core - 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 и файл решения для восстановления зависимых пакетов (подробности см. В полном журнале ниже).

Ошибка:

[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 работает нормально.

Есть идеи, как решить эту ошибку / как продолжить анализ проблемы?


Файл проекта (содержащий пакеты nuget):

<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 https://api.nuget.org/v3-flatcontainer/microsoft.visualstudio.web.codegeneration.tools/index.json
[22:57:32][restore]   GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.mvc/index.json
[22:57:32][restore]   GET https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore/index.json
[...]
[22:57:41][restore]   OK https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnetapphost/index.json 475ms
[22:57:41][restore]   GET https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnetapphost/2.0.0/microsoft.netcore.dotnetapphost.2.0.0.nupkg
[22:57:41][restore]   OK https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnetapphost/2.0.0/microsoft.netcore.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]     https://api.nuget.org/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



Ответы (1)


Использование Nuget версии 4.3 исправило это :).

person JanDotNet    schedule 17.08.2017
comment
Вы используете nuget.exe 4.3.0, загруженный с nuget.org? У меня такая же проблема с тем, что все новые ссылки AspNetCore и EntityFrameworkCore 2.0.0 несовместимы с net462, но nuget в VS2017 работает. - person Valuator; 15.09.2017
comment
Я установил версию nuget через team city, как описано здесь. Но я думаю, что Team City получила это с сайта nuget.org. - person JanDotNet; 26.09.2017
comment
У меня возникла проблема с Azure DevOps (VSTS) и я добавил задачу в агент задания, чтобы получить NuGet 4.3 до того, как задача восстановления заставит его работать. Непонятно, потому что, конечно, это сработало на моей машине. Спасибо. - person Daniel Przybylski; 01.02.2019
comment
Та же проблема для проекта .net core 2.2, ссылающегося на библиотеку .net 4.6.1. Уже использовал Nuget 4.4.1 в Azure DevOps. Обновился до Nuget 4.9.3, работал нормально. - person ubienewbie; 13.02.2019