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

Dependencies on .NET Framework #878

Closed
yishaigalatzer opened this issue Jul 2, 2015 · 10 comments
Closed

Dependencies on .NET Framework #878

yishaigalatzer opened this issue Jul 2, 2015 · 10 comments
Labels
Functionality:Update The update package feature/command/experience Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Product:VS.Client Type:Bug
Milestone

Comments

@yishaigalatzer
Copy link

Moved from - NuGet/NuGetGallery#2574

I did a quick search through issues so sorry if this has been mentioned but why are some packages not defining/stating their dependency on .specific NET framework versions?

For example... I have a .NET 4.0 Web App and Microsoft.AspNet.Web.Optimization.WebForms v1.1.3 allows me to install it via powershell console. The gallery page does not state that the latest version is for .NET 4.5 but Nuget happily installs the version despite it not being able to add the reference into a .NET 4.0 project.

Similar issues with Microsoft.AspNet.Mvc

Also the updat-package isn't aware of the .NET dependency and will happily upgrade to the incompatible version.

It seems the UI dialog filters out the invalid packages. But it would be nice is the project page in the gallery would also make it a little more obvious.

Note, I've got installed Package Manager Console Host Version 2.8.60318.734

Here is some -WhatIf output for my .NET 4.0 Web App...
PM> update-package -WhatIf Microsoft.AspNet.Mvc -ProjectName MyWebApp
Updating 'Microsoft.AspNet.Mvc' from version '4.0.40804.0' to '5.2.3' in project 'MyWebApp'.
Remove 'Microsoft.AspNet.Mvc 4.0.40804.0' from project MyWebApp.
Remove 'Microsoft.AspNet.WebPages 2.0.30506.0' from project MyWebApp.
Remove 'Microsoft.AspNet.Razor 2.0.30506.0' from project MyWebApp.
Add 'Microsoft.AspNet.Razor 3.2.3' to project MyWebApp.
Install 'Microsoft.AspNet.Razor 3.2.3'
Add 'Microsoft.AspNet.WebPages 3.2.3' to project MyWebApp.
Install 'Microsoft.AspNet.WebPages 3.2.3'
Add 'Microsoft.AspNet.Mvc 5.2.3' to project MyWebApp.
Install 'Microsoft.AspNet.Mvc 5.2.3'
Uninstall 'Microsoft.AspNet.Mvc 4.0.40804.0'.
Uninstall 'Microsoft.AspNet.WebPages 2.0.30506.0'.
Uninstall 'Microsoft.AspNet.Razor 2.0.30506.0'.

Note, without the -WhatIf it does happily upgrade the packages despite it not being valid.

@yishaigalatzer
Copy link
Author

Note that MVC 5.2.3 does have a specific dependency on .NET 4.5

@BlackMael
Copy link

MVC 5.2.3 has assemblies that target .NET 4.5 but I cannot see where it explicitly states .NET 4.5 is required even though it is implied.

The dependencies for WebPages and Razor don't target a specific framework in the Package Dependency Editor (I'm using NuGet Package Explorer)

@yishaigalatzer
Copy link
Author

You can see that the mvc assemblies are placed in the net45 folder inside the lib folder

@BlackMael
Copy link

Yes. Only after downloading the package and opening it up manually. The problem see is should I have to manually interrogate each and every package to check it supports the .NET framework I'm working in? I feel I should be able to trust the "Update" option to not let me upgrade a package when it would result in breaking my project because the new version is not compatible with the .NET framework I'm working in.

@yishaigalatzer
Copy link
Author

Can you tell us what version of visual studio and nuget you are using? We can take a look at this for nuget 3.2

@yishaigalatzer yishaigalatzer added this to the 3.2.0-Beta milestone Jul 7, 2015
@yishaigalatzer yishaigalatzer added Product:VS.Client Type:Bug Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. labels Jul 7, 2015
@BlackMael
Copy link

Hi yishaigalatzer

I'm using NuGet 2.8.60318.734 in both VS2013 Professional and Community Edition.

@danliu
Copy link

danliu commented Jul 9, 2015

I can repro the issue with both NuGet 2.8.60318.734 and NuGet 3.0.

Repro steps:

  1. create a new empty web application in .net4
  2. Install-Package Microsoft.AspNet.Mvc -Version 4.0.40804
  3. update-package microsoft.aspnet.mvc -whatif

Expected: no package updates available for the current project

Actual:

PM> update-package microsoft.aspnet.mvc -whatif
Updating 'Microsoft.AspNet.Mvc' from version '4.0.40804.0' to '5.2.3' in project 'WebApplication1'.
Remove 'Microsoft.AspNet.Mvc 4.0.40804.0' from project WebApplication1.
Remove 'Microsoft.AspNet.WebPages 2.0.20710.0' from project WebApplication1.
Remove 'Microsoft.AspNet.Razor 2.0.20710.0' from project WebApplication1.
Add 'Microsoft.AspNet.Razor 3.2.3' to project WebApplication1.
Install 'Microsoft.AspNet.Razor 3.2.3'
Add 'Microsoft.AspNet.WebPages 3.2.3' to project WebApplication1.
Install 'Microsoft.AspNet.WebPages 3.2.3'
Add 'Microsoft.AspNet.Mvc 5.2.3' to project WebApplication1.
Install 'Microsoft.AspNet.Mvc 5.2.3'
Uninstall 'Microsoft.AspNet.Mvc 4.0.40804.0'.
Uninstall 'Microsoft.AspNet.WebPages 2.0.20710.0'.
Uninstall 'Microsoft.AspNet.Razor 2.0.20710.0'.

In 'Microsoft.AspNet.Mvc', 'Microsoft.AspNet.WebPages' and 'Microsoft.AspNet.Razor' packages, the lib folder only have lib45 folder. Mvc and Webpages have Content\Web.config.install.xdt files also.

@punitganshani
Copy link

I've also submitted similar request (but for API) to provide list of compatible .NET frameworks #1024

@danliu
Copy link

danliu commented Sep 18, 2015

I've debugged and investigated this issue. So far we only compare with project's target framework to get matching dependency group of a package.

For the package itself, in this case Microsoft.AspNet.Mvc, We are just getting the list of available versions from the registration blob, without filtering the versions based on supported target frameworks. As a result, after pruning process, Microsoft.AspNet.MVC 5.2.3 is selected as the version to update, although it does not support .net40.

This seems like a feature that NuGet has not supported. As of now, the package's metadata from the server does not have information about supported target frameworks. It would be hard to determine accurately what the frameworks the packages intend to support. We could only make a guess, by unzipping the package, looping through the lib, content and tools folder to see which ones are available. But the result may not be correct sometimes.

@yishaigalatzer
Copy link
Author

So one quick update - without whatif it currently updates and fails (correctly), we need to see if we can do something better about update-package scenario

image

@yishaigalatzer yishaigalatzer modified the milestones: 3.4, 3.3.0-Beta Nov 23, 2015
@yishaigalatzer yishaigalatzer modified the milestones: 3.4 Beta, 3.4 RTM Feb 25, 2016
@yishaigalatzer yishaigalatzer modified the milestones: 3.4 RTM, 3.4 RTM - Triage, 3.5 Beta Mar 11, 2016
@yishaigalatzer yishaigalatzer added the Functionality:Update The update package feature/command/experience label Mar 14, 2016
@yishaigalatzer yishaigalatzer removed this from the 3.5 Beta milestone Apr 8, 2016
@yishaigalatzer yishaigalatzer modified the milestones: 3.5 RC, 3.5 Beta Apr 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Update The update package feature/command/experience Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Product:VS.Client Type:Bug
Projects
None yet
Development

No branches or pull requests

5 participants