我的项目文件:
<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?)
我不确定原因,但我的案例中的解决方案是我正在使用dotnet msbuild /t:Restore;Pack
构建。
有关GH的更多细节:https://github.com/dotnet/cli/issues/9993
我不知道我是怎么来使用/t:Restore;Pack
的 - 但显然,/t:Restore;anything
不是一个好主意。