0

In my project, I have a nuget package "package1" that uses System.Net.Http.dll (reference 4.0.0.0 from .net framework 4.6.2). I also have a nuget package "package2" that references System.Net.Http.dll (name of nuget package System.Net.Http 4.3.4).

How can I make my package "package2" overwrite the old version of the framework on the bin directory by nuspec file? I don't have access to the package code "package1", only access to the package code "package2".

nuspec in package ICI.Doc.WebApi.Cliente:

<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>$Id$</id>
    <version>$Version$</version>
    <title>$Title$</title>
    <authors>$Authors$</authors>
    <owners>$Owners$</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>$Description$</description>
    <summary>$Summary$</summary>
    <releaseNotes>$ReleaseNotes$</releaseNotes>
    <copyright>Copyright ©  2019</copyright>
    <dependencies>
      <dependency id="Microsoft.Rest.ClientRuntime" version="0.9.6" />
      <dependency id="Newtonsoft.Json" version="12.0.2" />
      <dependency id="System.Net.Http" version="4.3.4" />
      <dependency id="System.Security.Cryptography.Algorithms" version="4.3.0" />
      <dependency id="System.Security.Cryptography.Encoding" version="4.3.0" />
      <dependency id="System.Security.Cryptography.Primitives" version="4.3.0" />
      <dependency id="System.Security.Cryptography.X509Certificates" version="4.3.0" />
    </dependencies>
  </metadata>
  <files>
    <file src="bin\Release\*.*" target="lib\net462" />
  </files>
</package>

project.json in Grh.Negocio:

{
  "version": "2.0.0.1",
  "dependencies": {
    "Grh": "*",
    "Grh.Dados": "*",
    "ICI.Doc.WebApi.Cliente": "1.0.5.10",  //references nuget System.Net.Http 4.3.4
    "ICICore.Seguranca": "3.1.0"  //references frameworkAssembly System.Net.Http 4.0.0.0
  },
  "frameworks": {
    "net462": {
    }
  }
}
3
  • I think you're looking for binding redirects, but I don't really understand the question you're asking. What's the actual problem you're experiencing? FileNotFoundException at runtime when it can't load a different version of the assembly? Commented May 22, 2020 at 13:24
  • I have edited the source above. The framework dll win in target assembly resolution. Commented May 22, 2020 at 13:53
  • project.json isn't really supported by a lot of tooling any more. .NET Core introduced it during early alphas, but by late previews it had gone back to csproj, so there was never a supported version of .NET Core or the .NET SDK that supported project.json. UWP did ship project.json projects for some time, but they use csproj in VS2019 as well. In any case, you still haven't provided any error messages and explained what problems this package has when used in projects. Commented May 22, 2020 at 15:23

1 Answer 1

1

This has been done automatically when you install new version. also when you install a package, the package dependency is resolved automatically.

Sign up to request clarification or add additional context in comments.

1 Comment

It should be like this, but Visual Studio 2015 gives preference to the old dll that is in the framework

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.