Closed yishaigalatzer closed 6 years ago
Note that MVC 5.2.3 does have a specific dependency on .NET 4.5
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)
You can see that the mvc assemblies are placed in the net45 folder inside the lib folder
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.
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
Hi yishaigalatzer
I'm using NuGet 2.8.60318.734 in both VS2013 Professional and Community Edition.
I can repro the issue with both NuGet 2.8.60318.734 and NuGet 3.0.
Repro steps:
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.
I've also submitted similar request (but for API) to provide list of compatible .NET frameworks https://github.com/NuGet/Home/issues/1024
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.
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
Moved from - https://github.com/NuGet/NuGetGallery/issues/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.