Sebastiaan Dammann

Blogging, coding, 3D printing and reviews

Temporary overriding a PackageReference bin path

.NET projects offer <PackageReference> items which are used for including NuGet packages in your project. However, the <PackageReference> is quite black-box at first sight, and does not allow overriding the binary path in case you’d like to temporary use locally built binary. You may need it if public symbols are not available.

You can use the snipped below in your csproj file or any Directory.Build.targets to override the binary path of the NuGet package reference. This example is for LibGit2Sharp.

<Target Name="ReplaceReference" AfterTargets="ResolveLockFileReferences">
  <Reference Remove="$(USERPROFILE)\.nuget\packages\libgit2sharp\0.26.0\lib\net46\LibGit2Sharp.dll"/>
  <Reference Include="$(USERPROFILE)\.nuget\packages\libgit2sharp\0.26.0\lib\net46\LibGit2Sharp.dll">

Good luck!

What are your thoughts?