问题
my project has multiple target frameworks, 2 of the package reference need to use a different version for .net461
when building in VS 2017 everything works and the dependency shows using the right versions.
but when build using dotnet cli, the dependency shows the wrong version is being use for .net461. is this a bug in dotnet cli?
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>
来源:https://stackoverflow.com/questions/54485020/dotnet-restore-not-using-packagereference-condition