Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler error when referencing a NetStandard 2.0 library using ValueTask<T> #1879

Closed
yinyue200 opened this issue Jun 23, 2018 · 7 comments
Closed
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects. bug Component does not function as intended. vs-sync For internal use only; creates a VSTS "mirror" issue.
Milestone

Comments

@yinyue200
Copy link

yinyue200 commented Jun 23, 2018

Steps to Reproduce

  1. Build it

Repro project: https://github.com/yinyue200/taskextest/tree/v2

Expected Behavior

Build successful

Actual Behavior

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'.

Version Information

Log File

VS bug #639363

@jonathanpeppers jonathanpeppers added bug Component does not function as intended. Area: App+Library Build Issues when building Library projects or Application projects. labels Jun 25, 2018
@jonathanpeppers
Copy link
Member

jonathanpeppers commented Jun 25, 2018

I'm not able to build this project with VS 2017 15.7.4 or current master (0b5ce8f).

@atsushieno
Copy link
Contributor

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.

@jonathanpeppers
Copy link
Member

I think there is an issue in using ValueTask<T> with Xamarin.Android, I need to spend more time looking into it.

@jonathanpeppers
Copy link
Member

Ok, here is a better summary of the problem:

  1. If you create a Xamarin.Android app, you can use ValueTask<T> without any NuGets
  2. If you instead use ValueTask<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

@jonathanpeppers jonathanpeppers changed the title error CS0012: The type 'ValueTask<>' is defined in an assembly that is not referenced Compiler error when referencing a NetStandard 2.0 library using ValueTask<T> Jun 27, 2018
@jonathanpeppers jonathanpeppers added this to the d15-9 milestone Jun 27, 2018
@jonathanpeppers jonathanpeppers added the vs-sync For internal use only; creates a VSTS "mirror" issue. label Jun 27, 2018
@AdamDotNet
Copy link

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?

@yinyue200
Copy link
Author

@AdamDotNet ,4.5.0 has a another issue. see dotnet/corefx#29585

@jdluzen
Copy link

jdluzen commented Aug 11, 2018

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.

jonpryor added a commit to jonpryor/xamarin-android that referenced this issue Nov 20, 2018
Fixes: dotnet#1879

Add the following Facade assemblies to `@(MonoFacadeAssembly)`:

  * `System.Buffers.dll`
  * `System.Memory.dll`
  * `System.Net.Http.Rtc.dll`
  * `System.Threading.Tasks.Extensions.dll`

Note: list was reordered to be sorted as per **sort**(1), and
generated with the following shell code on macOS:

	$ cd external/mono/mcs/class/Facades
	$ for d in `find . -depth 1 -type d | grep -v 'netstandard\|System.Drawing.Primitives' | sort -f` ; do
	  n=`basename "$d"`;
	  echo "    <MonoFacadeAssembly Include=\"$n.dll\" />";
	done | pbcopy

The `netstandard` and `System.Drawing.Primitives` directory are
excluded so that the comment and following `@(MonoFacadeAssembly)`
entries in `ProfileAssemblies.projitems` are still relevant.
jonpryor added a commit to jonpryor/xamarin-android that referenced this issue Nov 21, 2018
Fixes: dotnet#1879

Add the following Facade assemblies to `@(MonoFacadeAssembly)`:

  * `System.Buffers.dll`
  * `System.Memory.dll`
  * `System.Net.Http.Rtc.dll`
  * `System.Threading.Tasks.Extensions.dll`

Note: list was reordered to be sorted as per **sort**(1), and
generated with the following shell code on macOS:

	$ cd external/mono/mcs/class/Facades
	$ for d in `find . -depth 1 -type d | grep -v 'netstandard\|System.Drawing.Primitives' | sort -f` ; do
	  n=`basename "$d"`;
	  echo "    <MonoFacadeAssembly Include=\"$n.dll\" />";
	done | pbcopy

The `netstandard` and `System.Drawing.Primitives` directory are
excluded so that the comment and following `@(MonoFacadeAssembly)`
entries in `ProfileAssemblies.projitems` are still relevant.
jonpryor added a commit to jonpryor/xamarin-android that referenced this issue Nov 21, 2018
Fixes: dotnet#1879

Add the following Facade assemblies to `@(MonoFacadeAssembly)`:

  * `System.Buffers.dll`
  * `System.Memory.dll`
  * `System.Net.Http.Rtc.dll`
  * `System.Threading.Tasks.Extensions.dll`

Note: list was reordered to be sorted as per **sort**(1), and
generated with the following shell code on macOS:

	$ cd external/mono/mcs/class/Facades
	$ for d in `find . -depth 1 -type d | grep -v 'netstandard\|System.Drawing.Primitives' | sort -f` ; do
	  n=`basename "$d"`;
	  echo "    <MonoFacadeAssembly Include=\"$n.dll\" />";
	done | pbcopy

The `netstandard` and `System.Drawing.Primitives` directory are
excluded so that the comment and following `@(MonoFacadeAssembly)`
entries in `ProfileAssemblies.projitems` are still relevant.
jonpryor added a commit to jonpryor/xamarin-android that referenced this issue Nov 21, 2018
Fixes: dotnet#1879

Add the following Facade assemblies to `@(MonoFacadeAssembly)`:

  * `System.Buffers.dll`
  * `System.Memory.dll`
  * `System.Net.Http.Rtc.dll`
  * `System.Threading.Tasks.Extensions.dll`

Note: list was reordered to be sorted as per **sort**(1), and
generated with the following shell code on macOS:

	$ cd external/mono/mcs/class/Facades
	$ for d in `find . -depth 1 -type d | grep -v 'netstandard\|System.Drawing.Primitives\|System.Net.Http.Rtc' | sort -f` ; do
	  n=`basename "$d"`;
	  echo "    <MonoFacadeAssembly Include=\"$n.dll\" />";
	done | pbcopy

The `netstandard` and `System.Drawing.Primitives` directory are
excluded so that the comment and following `@(MonoFacadeAssembly)`
entries in `ProfileAssemblies.projitems` are still relevant.
jonpryor added a commit to jonpryor/xamarin-android that referenced this issue Nov 21, 2018
Fixes: dotnet#1879

Add the following Facade assemblies to `@(MonoFacadeAssembly)`:

  * `System.Buffers.dll`
  * `System.Memory.dll`
  * `System.Net.Http.Rtc.dll`
  * `System.Threading.Tasks.Extensions.dll`

Note: list was reordered to be sorted as per **sort**(1), and
generated with the following shell code on macOS:

	$ cd external/mono/mcs/class/Facades
	$ for d in `find . -depth 1 -type d | grep -v 'netstandard\|System.Drawing.Primitives\|System.Net.Http.Rtc' | sort -f` ; do
	  n=`basename "$d"`;
	  echo "    <MonoFacadeAssembly Include=\"$n.dll\" />";
	done | pbcopy

The `netstandard` and `System.Drawing.Primitives` directory are
excluded so that the comment and following `@(MonoFacadeAssembly)`
entries in `ProfileAssemblies.projitems` are still relevant.
jonpryor added a commit to jonpryor/xamarin-android that referenced this issue Nov 21, 2018
Fixes: dotnet#1879

Add the following Facade assemblies to `@(MonoFacadeAssembly)`:

  * `System.Buffers.dll`
  * `System.Memory.dll`
  * `System.Net.Http.Rtc.dll`
  * `System.Threading.Tasks.Extensions.dll`

Note: list was reordered to be sorted as per **sort**(1), and
generated with the following shell code on macOS:

	$ cd external/mono/mcs/class/Facades
	$ for d in `find . -depth 1 -type d | grep -v 'netstandard\|System.Drawing.Primitives\|System.Net.Http.Rtc' | sort -f` ; do
	  n=`basename "$d"`;
	  echo "    <MonoFacadeAssembly Include=\"$n.dll\" />";
	done | pbcopy

The `netstandard` and `System.Drawing.Primitives` directory are
excluded so that the comment and following `@(MonoFacadeAssembly)`
entries in `ProfileAssemblies.projitems` are still relevant.
jonpryor added a commit to jonpryor/xamarin-android that referenced this issue Nov 21, 2018
Fixes: dotnet#1879

