PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, November 21, 2022

[FIXED] How to update dependencies not referenced directly as PackageReference via NuGet?

 November 21, 2022     nuget, visual-studio     No comments   

Issue

This question is similar to one described here.

When using "legacy"-style .csproj project files we have a separate packages.config file where all dependencies are listed, including transitive ones. This enables a use case when one installs a package with dependencies and then decides which transitive dependencies can be manually updated. So, the benefits are:

  • Dependencies are easily identifiable due to presence of a flat list
  • Fine-grain control over all dependency versions

E.g., after installing Autofac.WebApi2.Owin from NuGet, we have a picture like this:

Transitive dependencies which are clearly viewable can be manually updated very easily.

When using the new Sdk-style .csproj projects NuGet references are added as <PackageReference/> to the project file itself and transitive dependencies are referenced by MSBuild silently:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net462</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Autofac.WebApi2.Owin" Version="4.0.0" />
  </ItemGroup>
</Project>

So, to update transitive dependencies, one would have to

  1. Identify them (e.g. via obj/project.assets.json)
  2. Add all of them explicitly to the project
  3. Perform updates

And this has to be done after each update and for every (!) transitive dependency in the project which is clearly almost impossible.

Possible resolutions:

  • Adding transitive dependencies to the project automatically
  • Show transitive dependency updates in NuGet GUI

Unfortunately, no such feature was found in the documentation.

So, is there an easy way to get the best from two worlds?


Solution

Not possible at the moment but a discussion is open on Github.



Answered By - Andrey Kamyshanov
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing