Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM UI multi targeting experience is incomplete - support for updating and uninstalling conditional package versions #4681

Closed
mishra14 opened this issue Feb 23, 2017 · 8 comments · Fixed by NuGet/NuGet.Client#5499

Comments

@mishra14
Copy link
Contributor

mishra14 commented Feb 23, 2017

If you have a package reference in multiple conditional item groups, then PM UI does not update all occurrences of the package.

Repro Steps-

  1. Start with -
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard1.0;netstandard1.3;net45;uap10.0;portable-win81+wpa81;win8;wpa81;wp8</TargetFrameworks>
  </PropertyGroup>
</Project>
  1. Install NUnit v3.4.0 -
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard1.0;netstandard1.3;net45;uap10.0;portable-win81+wpa81;win8;wpa81;wp8</TargetFrameworks>
  </PropertyGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'win8'">
    <PackageReference Include="NUnit">
      <Version>3.4.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'wp8'">
    <PackageReference Include="NUnit">
      <Version>3.4.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'uap10.0'">
    <PackageReference Include="NUnit">
      <Version>3.4.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'wpa81'">
    <PackageReference Include="NUnit">
      <Version>3.4.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'net45'">
    <PackageReference Include="NUnit">
      <Version>3.4.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'portable-win81+wpa81'">
    <PackageReference Include="NUnit">
      <Version>3.4.0</Version>
    </PackageReference>
  </ItemGroup>
</Project>
  1. Update NUnit to v3.6.0 through the PM UI -
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard1.0;netstandard1.3;net45;uap10.0;portable-win81+wpa81;win8;wpa81;wp8</TargetFrameworks>
  </PropertyGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'win8'">
    <PackageReference Include="NUnit">
      <Version>3.4.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'wp8'">
    <PackageReference Include="NUnit">
      <Version>3.4.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'uap10.0'">
    <PackageReference Include="NUnit">
      <Version>3.4.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'wpa81'">
    <PackageReference Include="NUnit">
      <Version>3.4.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'net45'">
    <PackageReference Include="NUnit">
      <Version>3.4.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'portable-win81+wpa81'">
    <PackageReference Include="NUnit">
      <Version>3.4.0</Version>
    </PackageReference>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="NUnit" Version="3.6.0" />
  </ItemGroup>
</Project>

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: #5521

@mishra14
Copy link
Contributor Author

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-

  1. 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>
  1. 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>
  1. Update Newtonsoft.Json to v7.0.1 through the PM UI -
<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!

@mynkow
Copy link

mynkow commented Feb 27, 2018

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/

@jainaashish jainaashish changed the title PM UI package update should update all tfms for the package PM UI package update should only update applicable tfms for the package in multi tfms Nov 9, 2018
@nkolev92 nkolev92 changed the title PM UI package update should only update applicable tfms for the package in multi tfms PM UI multi tfm experience is incomplete Feb 8, 2020
@nkolev92 nkolev92 changed the title PM UI multi tfm experience is incomplete PM UI multi targeting experience is incomplete Feb 8, 2020
@Redth
Copy link

Redth commented Oct 26, 2020

@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.

@nkolev92 nkolev92 removed this from the Backlog milestone Oct 26, 2020
@nkolev92
Copy link
Member

Matching the labels to the closed issue by adding the partner tag.

@moljac
Copy link

moljac commented Mar 16, 2022

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 😃 )

@jeromelaban
Copy link

This issue was referred to from VS Dev Community. It is related to microsoft/WindowsAppSDK#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.

@donnie-msft
Copy link
Contributor

I closed this VS Feedback as duplicate of this issue: https://developercommunity.visualstudio.com/t/For-C-project-targeting-multiple-platfo/10353470

@MichaelRumpler
Copy link

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.

@nkolev92 nkolev92 self-assigned this Sep 26, 2023
@nkolev92 nkolev92 modified the milestone: 6.8 Oct 31, 2023
@jgonz120 jgonz120 added this to the 6.9 milestone Jan 31, 2024
@nkolev92 nkolev92 changed the title PM UI multi targeting experience is incomplete PM UI multi targeting experience is incomplete - support for updating and uninstalling conditional package versions Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment