Why doesn't AutogenerateBindingRedirects work for a Web.config in Visual Studio 2017

前端 未结 3 1187
攒了一身酷
攒了一身酷 2021-02-19 20:31

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

3条回答
  •  鱼传尺愫
    2021-02-19 21:08

    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:

      
        
        
      
    

提交回复
热议问题