Microsoft.Bcl.Async is Now Stable


It’s done. About five months ago, we shipped our Microsoft.Bcl.Async NuGet package which provides support for the async/await keywords for pre-.NET 4.5 platforms, such as .NET 4, Silverlight 4, and Windows Phone 7.5. Of course, this includes support for portable class libraries as well.

We believe we’ve baked Microsoft.Bcl.Async enough to flip the switch and mark it as stable. This might not sound like a big deal but it is the NuGet equivalent of shipping an RTM.

C-3PO: “Sir, it’s quite possible this package is not entirely stable.”

Han Solo: “Not entirely stable? Well, I’m glad you’re here to tell us

these things. Chewie, take the professor in the back and

show him how to upgrade the NuGet package!”

— Star Wars as Immo remembers it

What’s the big deal with being stable?

Being stable means the owner of that package states that API and functionality are unlikely to change and therefore suitable for use in production. This also enables 3rd parties to publish stable NuGet packages that depend on our package because NuGet prevents stable packages from depending on pre-release packages.

What about Microsoft.CompilerServices.AsyncTargetingPack?

Before we shipped Microsoft.Bcl.Async we shipped another NuGet package which was provided by the language team to gather feedback on the async and await keywords (“Async Targeting Pack”)

https://www.nuget.org/packages/Microsoft.CompilerServices.AsyncTargetingPack

Our stable release of Microsoft.Bcl.Async officially supersedes the Async Targeting Pack. We haven’t removed it, but we unlisted it on NuGet so that new developers aren’t accidentally using the old version. We’ve also added a readme.txt which is automatically displayed by VS when existing consumers upgrade their package references.

Fixed Issues

The majority of customer issues we’ve seen was due to two issues:

  1. Outdated version of NuGet. In order to use the Async package from a portable class library, you need to run the NuGet 2.1 or higher. To address this in the future, we have worked with the NuGet team and NuGet 2.3 will add this ability. For now, you will need to know to install an updated version of NuGet (see instructions in section “How to Upgrade” below).
  2. Missing reference to the async package from all referencing projects. In order to make the async functionality work across all platforms, we make use of a CLR feature called assembly unification. For that to work properly, all projects must have a reference to the Async NuGet package. Since this can be easy to forget, we’ve added a warning mechanism to our package that tells you what to do. I’ll discuss this in more detail below.

After upgrading, you will see the following build warning:

 

After fixing this, you might see the following warnings:

In both cases, the project that causes the warning is missing a NuGet package reference. Adding these references will fix the warnings.

Tip: If your solution contains many projects, you may want bulk-add the async packages to several projects at once. You can do this by right clicking your solution and selecting Manage NuGet Packages for Solution. Select the NuGet package and click Manage. A dialog appears that enables you to select the projects you want to update.

Add references for Microsoft.Bcl, Microsoft.Bcl.Async, and Microsoft.Bcl.Build to all projects that show the warnings mentioned previously.

Branding

We’ve added some branding to make our packages easier to recognize. Our dotnetframework user now displays the .NET gravatar.

 

and so does our async NuGet package:

 

How to Upgrade

Important: Since our package contains portable class libraries, you need to use NuGet 2.1 or higher. You can check whether you have the latest version by going to Tools | Extensions and Updates. When the Extensions and Updates dialog opens, select Updates | Visual Studio Gallery and look for an entry titled NuGet Package Manager.

In order to upgrade to the RTM version, right click your project and select Manage NuGet Packages. In the resulting dialog, select the Updates section on the left hand side. In the center, the Async NuGet package should show up. Simply click the Update button.

Summary

Microsoft.Bcl.Async is now stable which means you can use it in production. Of course, software is never truly done, so we still want to hear from you if things don’t work for you. You can contact us via comments under this blog posts or via our NuGet contact page. Also, make sure to check out the known issues list.


