Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

How to use 2 different package versions in a .net web site project

$
0
0

I have a web application project like this:

<Project Sdk="Microsoft.NET.Sdk.Web"><PropertyGroup><TargetFramework>net472</TargetFramework>

It is currently deployed on a Windows 2012, under IIS.
It is automatically deployed using TeamCity but probably GitHub Actions or MS DevOps pipeline is going to be used soon, so it will be build with the dotnet commands, probably on a Linux dockerized machine.

In the same solution I have a project (MyProject) that the web application project is referencing:

<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>

The project MyProject reference Package A and Package B.
That error came out after I updated the package A.
The package A uses FSharp.Data 4.2.2 .
The package B uses FSharp.Data 4.0.1 .

Said that, my current problem is the usual

"Could not load file or assembly 'FSharp.Data, Version=4.0.1.0, Culture=neutral, PublicKeyToken=null'".

I tried to add this BindingRedirect in the app.config of the web project:

<dependentAssembly><assemblyIdentity name="FSharp.Data" culture="neutral"/><bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0"/></dependentAssembly>

as well as this instruction in the website.proj file (and MyProject.csproj too):

<PropertyGroup><AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects><GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType></PropertyGroup>

I read many posts about this problem and the possible solutions I collected are:

  1. Register the FSharp.Data 4.0.1 in the GAC
    No. I'm not going to add post-build stuff and try to replicate it in a GitHub Action and create the responsability to update this stuff at any change/update of packages.
  2. Use BindingRedirectWell, this is what I tried and seems not working plus I read somewhere that BindingRedirect is dead/old-solution.
  3. Override the AssemblyResolve eventNo. I want to spend my time on creating things, not find a stratagem for a framework deficit.

Any suggestion?
Why the BindingRedirect is not working?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>