Closed mishra14 closed 1 year ago
Another similar situation is when updating a NuGet package that is not compatible with all tfms only update one packagereference or in some cases does not even update an existing reference -
If you have a package reference in multiple conditional item groups, then PM UI does not update all occurrences of the package.
Repro Steps-
Start with -
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.0;netstandard1.3;net45;uap10.0;portable-win81+wpa81;win8;wpa81;wp8;netcoreapp1.0</TargetFrameworks>
</PropertyGroup>
</Project>
InstallNewtonsoft.Json v3.5.8-
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.0;netstandard1.3;net45;uap10.0;portable-win81+wpa81;win8;wpa81;wp8;netcoreapp1.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="Newtonsoft.Json">
<Version>3.5.8</Version>
</PackageReference>
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.0;netstandard1.3;net45;uap10.0;portable-win81+wpa81;win8;wpa81;wp8;netcoreapp1.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="Newtonsoft.Json">
<Version>3.5.8</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'win8'">
<PackageReference Include="Newtonsoft.Json">
<Version>7.0.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'wp8'">
<PackageReference Include="Newtonsoft.Json">
<Version>7.0.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'uap10.0'">
<PackageReference Include="Newtonsoft.Json">
<Version>7.0.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'wpa81'">
<PackageReference Include="Newtonsoft.Json">
<Version>7.0.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'portable-win81+wpa81'">
<PackageReference Include="Newtonsoft.Json">
<Version>7.0.1</Version>
</PackageReference>
</ItemGroup>
</Project>
After the third step, the existing reference to v3.5.8 is not even updated!
Doing my own experiment on this. Using VisualStudio 15.5.7, the nuget package reference was only updated for the framework which appears first inside <TargetFrameworks />
.
Here is my usual flow deciding how to target multiple frameworks. Hope it helps somehow:
https://mynkow.github.io/How-to-add-netstandard2.0-to-a-C-.NET-4.5-class-library/
@JonDouglas just wanted to bring your attention to this one as the issue we created was closed and linked here. Want to make sure this doesn’t get lost for net6.
Matching the labels to the closed issue by adding the partner tag.
FYI I have the same case building GooglePlayServices. Funny it is just one (1) project. At the beginning I thought that older (deprecated to be) Cake aliases (possibly resolving to older nuget) were the culprit, but updating did not help.
Workaround is to run Cake DotNetRestore
(alias for dotnet restore
) twice. Seems to be working.
Ping me if you need repro sample (whole GPS repo 😃 )
This issue was referred to from VS Dev Community. It is related to https://github.com/microsoft/WindowsAppSDK/issues/2338 and various other issues and discussions about developers getting lost in confusing error messages after their nuget package updates as their PackageReference
items get duplicated.
This scenario is now very common when dealing with multi-targeted projects whether it's MAUI, Uno Platform or any other .NET iOS/Android based project.
Scenarios include adding platform-specific controls, native library bindings or native DllImports/Library imports for single TargetFrameworks.
I closed this VS Feedback as duplicate of this issue: https://developercommunity.visualstudio.com/t/For-C-project-targeting-multiple-platfo/10353470
This is a problem in all serious MAUI, Xamarin.Forms, Uno and Avalonia projects. You always have to fix the .csproj files manually after updating the dependencies.
I wonder if it would not be less effort to just fix this problem than to close every duplicate issue in the last six years and link it to this one. By now every support agent should know about this.
If you have a package reference in multiple conditional item groups, then PM UI does not update all occurrences of the package.
Repro Steps-
Start with -
Install NUnit v3.4.0 -
After the third step, we add an unconditional reference to NUnit v3.6.0 without removing existing conditional package references. This leads to a customer bug - vsfeedback/812089
Related: https://github.com/NuGet/Home/issues/5521