Skip to content

Cleans binding redirects - #1235

Merged
forki merged 4 commits into
fsprojects:masterfrom
mrinaldi:clean_binding_redirects
Nov 19, 2015
Merged

forki merged 4 commits into
fsprojects:masterfrom
mrinaldi:clean_binding_redirects

Conversation

@mrinaldi

Copy link
Copy Markdown
Contributor

This PR closes #1218.

It removes all binding redirects when the --hard flag is used.

It also marks all binding redirects with a <!--Paket--> comment.
This was the best way I've found to mark the paket's redirects.
Since it does that, it also removes all binding redirects marked with the comment, regardless the --hard is used.

Take this app.config for example:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Ploeh.AutoFixture" publicKeyToken="b24654c590009d4f" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="3.36.9.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="7.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <!-- Paket -->
    <assemblyIdentity name="xunit.extensions" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="1.9.2.1705" />
  </dependentAssembly>
</assemblyBinding></runtime></configuration>

This project only needs Castle.Core and Newtonsoft.Json binding redirect

Running paket install, this is the result:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Ploeh.AutoFixture" publicKeyToken="b24654c590009d4f" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="3.36.9.0" />
  </dependentAssembly>
  <dependentAssembly>
    <!--Paket-->
    <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="3.3.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <!--Paket-->
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="7.0.0.0" />
  </dependentAssembly>
</assemblyBinding></runtime></configuration>

Note that Ploeh.AutoFixture redirect was not removed because it was not marked.
xunit.extensions redirect was marked though, hence it was removed.

On the other hand, running paket install --hard this is the resulting file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <!--Paket-->
    <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="3.3.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <!--Paket-->
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="7.0.0.0" />
  </dependentAssembly>
</assemblyBinding></runtime></configuration>

Note that regardless the redirect was marked, it was removed, leaving only the required redirects.

@forki

forki commented Nov 18, 2015

Copy link
Copy Markdown
Member

/cc @isaacabraham

@baronfel

Copy link
Copy Markdown
Contributor

What's the rationale for using <!--Paket--> instead of <Paket>True</Paket> like in the .csproj?

<Reference Include="FSharpx.Collections">
    <HintPath>..\packages\FSharpx.Collections\lib\portable-net4+sl4+wp71+win8\FSharpx.Collections.dll</HintPath>
    <Private>True</Private>
    <Paket>True</Paket>
</Reference>

@isaacabraham

Copy link
Copy Markdown
Contributor

Was just going to ask the same question - surely better to use an attribute or element?

Also - whilst you're at this, can you see if it's possible to properly format the BR area of XML as well? If it's more than 60 seconds work, leave it and I'll raise an issue for it.

@mrinaldi

Copy link
Copy Markdown
Contributor Author

I checked the urn:schemas-microsoft-com:asm.v1 schema and for some reason I thought a <Paket>True</Paket> was not allowed. I never tested it though. <-- that's me being stupid

I just tested it and it does work. I'm gonna change it and update the PR.

@isaacabraham I'd rather do it in another PR

@isaacabraham

Copy link
Copy Markdown
Contributor

That's cool. Cheers.

@mrinaldi
mrinaldi force-pushed the clean_binding_redirects branch from 82b8838 to 3a79c92 Compare November 18, 2015 18:05
@mrinaldi

Copy link
Copy Markdown
Contributor Author

I've updated the PR to create <Paket> nodes instead.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <Paket>True</Paket>
    <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="3.3.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <Paket>True</Paket>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="7.0.0.0" />
  </dependentAssembly>
</assemblyBinding></runtime></configuration>

forki added a commit that referenced this pull request Nov 19, 2015
@forki
forki merged commit 56c66ad into fsprojects:master Nov 19, 2015
@forki

forki commented Nov 19, 2015

Copy link
Copy Markdown
Member

Awesome. Thanks

@mrinaldi
mrinaldi deleted the clean_binding_redirects branch November 19, 2015 15:07
@mavnn

mavnn commented Nov 20, 2015

Copy link
Copy Markdown
Contributor

@mrinaldi thanks for that! Saved me a lot of work :D

@mrinaldi

Copy link
Copy Markdown
Contributor Author

awesome

@forki

forki commented Nov 21, 2015

Copy link
Copy Markdown
Member

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Binding redirects not being updated on paket install

5 participants