Add the following Facade assemblies to `@(MonoFacadeAssembly)`:

  * `System.Buffers.dll`
  * `System.Memory.dll`
  * `System.Threading.Tasks.Extensions.dll`

Note: list was reordered to be sorted as per **sort**(1), and
generated with the following shell code on macOS:

	$ cd external/mono/mcs/class/Facades
	$ for d in `find . -depth 1 -type d | grep -v 'netstandard\|System.Drawing.Primitives\|System.Net.Http.Rtc' | sort -f` ; do
	  n=`basename "$d"`;
	  echo "    <MonoFacadeAssembly Include=\"$n.dll\" />";
	done | pbcopy

The `netstandard` and `System.Drawing.Primitives` directory are
excluded so that the comment and following `@(MonoFacadeAssembly)`
entries in `ProfileAssemblies.projitems` are still relevant.
jonpryor added a commit to jonpryor/xamarin-android that referenced this issue Nov 21, 2018
Fixes: dotnet#1879

Add the following Facade assemblies to `@(MonoFacadeAssembly)`:

  * `System.Buffers.dll`
  * `System.Memory.dll`
  * `System.Threading.Tasks.Extensions.dll`

Note: list was reordered to be sorted as per **sort**(1), and
generated with the following shell code on macOS:

	$ cd external/mono/mcs/class/Facades
	$ for d in `find . -depth 1 -type d | grep -v 'netstandard\|System.Drawing.Primitives\|System.Net.Http.Rtc' | sort -f` ; do
	  n=`basename "$d"`;
	  echo "    <MonoFacadeAssembly Include=\"$n.dll\" />";
	done | pbcopy

The `netstandard` and `System.Drawing.Primitives` directories are
excluded so that the comment and following `@(MonoFacadeAssembly)`
entries in `ProfileAssemblies.projitems` are still relevant.

The `System.Net.Http.Rtc` directory is excluded because it is only for
use on Desktop profiles.
jonpryor added a commit that referenced this issue Nov 26, 2018
Fixes: #1879

Add the following Facade assemblies to `@(MonoFacadeAssembly)`:

  * `System.Buffers.dll`
  * `System.Memory.dll`
  * `System.Threading.Tasks.Extensions.dll`

Note: list was reordered to be sorted as per **sort**(1), and
generated with the following shell code on macOS:

	$ cd external/mono/mcs/class/Facades
	$ for d in `find . -depth 1 -type d | grep -v 'netstandard\|System.Drawing.Primitives\|System.Net.Http.Rtc' | sort -f` ; do
	  n=`basename "$d"`;
	  echo "    <MonoFacadeAssembly Include=\"$n.dll\" />";
	done | pbcopy

The `netstandard` and `System.Drawing.Primitives` directories are
excluded so that the comment and following `@(MonoFacadeAssembly)`
entries in `ProfileAssemblies.projitems` are still relevant.

The `System.Net.Http.Rtc` directory is excluded because it is only for
use on Desktop profiles.
jonpryor added a commit that referenced this issue Nov 29, 2018
Fixes: #1879

Add the following Facade assemblies to `@(MonoFacadeAssembly)`:

  * `System.Buffers.dll`
  * `System.Memory.dll`
  * `System.Threading.Tasks.Extensions.dll`

Note: list was reordered to be sorted as per **sort**(1), and
generated with the following shell code on macOS:

	$ cd external/mono/mcs/class/Facades
	$ for d in `find . -depth 1 -type d | grep -v 'netstandard\|System.Drawing.Primitives\|System.Net.Http.Rtc' | sort -f` ; do
	  n=`basename "$d"`;
	  echo "    <MonoFacadeAssembly Include=\"$n.dll\" />";
	done | pbcopy

The `netstandard` and `System.Drawing.Primitives` directories are
excluded so that the comment and following `@(MonoFacadeAssembly)`
entries in `ProfileAssemblies.projitems` are still relevant.

The `System.Net.Http.Rtc` directory is excluded because it is only for
use on Desktop profiles.
kekekeks added a commit to AvaloniaUI/Avalonia that referenced this issue Jul 9, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Jun 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects. bug Component does not function as intended. vs-sync For internal use only; creates a VSTS "mirror" issue.
Projects
None yet
Development

No branches or pull requests

7 participants