Comments (49)

  1. Bernhard Koenig says:

    Thanks, this is very helpful for WP7 development. Just updated to the stable release over NuGet.

  2. Jose Fajardo says:

    Great work … I'm absolutely loving the use of NuGet for deploying .NET libs, very very developer friendly!

  3. Ladislav says:

    thanks. Now we have an upgrade path.

  4. Ladislav says:

    Please add support for Task based WCF Client generation.

  5. Fantastic news!

    This is really helping me out writing my WP7 app that has loads of asynchronous network communication. Now I can publish it!

  6. Martin Suchan says:

    Great! Any news about Http Client Libraries hitting RTM soon?

  7. BG says:

    Hello,

    having a issue with a Library (.NET 4) that is use BCL. If a .NET 4.5 executable tries to add a references (based on the warning that it is required) to Microsoft.Bcl.Async I end up with a compiler error that this is not allowed.

    Any solution for that?

  8. BG: Can you provide more information? What compiler error are you getting? Did you use NuGet to install the package to the .NET 4.5 project?

    David Kean (MSFT)

  9. Kamran Ayub says:

    Awesome! Now let's see System.Net.Http stable for WP! Keep up the great work.

  10. @Martin Suchan: Thanks for your interest in the portable HttpClient!

    We haven't finalized the release date yet but we are planning on shipping an updated version within the next three weeks or so.

    Right now we aren't planning on making this a stable release as we are adding substantial feature work. However, we are quite confident that the very next release after will be marked as stable.

  11. dsplaisted says:

    @BG: You should be able to fix the issue by changing the newVersion for the binding redirects in the .NET 4.5 project's app.config from 2.5.19.0 to 4.0.0.0 for System.Runtime and System.Threading.Tasks.

    Daniel Plaisted (MSFT)

  12. Jason R says:

    Our company policy is to have all development workstations offline.  How can I install this and other nuget packages offline?

  13. @Jason R, NuGet offers you a way to create your own custom shares. So you can download packages that you need to a non development workstation and configure your dev workstations to consume packages from there, instead of the online mode.

  14. Bruce B says:

    Is Microsoft.Bcl.Async now supported for VB Web Applications?

  15. Ted says:

    Is there a planned .NET 4.1 framework update to push this DLL out to our end users?

  16. Haacked says:

    I think I may have found an issue with the assembly unification and mixed platform targets. I have a repro project, but the steps are pretty easy.

    Here's a description of my solution with two projects and platform targets.

    Solution.sln

     > WPFProject.exe (x86)

     > SomeClassLib (AnyCPU)

    WPFProject.exe references SomeClassLib which is a C# class lib. I installed Microsoft.Bcl.Async into both projects.

    I changed the Active CPU configuration to x86. When I build the project, I get the following error.

    1>—— Skipped Build: Project: SomeClassLibrary, Configuration: Debug Any CPU ——

    1>Project not selected to build for this solution configuration

    2>—— Build started: Project: WpfApplication1, Configuration: Debug x86 ——

    2>C:WindowsMicrosoft.NETFrameworkv4.0.30319Microsoft.Common.targets(609,5): error : The OutputPath property is not set for project 'SomeClassLibrary.csproj'.  Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='Debug'  Platform='x86'.  This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform.

    Build has been canceled.

    Build Summary

    ————-

    00:00.386 – Failed  – Debug x86 – WpfApplication1WpfApplication1.csproj

    Total build time: 00:00.404

    ========== Build: 0 succeeded or up-to-date, 1 failed, 1 skipped ==========

    Any ideas?

  17. Haacked says:

    I should add that the solution built just fine before I installed the Microsoft.Bcl.Async package. And it builds if I uninstall all the Microsoft.Bcl.* packages.

  18. Christian Fredh says:

    Great news!

    Will it work with .NET Framework 3.5 as well?

  19. I have the same problem as Haacked. But I can finally build the project by changing the configurations and platform so that all projects have the same name. The problem occur again when I create new configuration for just 1 project.

    It did not happen with the pre-release version either.

  20. Stilgar says:

    Why does the nuget page list Windows Phone 8 as a target platform. Windows Phone 8 supports these things out of the box doesn't it?

  21. Furkan Gozukara says:

    hello Immo. i have a big problem

    my msdn forum account is banned and there is no reason

    i did not get any email message etc

    can you please check the issue ?

    social.msdn.microsoft.com/…/monstermmorpg

    thank you

  22. I'd love to work this in to our current projects that are using the AsyncTargetingPack however I would also appreciate a way to work the assembly references in without using NuGet.  We don't use NuGet for anything else and we bundle all of our referenced assemblies along with the source code so working this in as a one-off just isn't that clean for us.  If you get some time and know of an alternate deployment scenario, please let me know.

    Thanks!

  23. Had posted this in the HttpClient topic but that seems closed for comments now.  And besides, it is the same issue that the BCL Build package won't install and stops everything else.  Error is below.  VS2012 with latest updates to VS and NuGet.

    Attempting to resolve dependency 'Microsoft.Bcl.Build (≥ 1.0.4)'.

    Successfully installed 'Microsoft.Bcl.Build 1.0.4'.

    Successfully installed 'Microsoft.Bcl 1.0.19'.

    Successfully uninstalled 'Microsoft.Bcl.Build 1.0.4'.

    Install failed. Rolling back…

    Could not install package 'Microsoft.Bcl.Build 1.0.4'. You are trying to install this package into a project that targets 'portable-win+net45+sl40+wp', but the package does not contain any assembly references or content files that are compatible with that framework.

  24. @Bruce B: "Is Microsoft.Bcl.Async now supported for VB Web Applications?"

    Unfortunately not. The known issues document (blogs.msdn.com/…/asynctargetingpackkb.aspx lists a work around though.

    @Ted: "Is there a planned .NET 4.1 framework update to push this DLL out to our end users?"

    No, we've specifically chosen an out-of-band release vehicle for this work. There are no plans to add this support to any of the downlevel platforms (.NET 4, Silverlight or Windows Phone 7.1).

    @Christian Fredh: "Will it work with .NET Framework 3.5 as well?"

    No, you'll need at least .NET 4.

    @Haacked and @Nguy?n Quý Hy: Thanks, we've identified the root cause and are working on a fix.

    @Stilgar: "Why does the nuget page list Windows Phone 8 as a target platform. Windows Phone 8 supports these things out of the box doesn't it?"

    We've designed the downlevel work to be compatible with platforms that ship the support in-box (.NET 4.5, .NET for Windows Store, and Windows Phone 8). That was required to make portable class libraries work across all platforms. This also allows for project references between a .NET 4.5 app and a .NET 4 class library.

    @Furkan Gozukara: I'm trying to find a contact, stay tuned.

    @adamgrahamcgi: I'd like to chat a bit more about this. Can you contact me at immol at microsoft dot com? Thanks.

    @Shecky Boy: Are you running the latest version of NuGet? You can check whether you have the latest version by going to Tools | Extensions and Updates. When the Extensions and Updates dialog opens, select Updates | Visual Studio Gallery and look for an entry titled NuGet Package Manager.

  25. @Furkan Gozukara: Found the right contact. For some reason, our software detected one of your posts as spam. We've fixed that so you should no longer experience any issues. Sorry for the inconvenience.

  26. dsplaisted says:

    @Shecky Boy: It looks like your Portable Class Library is targeting Windows Phone 7.  The async targeting pack supports Windows Phone 7.5 and higher, so switch your PCL to target WP7.5 and try again.

  27. Amenti says:

    I have the same problem as @Haacked and @Nguy?n.

    Great that you are working on that. Thanks a lot.

  28. There is a problem with NuGet package restore. Bcl.Async alters project file to import Microsoft.Bcl.Async.targets from packages folder. This means that it expects the content of packages folder to be stored in the source control, and if not, projects won't load.

    I've manually changed projects to import targets file from ..nuget folder and copied targets file there. But there must be a better way :-)

  29. Richard Szalay says:

    Hi guys, I think I've discovered a bug in the RC/final versions that causes WebClient.OpenReadTaskAsync to randomly throw a NullReferenceException when called from a background agent on Windows Phone.

    I've had to roll back to Microsoft.Bcl.1.0.11-beta and Microsoft.Bcl.Async.1.0.12-beta as they were the last versions to not have this behavior.

    Where is the best place for me to post the specifics?

  30. I have problems running FxCop in Wpf projects when i use Async library features. Everything except FxCop works fine.

    The error message i get is:

    1>MSBUILD : error : CA0001 : The following error was encountered while reading module 'WpfApplication3': Could not resolve member reference: [Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]System.Threading.Tasks.TaskEx::Delay.

    1>  Code Analysis Complete — 1 error(s), 0 warning(s)

    1>MSBUILD : error : Code Analysis detected errors.  See Code Analysis results window or log file for details.

    Do you have any suggestions?

    Thanks

  31. Kent Boogaart says:

    Thanks, but doesn't work in FX4. Create a new FX4 project, install package Microsoft.Bcl and immediately attempt to build. I get:

    Error 1 The "EnsureBindingRedirects" task failed unexpectedly.

    System.MissingMethodException: Method not found: 'System.String System.Reflection.AssemblyName.get_CultureName()'.

      at Roxel.BuildTasks.EnsureBindingRedirects.MergeBindingRedirectsForReferences()

      at Roxel.BuildTasks.EnsureBindingRedirects.Execute()

      at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

      at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult) BclTest

  32. Werner says:

    I had the same problem as described in forums.lhotka.net/…/11927.aspx. The only thing that worked for me was going back to the old async targeting pack.

  33. Vagif Abilov: Issues with package Restore. Please see Issue 5 in our known issues list:

    blogs.msdn.com/…/asynctargetingpackkb.aspx

    @Amenti, Haacked and @Nguy?n: Issue with non-AnyCPU configurations. we've updated our version of Microsoft.Bcl.Build. Updating that package should solve this issue.

    @Richard Szalay: You can send me an email under immol at microsoft dot com. Thanks!

    @Wolfgang Fuerst: We're looking into it. At first glance it seems like a unification issue in the VS static code analysis feature (FxCop). We've contacted the owners of it. Unfortunately, I don't think there is a workaround other than disabling code analysis for those projects :-(

    @Kent Boogaart: Thanks for reporting it. The root cause is that our infrastructure packages (such as Microsoft.Bcl.Build) require Visual Studio 2012/.NET 4.5. We've could probably recompile those packages against .NET 4 but in order to use the async/await keywords you need it to compile your code with .NET 4.5 build & compiler anyways, so this wouldn't help your particular case.

    @Werner: Which platform are you targeting? Could be that your application project is missing a reference to Microsoft.Bcl.Async?

  34. Microsoft.Bcl.Async is just awsome. :)

    I'm making number of presentations in Slovenia presenting this for PCL. :)

  35. Amenti says:

    @Immo: Issue with non-AnyCPU configurations. we've updated our version of Microsoft.Bcl.Build. Updating that package should solve this issue.

    It works great now. Thanks a lot. :)

  36. NW says:

    I get the following error when trying to build on the MSBuild server for a couple of my projects.  It builds fine on my machine.   What could I be missing up there?

    …SourcespackagesMicrosoft.Bcl.Build.1.0.5toolsMicrosoft.Bcl.Build.targets (74): The "EnsureBindingRedirects" task failed unexpectedly. System.MissingMethodException: Method not found: 'System.String System.Reflection.AssemblyName.get_CultureName()'.    at Roxel.BuildTasks.EnsureBindingRedirects.MergeBindingRedirectsForReferences()    at Roxel.BuildTasks.EnsureBindingRedirects.Execute()    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)

    It's strange.  Due to a dependency we took with a project we needed to add async to around 40 other projects in the solution (out of the 110).  Only a couple of the projects flag with the error above when building on TFS/MSBuild server.  

    The other issue I'm running into is now my SlowCheetah transforms no longer work at run time.  I have to comment out the bcl.targets import in the csproj project file of the exe project as a work around.  Which isn't a long term solution.

    Thanks!

    Neil

  37. @Jernej Kavka and Amenti: Thanks for the kind words — we are glad you are as excited as we are!

    @NW: This looks like you are building on a .NET 4 machine. Although we do support targeting .NET 4, we require the .NET 4.5 tools. This would also be required, if, for example, you try to use the new async/await keywords.

  38. Mark says:

    I have a multi-assembly VB.NET application (VS2012, .NET 4.0), and I've added the three Microsoft.Bcl(.Async, .Build) NuGet packages to all projects in the solution.  I am trying to use ClickOnce to deploy the executable, but System.Runtime.dll and System.Threading.Tasks.dll are not being included in the ClickOnce deployment.  They are not even listed in the "Application Files…" dialog, even though they are referenced by the project and "Copy Local" is true.  Any ideas why they aren't being included?  Is there some way to add them manually?

  39. I was having problems loading the solution when adding this package if my project was installed in a folder that contains the # (sharp) symbol (e.g. C# ProjectsProjectName…). It could not find the correct path to the package.

    Also, as somebody mentioned before, I had to manually add a reference to System.Net 4.0.0.0 for the package to correctly install in the project.

    I thought I'd report this stuff.

  40. @Mark: Thanks, we are looking into it.

    @Fog.Gene: Thanks for reporting this issue. I can reproduce it and filed a bug. We'll fix it in the next update.

  41. Richard says:

    Hi guys,

    Is there a reason that Microsoft.Threading.Tasks required System.Core 2.0.5 rather than 4.0? I just had to remove all asynchronous code from an application because production didn't have the assembly available.

    Is there a recommended way to get System.Core, 2.0.5 deployed with an application?

    Richard

  42. @Richard: Yes, this is by-design. The lower version number ensures compatibility with other platforms, such as Silverlight. System.Core 2.0.5 unifies with System.Core 4 so it is also compatible with .NET 4. Any reason you are concerned about the version number?

  43. Richard says:

    @Immo The version number itself doesn't bother me, per se. However, having simply added the nuget package, when we deploy into our production environment that System.Core assembly is apparently not available on that server and an assembly binding exception is thrown.

    Any thoughts on how to configure the project so that System.Core 2.0.5 is deployed with the application?

  44. @Richard: That sounds like a problem. Can you contact me at immol at microsoft dot com? We may need more details to repro this. If you're sending mail it would be helpful if you include the platform you're targeting.

    Thanks!

  45. Daniel says:

    I'm having the following problem: When the Microsoft.Bcl.Build.Tasks.dll is not present in the packages folder when VS starts, i'm getting build errors like "Error 6 The "ValidatePackageReferences" task could not be loaded from the assembly". NuGet restores the DLL, but a rebuild or restarting of VS does not solve the errors. Only after a restart of the whole system does the build process work again. (I make sure "Microsoft.Bcl.Build.targets" is always present, as described in Issue 5 of the known issues.)

  46. Miguel Hau says:

    Using VS 2012 I was getting the same error like Kent Boogart for my .net 4 project.

    Then I found this workaround.  I did have a missing culture in one of the elements.  After applying the workaround it worked.

    ——————————————————————

    Workaround

    ——————————————————————

    connect.microsoft.com/…/microsoft-bcl-build-1-0-5-fails-when-dependentassembly-is-missing-a-culture-attribute

    Open your project's web/app.config and look for any configuration/runtime/assemblyBinding/dependentAssembly/assemblyIdentity that are missing a culture attribute and add culture="neutral". Clean and rebuild.

    ——————————————————————

    But now I have another minor issue where inside the app.config assemblyBinding I have a probing element that gets erased every time I build the solution!

  47. redflares says:

    Building my silverlight project is just fine. But FxCop code analysis fails with the following error. Any thoughts?

    Unresolved  : 'Microsoft.Threading.Tasks' reference to System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.

    The indirectly-referenced assembly 'System.Runtime, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be found. This assembly is not required for analysis, however, analysis results could be incomplete. This assembly was referenced by: E:packagesMicrosoft.Bcl.Async.1.0.16libsl4Microsoft.Threading.Tasks.dll.

  48. ture says:

    When I run Code Analysis from within Visual Studio 2012 Premium, I get the following error:

    CA0001 Error Running Code Analysis CA0001 : The following error was encountered while reading module 'ConsoleApplication1': Could not resolve member reference: [Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]System.Threading.Tasks.TaskEx::Delay. [Errors and Warnings] (Global)

    Microsoft.Threading.Tasks.dll (v1.0.12) is located in the output folder together will all other dependencies and the application is running just fine.

    Is it a problem with code analysis? And is there any workaround or a fix in the works?

  49. Wayne says:

    man i've got the 2.0.5.0 type error  in Win8  but  KB2468871 cannot be installed  in win8.  what should i do…