Joshua
Joshua

Reputation: 43337

How do I exclude a dependency of Microsoft.NETCore.APP

How do I exclude a dependency of Microsoft.NETCore.App so I can replace it with a locally compiled (bugfix) version.

I carried out the normal procedure for replacing a package by making one with a higher version number, and tried to compile. The build tried to link against both and died at the compile step with CS0433 due to duplicate references.

<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
       <OutputType>Exe</OutputType>
       <TargetFramework>netcoreapp2.1</TargetFramework>
   </PropertyGroup>

   <ItemGroup>
       <ProjectReference Include="..\System.Threading.ThreadPool\System.Threading.ThreadPool.csproj"/>
       <ProjectReference Update="..\System.Threading.ThreadPool\System.Threading.ThreadPool.csproj"/>
   </ItemGroup>
</Project>

Compile error:

C:\Program FFiles\dotnet\sdk\2.1.604\Microsoft.Common.CurrentVersion.targets(2114,5): warning MSB3243: No way to resolve conflict between "System.Threading.ThreadPool, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null" and "System.Threading.ThreadPool, Version=4.1.1.0, Culture=neutral, PublicKeyTokn=b03f5f7f11d50a3a". Choosing "System.Threading.ThreadPool, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null" arbitrarily. [path]

Program.cs(17,13): error CS0433: The type 'ThreadPool' exists in both 'System.Threading.ThreadPool, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Threading.ThreadPool, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null' [path]

Upvotes: 1

Views: 332

Answers (1)

omajid
omajid

Reputation: 15233

I assume you compiled corefx to produce the updated System.Threading.ThreadPool package?

In that case corefx has docs that spell out how do this. To summarize:

  1. Build corefx with your fixes

  2. Get the version number of the corefx that you built

  3. Add a PackageReference to Microsoft.Private.CoreFx.NETCoreApp with the version from step 2

  4. Add a nuget.config that points to the bin directory of the corefx that you built.

  5. restore and publish your project to pick up the custom-modified corefx.

Upvotes: 1

Related Questions