teamcity - 构建服务器上的 ASP.NET Core 2.0 项目的 Nuget 恢复失败

标签 teamcity windows-server-2012-r2 nuget-package-restore .net-4.6.2 asp.net-core-2.0

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

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

  • Microsoft .Net Core SDK - 2.0.0.0
  • Microsoft .Net 框架(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

最佳答案

使用 Nuget 4.3 版本修复了这个问题:)。

关于teamcity - 构建服务器上的 ASP.NET Core 2.0 项目的 Nuget 恢复失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45723797/

相关文章:

c# - 正则表达式替换程序集版本的最后两位数字

visual-c++ - 如何让 MSBuild 自动下载解决方案/项目中引用的新 nuget 包?

azure-devops - 如何在 VSO 中启用 Nuget 包还原

teamcity - SpecRun 和 TeamCity 集成通过/失败

asp.net-mvc - 尝试使用 TeamCity 构建 ASP.NET MVC Web 应用程序时出错

java - Spring 集成应用程序启动时生成种子时 CryptoAPI 意外失败

web-services - 如何在 Windows Server 2012 r2 上调试 NTLM 身份验证

powershell - PowerShell脚本未与任务计划程序一起运行

Azure Functions,nuget 包安装失败

Java静态分析器自定义模板/规范