当 net461 引用 netstandard2.0 时,VSTS 失败并生成 Visual Studio
VSTS fails with Visual Studio Build when net461 is referencing netstandard2.0
我们正在将库项目从 net461
迁移到 netstandard2.0
。某些库尚不支持 .NET Standard,因此托管应用程序正在运行 net461
并引用我们使用 netstandard2.0
.
的库
这与 Visual Studio 15.3 在本地完美运行,一切都在运行和构建。
根据 Microsoft documentation 带有 SDK 2.0 的 .NET 标准实现了 4.6.1,我认为这就是它在本地工作的原因。
当 运行 在 Visual Studio 在线 (VSTS) 中构建时失败并出现多个错误,例如:
Package Microsoft.AspNetCore.Mvc 2.0.0 is not compatible with net461 (.NETFramework,Version=v4.6.1). Package Microsoft.AspNetCore.Mvc 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
我阅读了 github 讨论 here and here,讨论类似的问题是一个工具问题,并添加了一个 .NET
Core Tool Installer
构建安装 Core 2.0 的任务,但仍然没有成功。
我需要做什么才能在 VSTS 中运行构建?
更新:
(将标题更改为 Visual Studio Build 而不是 MS Build)
找到此线程 https://github.com/dotnet/standard/issues/454 讨论需要更新的 VSTS。
我是 运行 VS Enterprise 15.4.1,VSTS Build is running version 15.3.5 today 根据 github 上的问题,这已经足够了。这就更让人费解了。
通过将 dotnet restore
和 dotnet build
与版本 2.* (preview)
一起使用找到了一个解决方法,效果很好。
不使用 MS Build 或 Visual Studio 2017 构建,只需将构建任务替换为以下 dotnet
任务即可。
(如果您没有任何私人提要,您甚至不需要 dotnet restore
命令,因为 dotnet build
会为您恢复包)。
TL;DR;改用这个:
我们正在将库项目从 net461
迁移到 netstandard2.0
。某些库尚不支持 .NET Standard,因此托管应用程序正在运行 net461
并引用我们使用 netstandard2.0
.
这与 Visual Studio 15.3 在本地完美运行,一切都在运行和构建。
根据 Microsoft documentation 带有 SDK 2.0 的 .NET 标准实现了 4.6.1,我认为这就是它在本地工作的原因。
当 运行 在 Visual Studio 在线 (VSTS) 中构建时失败并出现多个错误,例如:
Package Microsoft.AspNetCore.Mvc 2.0.0 is not compatible with net461 (.NETFramework,Version=v4.6.1). Package Microsoft.AspNetCore.Mvc 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
我阅读了 github 讨论 here and here,讨论类似的问题是一个工具问题,并添加了一个 .NET
Core Tool Installer
构建安装 Core 2.0 的任务,但仍然没有成功。
我需要做什么才能在 VSTS 中运行构建?
更新:
(将标题更改为 Visual Studio Build 而不是 MS Build)
找到此线程 https://github.com/dotnet/standard/issues/454 讨论需要更新的 VSTS。
我是 运行 VS Enterprise 15.4.1,VSTS Build is running version 15.3.5 today 根据 github 上的问题,这已经足够了。这就更让人费解了。
通过将 dotnet restore
和 dotnet build
与版本 2.* (preview)
一起使用找到了一个解决方法,效果很好。
不使用 MS Build 或 Visual Studio 2017 构建,只需将构建任务替换为以下 dotnet
任务即可。
(如果您没有任何私人提要,您甚至不需要 dotnet restore
命令,因为 dotnet build
会为您恢复包)。
TL;DR;改用这个: