I have a reference to a .Net Standard 2.0 library that requires Microsoft.AspNet.WebApi.Client 5.2.4. This has a lot of dependencies that need to be redirected to use newer vers
Expanding on the other answer from this question, here's a solution that supports incremental builds and uses absolute paths for greater flexibility:
Add this somewhere in your solution (I named it UpdateBindingRedirect.ps1
):
param ($from, $to)
$fromFileXml = [xml](Get-Content -Path $from -Raw)
$toFileXml = [xml](Get-Content -Path $to -Raw)
if ( $toFileXml.configuration.runtime.InnerXml -Ne $fromFileXml.configuration.runtime.InnerXml ) {
$toFileXml.configuration.runtime.InnerXml = $fromFileXml.configuration.runtime.InnerXml
$toFileXml.Save($to)
}
Add this to your csproj
: