Skip to content

Upgrading NuGet packages in Visual Studio doesn't work when project targets multiple frameworks #5521

@Daniel15

Description

@Daniel15

Details about Problem

NuGet product used: Visual Studio UI

dotnet.exe --version: 1.0.0

VS version: Visual Studio 2017

OS version: 10.0.16193.1001

Worked before? If so, with which NuGet version: Unknown

Detailed repro steps so we can see the same problem

Sample csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <Description>JSPool facilitates easy integration of JavaScript scripting into a .NET application in a scalable and performant manner. It does so by creating a pool of engines that can be reused multiple times, making it easy to use JavaScript libraries that have long initialisation times without having to create a new engine every time.
    
See https://dan.cx/projects/jspool for usage instructions.</Description>
    <Copyright>Daniel Lo Nigro</Copyright>
    <VersionPrefix>3.0.0</VersionPrefix>
    <TargetFrameworks>net40-client;net451;netstandard1.3</TargetFrameworks>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <AssemblyName>JSPool</AssemblyName>
    <AssemblyOriginatorKeyFile>../key.snk</AssemblyOriginatorKeyFile>
    <SignAssembly>true</SignAssembly>
    <PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
    <PackageId>JSPool</PackageId>
    <PackageTags>javascript;js;javascriptengineswitcher;msiejavascriptengine;v8;clearscript</PackageTags>
    <PackageProjectUrl>http://dan.cx/projects/jspool</PackageProjectUrl>
    <PackageLicenseUrl>https://github.com/Daniel15/JSPool/blob/master/LICENSE</PackageLicenseUrl>
    <NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard1.3' ">1.6.0</NetStandardImplicitPackageVersion>
    <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
    <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
  </PropertyGroup>

  <!-- https://github.com/dotnet/sdk/issues/294 -->
  <PropertyGroup Condition="'$(TargetFramework)' == 'net40-client'">
    <TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <TargetFrameworkProfile>client</TargetFrameworkProfile>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="JavaScriptEngineSwitcher.Core" Version="2.4.9" />
  </ItemGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
    <PackageReference Include="System.Diagnostics.TraceSource" Version="4.0.0" />
    <PackageReference Include="System.IO.FileSystem.Watcher" Version="4.0.0" />
  </ItemGroup>
</Project>

Note that this csproj is conditionally including a few NuGet packages (System.Diagnostics.TraceSource and System.IO.FileSystem.Watcher) just for netstandard1.3.

Try to upgrade System.IO.FileSystem.Watcher to the latest version in the Visual Studio UI.

Expected behaviour: It works
Actual behavior: It throws:

Package System.IO.FileSystem.Watcher 4.3.0 is not compatible with net40-client (.NETFramework,Version=v4.0,Profile=Client). Package System.IO.FileSystem.Watcher 4.3.0 supports:
  - monoandroid10 (MonoAndroid,Version=v1.0)
  - monotouch10 (MonoTouch,Version=v1.0)
  - net46 (.NETFramework,Version=v4.6)
  - netstandard1.3 (.NETStandard,Version=v1.3)
  - xamarinios10 (Xamarin.iOS,Version=v1.0)
  - xamarinmac20 (Xamarin.Mac,Version=v2.0)
  - xamarintvos10 (Xamarin.TVOS,Version=v1.0)
  - xamarinwatchos10 (Xamarin.WatchOS,Version=v1.0)
One or more packages are incompatible with .NETFramework,Version=v4.0,Profile=Client.

It looks like the upgrade is not taking the condition ('$(TargetFramework)' == 'netstandard1.3') into account and is instead trying to upgrade it for all target frameworks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions