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

Some dll (System.Net.Http) references twice in csproj #2352

Closed
seestems opened this issue May 19, 2017 · 10 comments · Fixed by #2628
Closed

Some dll (System.Net.Http) references twice in csproj #2352

seestems opened this issue May 19, 2017 · 10 comments · Fixed by #2628
Labels

Comments

@seestems
Copy link

Our solution targets .NET 4.6.1 and at the top of paket.dependencies we have Framework: net461 with redirects: on.
We reference .Net and .Net Core packages:

nuget Microsoft.AspNet.WebApi
nuget Microsoft.EntityFrameworkCore.SqlServer

After packet intall , System.Net.Http referenced twice in .csproj .

Compilation Error:

error CS0433: The type StringContent' exists in both 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Net.Http, Version=4.1.1.1, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a

Bindings:

  <dependentAssembly>
    <Paket>True</Paket>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.1.1.1" />
  </dependentAssembly>

Simple project is in attachement:
PaketWebApp.zip

No workaround found for the moment.

@matthid
Copy link
Member

matthid commented May 20, 2017

yes something is broken there

  <Choose>
    <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
      <ItemGroup>
        <Reference Include="System.Net.Http">
          <Paket>True</Paket>
        </Reference>
        <Reference Include="System.Net.Http.Formatting">
          <HintPath>..\packages\Microsoft.AspNet.WebApi.Client\lib\net45\System.Net.Http.Formatting.dll</HintPath>
          <Private>True</Private>
          <Paket>True</Paket>
        </Reference>
      </ItemGroup>
    </When>
  </Choose>

and later

  <Choose>
    <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
      <ItemGroup>
        <Reference Include="System.Core">
          <Paket>True</Paket>
        </Reference>
        <Reference Include="System.Net.Http">
          <HintPath>..\packages\System.Net.Http\lib\net46\System.Net.Http.dll</HintPath>
          <Private>True</Private>
          <Paket>True</Paket>
        </Reference>
      </ItemGroup>
    </When>
  </Choose>

@matthid matthid added the bug label May 20, 2017
@Gonnagle
Copy link
Contributor

We are struggling with this also. Related to https://github.com/dotnet/corefx/issues/11100 we are trying to use version found in nuget (4.3.2) instead of the one in GAC. After uninstalling the original reference and installing the nuget with paket we ended up to this exact situation.

Manually removing the reference before System.Net.Http.Formatting seemed to temporarily resolve the issue (getting us to other version mismatches related to netstandard, but they are another story...)

@nikolaia
Copy link

Have this same problem. Removing the following reference to the GAC from the .csproj file fixes it:

        <Reference Include="System.Net.Http">
          <Paket>True</Paket>
        </Reference>

However it returns as soon as paket installor upgrade is run again.

@forki
Copy link
Member

forki commented Aug 18, 2017

Will try to take a look at this later today or during the weekend

@forki
Copy link
Member

forki commented Aug 18, 2017

mhm I just tried to run paket update on the attached zip and it only references System.Net.Http via the GAC. And only once. What am I missing?

@nikolaia
Copy link

We have a direct reference to the https://www.nuget.org/packages/System.Net.Http/ nugget in our project, you could try adding that to the project. We are using net461.

@forki
Copy link
Member

forki commented Aug 18, 2017

yes then we have the duplicates - which is no wonder tbh.
let's see if we can do stupid workaround here

@forki
Copy link
Member

forki commented Aug 18, 2017

possible solution in #2628

@nikolaia
Copy link

Seems like #2628 fixed the duplicate System.Net.Http references (awesome :D). However I can't remember having the following bug before, maybe #2628 introduced it? This is a project that holds a reference to the System.Net.Http NuGet package:

After running paket install I can see it change the location of the FSharp.Core binding redirect:

C:\Projects\SomeProject [b_paketbugquestionmark +0 ~1 -0 !]> git diff
diff --git a/src/Some.Project.IntegrationTests/app.config b/src/Some.Project.IntegrationTests/app.config
index 87a6834..c109a94 100644
--- a/src/Some.Project.IntegrationTests/app.config
+++ b/src/Some.Project.IntegrationTests/app.config
@@ -11,6 +11,11 @@

        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
   <dependentAssembly>
+    <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+    <bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.3.0.0" />
+  </dependentAssembly>
+</assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+  <dependentAssembly>
     <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
     <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
   </dependentAssembly>
@@ -74,10 +79,5 @@
     <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
     <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
   </dependentAssembly>
-</assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
-  <dependentAssembly>
-    <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
-    <bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.3.0.0" />
-  </dependentAssembly>
 </assemblyBinding></runtime>
 </configuration>
\ No newline at end of file

So I commit it and run paket install again:

C:\Projects\SomeProject [b_paketbugquestionmark +0 ~1 -0 !]> git diff
diff --git a/src/Some.Project.IntegrationTests/app.config b/src/Some.Project.IntegrationTests/app.config
index c109a94..87a6834 100644
--- a/src/Some.Project.IntegrationTests/app.config
+++ b/src/Some.Project.IntegrationTests/app.config
@@ -11,11 +11,6 @@

        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
   <dependentAssembly>
-    <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
-    <bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.3.0.0" />
-  </dependentAssembly>
-</assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
-  <dependentAssembly>
     <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
     <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
   </dependentAssembly>
@@ -79,5 +74,10 @@
     <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
     <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
   </dependentAssembly>
+</assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+  <dependentAssembly>
+    <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+    <bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.3.0.0" />
+  </dependentAssembly>
 </assemblyBinding></runtime>
 </configuration>
\ No newline at end of file
C:\Projects\SomeProject [b_paketbugquestionmark +0 ~1 -0 !]> git cmm "cm2"

It changed it back. So I commit it and run another paket install to see if we can go full circle:

C:\Projects\SomeProject [b_paketbugquestionmark +0 ~1 -0 !]> git diff
diff --git a/src/Some.Project.IntegrationTests/app.config b/src/Some.Project.IntegrationTests/app.config
index 87a6834..c109a94 100644
--- a/src/Some.Project.IntegrationTests/app.config
+++ b/src/Some.Project.IntegrationTests/app.config
@@ -11,6 +11,11 @@

        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
   <dependentAssembly>
+    <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+    <bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.3.0.0" />
+  </dependentAssembly>
+</assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+  <dependentAssembly>
     <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
     <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
   </dependentAssembly>
@@ -74,10 +79,5 @@
     <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
     <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
   </dependentAssembly>
-</assemblyBinding><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
-  <dependentAssembly>
-    <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
-    <bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.3.0.0" />
-  </dependentAssembly>
 </assemblyBinding></runtime>
 </configuration>
\ No newline at end of file

If I keep going paket install switches the assemblyBinding every time. If you think it's unrelated I'll post another bug.

@forki
Copy link
Member

forki commented Aug 21, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants