.NET Core - 为什么AsyncLocal <>引用构建在Windows上,而不是Linux(netstandard2.0)

问题描述 投票:0回答:1

我的项目文件:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <Description>Redacted</Description>
    <VersionPrefix>2.0.0</VersionPrefix>
    <TargetFramework>netstandard2.0</TargetFramework>
    <AssemblyName>Redacted</AssemblyName>
    <PackageId>Redacted</PackageId>
  </PropertyGroup>
</Project>

我的代码:

using System.Threading;
// ...
_context = new AsyncLocal<SomeClass>();

dotnet build命令行或VS 2017本地构建.NET SDK 2.1.401,Windows 10,没问题。关于异步方法的几个警告没有等待(不相关)。

基于Travis CI,.NET SDK 2.1.401,Ubuntu Trusty:

error CS0246: The type or namespace name 'AsyncLocal<>' could not be found (are you missing a using directive or an assembly reference?) 
linux .net-core .net-standard
1个回答
0
投票

我不确定原因,但我的案例中的解决方案是我正在使用dotnet msbuild /t:Restore;Pack构建。

有关GH的更多细节:https://github.com/dotnet/cli/issues/9993

我不知道我是怎么来使用/t:Restore;Pack的 - 但显然,/t:Restore;anything不是一个好主意。

© www.soinside.com 2019 - 2024. All rights reserved.