In my web project I have a <dependentAssembly>
element with a <bindingRedirect>
element. The attributes of this are an oldVersion
with a range and a newVersion
.
I am changing the new version to be the same as the assembly I've added to my project references. When I rebuild the solution, it changes back to the original value.
Why is this happening and how do I stop it.
For those wanting specifics, the current element is:
<bindingRedirect oldVersion="0.0.0.0-15.1.0.0" newVersion="15.1.0.0"/>
What I want it to be is:
<bindingRedirect oldVersion="0.0.0.0-15.1.0.0" newVersion="2017.8.3.7"/>
According to this page, the newVersion
value does not have to be within the range specified in oldVersion
:
https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions
Turns out I was missing this message in the output window:
1>------ Rebuild All started: Project: IOService, Configuration: Debug Any CPU ------
1> Comparing two files: "C:\git\IOService\Source\IOService\web.config.Debug" with "C:\git\IOService\Source\IOService\web.config"
1> Comparing files C:\GIT\IOSERVICE\SOURCE\IOSERVICE\Web.config.debug and C:\GIT\IOSERVICE\SOURCE\IOSERVICE\WEB.CONFIG
1> ***** C:\GIT\IOSERVICE\SOURCE\IOSERVICE\Web.config.debug
1> <?xml version="1.0"?>
1> <configuration>
1> ***** C:\GIT\IOSERVICE\SOURCE\IOSERVICE\WEB.CONFIG
1> ´╗┐<?xml version="1.0"?>
1> <configuration>
1> *****
1>
1> Files are not the same. Copying "C:\git\IOService\Source\IOService\web.config.Debug" over "C:\git\IOService\Source\IOService\web.config"
So it turns out that VS was actually overwriting my main web.config with the .debug version because it did not match.