Try to "Add Reference" the System.Threading.Tasks.dll
explicitly from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5
. Alternatively you can use C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades
directory.
UPDATED: I examined the problem more after reading of the answer about removing the reference to System.Runtime
and I can add the following: The reference to System.Runtime
will be added because of the error in the currect version of NuGet package Microsoft.Tpl.Dataflow.4.5.1-rc
. If one add the reference to the same System.Threading.Tasks.Dataflow.dll
directly in Visual Studio no System.Runtime
reference will be added and no problem exist.
Using NuGet Package Explorer one can download the original Microsoft.Tpl.Dataflow.4.5.1-rc.nupkg
from the "NuGet official package source". At the end of the Package Matadata one will see
One can modify the metadata (press Ctrl-K) and remove the reference:
After that one can save the modified file Microsoft.Tpl.Dataflow.4.5.1-rc.nupkg
in some directory. After adding new location (the local directory) in the list of NuGet sources (see here or here) one will be able to add new package from the local source (don't forget to choose to display all packages inclusive pre-release see the picture below):
The modified Microsoft.Tpl.Dataflow.4.5.1-rc.nupkg
will not add System.Runtime
and the project will be compiled without errors.
So the bug exist not in Visual Studio 2012 RC and even not in Microsoft.Tpl.Dataflow.dll
. The bug is just in the metadata of the pre-release version of Microsoft.Tpl.Dataflow
NuGet package available currently on "NuGet official package source".
You can post the bug report to the autors so that the package will be fixed.
UPDATED 2: Even if my answer are already marked as solved and the bounty awarded the problem still not go from my head. In reality I see two opened problems:
- Why the existence of unused assembly
System.Runtime
can produce the error during the builging of the project.
- I see some general problems in the way how Uninstall or Update of NuGet packages works (see details later).
Let us we accept just the fact that the first problem exist independent from the reason. The second problem make me restlessness. I see the real problem here. Everybody can make the following experiment to understand me better:
- Create a new empty console application in Visual Studio 2012 RC.
- Verify that the project has no reference to
System.Runtime
.
- Open "Package Manager Console" from "Tools" / "Library Package Manager".
- Execute the command "Install-Package Microsoft.Tpl.Dataflow -Pre" in the "Package Manager Console".
- Verify that both
System.Runtime
and System.Threading.Tasks.Dataflow
are included in the list of References of the project.
- Execute the command "Uninstall-Package Microsoft.Tpl.Dataflow" in the "Package Manager Console".
- Verify that
System.Threading.Tasks.Dataflow
are removed from the list of References of the project, but System.Runtime
is still in the list of references.
I made one more experiment and I changed the version of modified Microsoft.Tpl.Dataflow.4.5.1-rc.nupkg
, where I removed the reference to System.Runtime
, from 4.5.1-rc
to 4.5.1-rc1
and saved it locally (it will be saved under Microsoft.Tpl.Dataflow.4.5.1-rc1.nupkg
). After that I could see "new" version in the list of Updates to my project:
If I install the Update the reference to System.Runtime
will be also not removed.
So the current implementation of "Update" and "Uninstall" of NuGet has the bug or general design problem. If we added a package to our project and make some updates of the project we will get references of all dependent assemblies of all old versions. The old references, added by NuGet from old versions of the package, will be not removed during Uninstall or Update. First of all it's not good itself to have garbage in the project references, but because of existence the first problem (error during compilation if the reference to unreferenced System.Runtime
exist) the problem will be even more serious.
So if nothing will be changed in NuGet the update to the next version of Microsoft.Tpl.Dataflow
will not solve the problem for the users who installed Microsoft.Tpl.Dataflow
in version 4.5.1 (or probably early version). All users will have to remove the reference to System.Runtime
manually. I think that it's real NuGet problem which have to be solved by NuGet developers. I will post the description of the problem to http://nuget.org/ later.
The bug report which I posted to NuGet can be found here (sorry for not perfect formatting of the text).