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

dotnet restore not using PackageReference condition

$
0
0

my project has multiple target frameworks, 2 of the package reference need to use a different version for .net461

enter image description here

when building in VS 2017 everything works and the dependency shows using the right versions.

enter image description here

but when build using dotnet cli, the dependency shows the wrong version is being use for .net461. is this a bug in dotnet cli?

enter image description here

I also try putting those 2 pkg in another ItemGroup tag with condition but still the same

update: for anyone else running in to this issue, I ended up using <Choose> with <when> condition to fix this.. so look something like this.

  <Choose>
<When Condition=" '$(TargetFramework)' == 'net461' ">
  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="7.0.1" />
    <PackageReference Include="RestSharp" Version="105.2.3" />
  </ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'net451' ">
  <ItemGroup>
    <PackageReference Include="RestSharp" Version="105.0.0" />
    <PackageReference Include="Newtonsoft.Json" Version="7.0.1" />
  </ItemGroup>
</When>
<Otherwise>
  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
    <PackageReference Include="RestSharp" Version="106.2.1" />
  </ItemGroup>
</Otherwise>


Viewing all articles
Browse latest Browse all 3067

Trending Articles



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