Microsoft.Bcl package dependency issue

Bhupinder Singh 21 Reputation points
2022-12-30T19:07:35.16+00:00

Hi,

I recently came to know that Microsoft.BCL NuGet package is deprecated. We have been using this package as a dependency with other NuGet packages in our product.

While I was upgrading the installed NuGet packages in our project there I noticed that we're also using Microsoft.BCL package. So I tried to uninstall this package from the

web API project then I come across the dependency issue with Microsoft.AspNet.WebApi.Core.5.2.7 NuGet package.

Package dependencies:

  1. Microsoft.AspNet.WebApi.Core.5.27
  2. Microsoft.AspNet.WebApi.Client.4.0.30506
  3. Microsoft.Net.Http.2.2.29
  4. Microsoft.Bcl.1.1.10

Unfortunately, I cannot remove all other packages.

How can I remove only Microsoft.Bcl.1.1.10 package to stop using the deprecated packages?

Looking for guidance or solution to overcome this problem.

Thank you,

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,415 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
302 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 25,876 Reputation points Microsoft Vendor
    2023-01-02T08:21:19.6+00:00

    Hi @Bhupinder Singh ,
    You can choose to use the package manager console(Tool-->NuGet package manager). Run the following command to uninstall the nuget package.

    Get-Package //for getting all the package you have installed.  
    

    and then

    Uninstall-Package YourPackageName  
    

    More information about Package Manager Console you can find here:
    https://learn.microsoft.com/en-us/nuget/reference/powershell-reference
    If it still doesn't work, it is recommended to delete all entries related to Microsoft.Bcl in the packages.config and .csproj files,
    such as the following entries.

    <Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />  
      <Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">  
        <Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />  
        <Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />  
      </Target>  
    //////  
    <package id="Microsoft.Bcl" version="1.1.10" targetFramework="net461" />  
    <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net461" />  
    

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,931 Reputation points
    2022-12-30T19:31:04.89+00:00

    Bcl is a compatibility layer when 4.6+ projects reference 4.5 or lower projects. To remove it, update all projects to 4.6 or later (hard to understand why you would not be on 4.8 at this point). Then all nuget packages need to be updated to a version that support 4.6 or netstandard 2.0

    Once this is done, you can remove bcl.

    Note: if you have a nuget package that requires bcl, I’d find a replacement because that means there are no security updates being done, and it has not had support for almost a decade.