Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleans binding redirects #1235

Merged
merged 4 commits into from
Nov 19, 2015
Merged

Conversation

mrinaldi
Copy link
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="b24654c595009d4f" 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="b24654c595009d4f" 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
Copy link
Member

forki commented Nov 18, 2015

/cc @isaacabraham

@baronfel
Copy link
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
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
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
Contributor

That's cool. Cheers.

@mrinaldi
Copy link
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
Copy link
Member

forki commented Nov 19, 2015

Awesome. Thanks

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

mavnn commented Nov 20, 2015

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

@mrinaldi
Copy link
Contributor Author

awesome

@forki
Copy link
Member

forki commented Nov 21, 2015

❤️

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