Autorest runtimes install binding redirects
Runtime updates install the following binding redirects.
<dependentAssembly>
<assemblyIdentity name="Microsoft.Rest.ClientRuntime.Azure" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Rest.ClientRuntime" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
However, these assemblies are not backward compatible, so these binding redirects would break components.
This has nothing to do with AutoRest ClientRuntime, it's a nuget feature - http://docs.nuget.org/release-notes/nuget-1.2
That seems inherently dangerous. Is there a way to prevent NuGet from doing this?
No, but you can use bracketed dependency to prevent NuGet from using a higher version of the runtime with your client: "Microsoft.Rest.ClientRuntime": "[2.0, 3.0)"
Thanks!
It's an OK workaround, but it's conceptually incorrect. A component knows which versions are backward compatible, the consumer does not. For example, if versions 4-15 are compatible, version 15 will install
<bindingRedirect oldVersion="4.0.0.0-15.0.0.0" newVersion="15.0.0.0" />
If it's the consumer that decides, it will opt for "[4.0, 5.0)", because it does not know whether v5 will be compatible with v4. That would create unnecessary incompatibilities between consumers. In addition, some consumers will not be aware of the potential breaking changes and not specify the constraints. Even worse, a consumer in general does not know the versioning story of a dependent component. If they start specifying constraints on packages that are, in fact, backwards compatible, NuGet will eventually become useless because packages would be often mutually incompatible.
To clarify, I'm a producer of a package, not a consumer. The version Denis is talking about is in the nuspec when the package is built. Presumably NuGet uses this information when creating binding redirects.
This issue deals with dependencies. If you are not a consumer of Microsoft.Rest.ClientRuntime, then how are you affected?
Sorry, I misunderstood. I am a consumer of ClientRuntime, but I also know exactly which versions my dependent package is compatible with. I had simply made an error in my nuspec that allowed my package to bind to 3.x, when it's compatible only with 2.x.
Yes, this workaround will work, but it's in general incorrect. How can you know that your component is incompatible with 3.0 if 3.0 does not exist yet? And if it does exist, why are you targeting 2.0? You may have great answers in your specific case, but in general this does not make much sense...
If we can rely on package authors all following semver rules (which I know is a big if), then even before 3.x exists, I know I have only tested my package with 2.x. Therefore I should defensively version my dependency as [2.x,3.x).
If package authors all follow semver tools, NuGet is doomed. Most packages will become mutually incompatible really fast. See "When an upper bound makes sense" at http://blog.davidebbo.com/2011/01/nuget-versioning-part-2-core-algorithm.html