Azure-pipelines-tasks: DotNetCoreCLI .NET Core 3.1 - IAsyncEnumerable exists in both Microsoft.Bcl.AsyncInterfaces and System.Runtime

Created on 25 Jan 2020  路  2Comments  路  Source: microsoft/azure-pipelines-tasks

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: DotNetCoreCLI@2

list here (V# not needed):
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks

Environment

  • Agent - Hosted

https://msasg.visualstudio.com/Bing_UX/_build/results?buildId=9345941&view=logs&j=3dc8fd7e-4368-5a92-293e-d53cefc8c4b3&t=7510ef29-db76-5a4c-4d87-8cd81d6b33b8&l=135

Issue Description

Using DotNetCoreCLI to build .NET Core 3.1 project(s). Building and running them in Visual Studio 2019 works fine, but the pipeline outputs this error:

Build fails when it reaches a class that uses IAsyncEnumerable.

error CS0433: The type 'IAsyncEnumerable' exists in both 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

The projects we are building depend on multiple Azure libraries, including Azure.Security.KeyVault.Secrets, Azure.Storage.Blobs, Azure.Storage.Queues, etc., which all depend on Azure.Core, which in turn references Microsoft.Bcl.AsyncInterfaces.

Microsoft.Bcl.AsyncInterfaces implements IAsyncEnumerable, which is now included natively in .Net Core 3.1.

Task logs

Can't since this is an internal Microsoft project. Just click on the results link above or contact me internally - alias ovidan

Release bug

Most helpful comment

Worked with @pakrym to fix this for us. Here is some information that may help others that get into the same situation:

  • The reason this failure only happened in the Azure Pipelines build is that our pipeline used to restore nuget packages using an older version of nuget (4.7.1).
  • It seems that newer versions of nuget, as well as the build-in dotnet restore command, contain some magic code which omits the Microsoft.Bcl.AsyncInterfaces package from the restore tree, since it detects that we are using NET Core 3.1.

So in conclusion, either use a newer version of nuget in the pipeline, or better yet, use the dotnet restore command.

All 2 comments

Before you ask, I did try working around this with a using alias, but that does not work. I also don't get why it builds fine in Visual Studio and on my machine, but not on Azure Pipelines. They seem to be using the same SDK Version: 3.1.100

Worked with @pakrym to fix this for us. Here is some information that may help others that get into the same situation:

  • The reason this failure only happened in the Azure Pipelines build is that our pipeline used to restore nuget packages using an older version of nuget (4.7.1).
  • It seems that newer versions of nuget, as well as the build-in dotnet restore command, contain some magic code which omits the Microsoft.Bcl.AsyncInterfaces package from the restore tree, since it detects that we are using NET Core 3.1.

So in conclusion, either use a newer version of nuget in the pipeline, or better yet, use the dotnet restore command.

Was this page helpful?
0 / 5 - 0 ratings