Repro project: https://github.com/yinyue200/taskextest/tree/v2
Build successful
error CS0012: The type 'ValueTask<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
VS bug #639363
I'm not able to build this project with VS 2017 15.7.4 or current master (0b5ce8fb5e702b06c1d7f1d8d08a91b14b0e675d).
Build environment information is essential to determine if it is expected or not.
I could build ClassLibrary1 if I correctly run dotnet restore or I opened it from monodevelop/VSMac that does support .NET Standard 2.0 library.
I think there is an issue in using ValueTask<T> with Xamarin.Android, I need to spend more time looking into it.
Ok, here is a better summary of the problem:
ValueTask<T> without any NuGetsValueTask<T> in a NetStandard 2.0 project, it requires the System.Threading.Tasks.Extensions NuGet. Reference the NetStandard lib from a Xamarin.Android app: _it doesn't work_In case this helps at all, here's some of my experience.
VS 2017 15.58 P3
Xamarin.Android SDK 8.4.0.1
When referencing a NuGet that has a dependency on System.Threading.Tasks.Extensions 4.5.1 and is netstandard2.0, such as Asp.Net Core, then I get the following build error:
Xamarin.Android.Common.targets(1831,2): error XA2002: Can not resolve reference: 'System.Threading.Tasks.Extensions', referenced by 'Microsoft.AspNetCore.Server.Kestrel.Core'.
The project.assets.json file shows an empty placeholder for it:
"System.Threading.Tasks.Extensions/4.5.1": {
"type": "package",
"compile": {
"ref/MonoAndroid10/_._": {}
},
"runtime": {
"lib/MonoAndroid10/_._": {}
}
}
I noticed that System.Threading.Tasks.Extensions 4.5.0 does not have empty place holders for MonoAndroid, so it compiles and runs. (Well, Asp.Net Core breaks because FileSystemWatcher throws NotImplementedException, but that's another story I think the mono repo is tracking... mono/mono/issues/6966). The one con is that the compiler constantly warns about NuGet version downgrade.
NU1605: Detected package downgrade: System.Threading.Tasks.Extensions from 4.5.1 to 4.5.0. Reference the package directly from the project to select a different version.
KestrelTest2.Android -> Microsoft.AspNetCore.Server.Kestrel 2.1.1 -> Microsoft.AspNetCore.Server.Kestrel.Core 2.1.1 -> System.Threading.Tasks.Extensions (>= 4.5.1)
KestrelTest2.Android -> System.Threading.Tasks.Extensions (>= 4.5.0)
Does the milestone label d15-9 mean if this gets fixed, it won't be in Visual Studio 2017 15.8, but rather the next VS update, presumably 15.9?
@AdamDotNet ,4.5.0 has a another issue. see dotnet/corefx#29585
I think this is the same issue that I was having. My current workaround is to downgrade System.Threading.Tasks.Extensions to 4.4.0.
Most helpful comment
Ok, here is a better summary of the problem:
ValueTask<T>without any NuGetsValueTask<T>in a NetStandard 2.0 project, it requires theSystem.Threading.Tasks.ExtensionsNuGet. Reference the NetStandard lib from a Xamarin.Android app: _it doesn't work_