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

前端 未结 3 1251
攒了一身酷
攒了一身酷 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:12

    It appears that AutoGenerateBindingRedirects will not work for web projects per https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/how-to-enable-and-disable-automatic-binding-redirection.

    Inspecting the output from the build shows that binding redirects are generated just not in the Web.config. Instead, they are in $(AssemblyName).dll.config. This file has the original configuration from Web.config as well as the binding redirects.

    To put it all together you can have MSBuild copy the resulting config back to the Web.config. To do this you would add the following to the csproj:

    
      
    
    

提交回复
热议问题