Upgrading a project to MVC 5 - asp.net-mvc-4

I have been looking for a solution to upgrade a current MVC 4 app that i have to use the new MVC 5 binaries. I cannot find a solution anywhere.
Anyone have any ideas?

Visual Studio 2013 will automatically upgrade a project simply by allowing the Nuget Package Manager to run Updates.
Steps:
In Visual Studio 2013, open the project and right click on the project name to open the Properties window. Change the Target Framework to at least 4.5.
Then, on the project right click on the References item, and select Manage NuGet Packages. On the right side of the window select "Updates", and underneath select "All". This should begin a search for all packages needing to be updated. When the search completes an "Update All" button will appear which if clicked, will update all packages.
Note, my project had the UpgradeMvc3ToMvc4 package. It could not upgrade this so I uninstalled it first, but allowed the dll's to remain when asked.

See https://learn.microsoft.com/en-us/aspnet/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2
Microsoft info.
It works for me ...

Related

Nuget PM crashes VS 2019

Using the latest VS update 16.7.4 but happened also on .3 and .2. Working on a Xamarin.Forms project when I first started noticing it, but now it happens on any project when I try to go to the menu and click [Manage Nuget Packages for the Solution].
NPM shows up fine. If I stay on the installed or updates tab it works fine. But when I click the BROWSE tab it shows a list of the latest searches, and then after about 3 seconds the cursor pops up, then vs becomes un responsive and it crashes.
I don't know much about looking at the vs logs to find out what is going on. I happens on every project now, so I don't think removing the .vs or .obj folders have anything to do with it, although I tried it on the Xamarin Project to no avail.
Anyone else seen this?
Nuget PM crashes VS 2019
1) First, disable any other VS installed Extensions under Extensions-->Manage Extensions to check whether a vs extension caused that.
2) clean all nuget caches
3) reset all vs settings under Tools-->Import and Export Settings-->Reset All VS Settings
4) close VS Instance, delete the global nuget.config file under C:\Users\Administrator\AppData\Roaming\NuGet then reopen VS to regenerate that file.
5) check under Tools-->Options-->Nuget Package Manager-->Package Sources
try to use https://www.nuget.org/api/v2/ or http://packages.nuget.org/v1/FeedService.svc/ as nuget.org source.
Also, uncheck other package source and only remain the nuget.org package source.
6) delete bin and obj folder of the project to do a clean step. Also, you can try to install one package on the new project to test whether the issue happens again.
7) try to repair VS and it works as the final step.

System could not be found Visual Studio 2017 ASP.NET Core project

I've installed the newly released version of Visual Studio 2017 and started a fresh ASP.NET Core project targeting .NET Core.
Out of the box, I'm getting the
The type or namespace name 'System' could not be found (are you
missing a using directive or an assembly reference?)
error. Any idea what's causing this and how to fix it?
Also, looks like there are problems with NuGet packages as well:
I also tried dotnet restore on the project through the command line and got the following error:
P.S. Kind of disheartening that you get an error in a fresh new project in the latest version of Visual Studio 2017!
UPDATE:
SDK version is v 1.0.1 -- see below:
UPDATE 2:
This is very strange. Looks like the original problem was due to NuGet package source pointing to a folder under Visual Studio 2015 folder. I unchecked it and left only nuget.org. With that my project seemed to have restored all the packages and when I started the project it loads up the standard ASP.NET page. But if I open startup.cs file, I get red squigglies all over the place but if I run the project, it works fine. What's going on here?
UPDATE 3:
I closed the project and VS 2017. I then restarted VS 2017 and opened the project and now it seems to be fine. And I'm not referencing the .NETStandard library 1.6.1 and everything seems to be working fine now.
I had the same issue in my Visual studio 2017 .Net Core application. I closed the Visual studio and re-open fixed everything.
Came across the same issue today. I had an old nuget source that no longer existed. So I went into Tools > Nuget Packet Manager and un-checked the wrong one. Hit "Ok", and then rebuilt the project, and it works great now. It seems like you stumbled onto it, but also wanted to verify that it fixed my issue, and it does.
I had the same problem, first when converting a VS2015 net core mvc web project to 2017 and then when trying to create a new core web application in 2017.
Went to Tools|NuGet Package Manager|Package Manager Settings - checked 'Allow NuGet to download missing packages' and 'Automatically check for missing packages during build in VS' and then clicked 'Clear All NuGet Cache(s)'.
Then re-built the solution - it found and loaded all the required packages and ran OK.
May not work for all cases but simple and worth a try.
Multiple closing and reopening of VS2017 fixed it for me.
I had the same issue, the solution for me was to clear the NuGet cache. Tools > NuGet Package Manager > Package Manager Settings > Clear All NuGet Cache(s)
Check the version .NET Command Line Tools in CMD, just type dotnet --info. If version is 1.0.0, then try to install latest version .NET Core SDK from here.
Find the broken project and right click, Unload, right click, Re-load. Fastest fix for me.
If you get the problem while using the CLI, try doing nuget restore instead of dotnet restore as that sometimes pulls down packages that the dotnet CLI seems to miss.
I have had the same issue with Visual Studio 2019 and .NET Core SDK 2.2.
These steps solved the problem:
Close the Visual Studio
Open the Visual Studio as Administrator
Open the Solution
Right click on Solution -> Restore NuGet Packages
I've tried all answers above. For me works only removal and adding the reference again described in the following steps:
Open 'References' under the project.
Right click on 'System' reference.
Click on 'Remove'.
Right click on 'References'.
Click 'Add Reference...'.
From right menu choose an 'Assemblies',
In a search field type 'System'.
Choose 'System' from the list.
Click 'Add' button.
IMPORTANT: Restart the Visual Studio.
'System' reference you can replace with any you need.
Try adding the following line above the other references in the csproj file
<Reference Include="netstandard" />
For me the problem was caused by my project having a custom IntermediateOutputPath. For some reason, if project_name.csproj.nuget.g.targets is not in obj subfolder of project folder, the error occurs.
Using default IntermediateOutputPath or keeping a shadow copy of project_name.csproj.nuget.g.targets in fake obj folder solves the problem for me.
This issue seems to be triggered by a myriad of reasons. Mine was caused by cloning directly from VSTS using Git Bash, my project directory had spaces in it. Git Bash changed those spaces in the path to %20. It was throwing off all the references in my project. So for anyone who tried everything else and are at their wits end, make sure %20 is not in the path.
So, I have cloned the repository from github and started getting this error.
It was my project uploaded from another machine. I later realized that I have used the materialdesign packages in my project.
I have uninstalled and reinstalled these packages and it fixed my issue.
Had the same problem. Uninstalled Application Insights from my projects using the nuget package manager. I'm not looking at that yet, I just wanted core and unit tests. Problem solved.
I also had the same problem.
The is no SDK folder under the Dependencies one. Therefore, no Microsoft.NetCore.App libraries !
To solve this problem, in Nuget manager window, install any nuget which depends on .NetCoreApp (you can install for example Microsoft.AspNetCore or BundlerMinifier.Core from the Microsoft Visual Studio Offline Packages source).
The SDK will be restored by the same time.
Once it is back, you can uninstall the previously added nuget. The SDK will remain in place.
Not quite sure in which order vs 2017 trying to resolve packages.
But my situation was following. In my VS2015 I had configured local and 3rd party source for nuget packages, newly installed version of 2017 loaded them too.
https://api.nuget.org/v3/index.json was first in list.
But vs2017 throwed an error that it can't restore .net core libraries from my another local repo.
After I unchecked all of them except https://api.nuget.org/v3/index.json, it had started to working normally.
I had this problem too, but not right now, this steps solved my problem: Choose Project -> Properties from the menu bar. In the Project properties window, under Configuration Properties -> General, make sure that Common Language Runtime Support is set to Common Language Runtime Support (/clr)
Simply opening the NuGet package manager and then the Visual Studio settings related to it - without changing anything - merely looking around, and when I closed out, the problem was gone.
This seems to be an intermittent issue that can come and go for no obvious reason.
None of the answers here worked for me so I'm posting what did work.
My errors were mostly the same as the original poster but I also had:
Error loading meta data for 'Microsoft.Extensions.FileProviders.Embedded.2.0.1'
hexadecimal value 0x1C invalid character
Every time I attempted to download a different nuget package or restore old packages I would see this error. I also saw the other errors such as:
type or namespace system could not be found
What worked for me:
opened the filepath that the error said the bad metadata was in, which for me was C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.fileproviders.embedded\2.0.1
Then, I put the contents of that folder into another folder I named "hiding".
Then, I went back to the nuget package manager and tried to install a package, hoping to have the SDK restored. IOt worked successfully, and all my other errors were gone as well, and the fresh new project runs as it should!
The problem for me occurred when running my Visual Studio as Admin with a separate user-- I had created a Git Repo with the source files in the user documents of my normal account. When I created a new solution in that folder the above errors occurred. Try creating your project in a different place and see if the error still occurs.
I was facing the same issue when I created a new project (.net Core 2.2) in VS2019.In my case there was an Azure package which was creating the problem.I uninstalled it and the project started working fine.
Run mentioned below command to uninstall the package.
Uninstall-Package Microsoft.VisualStudio.Azure.Containers.Tools.Targets -Version 1.7.10
I had the same problem. I cloned a github project and this error came. So I deleted the cloned project and then I cloned the project again and it worked fine.

How to resolve errors with namespaces and references?

I just added an existing MVC project to VS 2012 that i downloaded from Codeplex. The problem is when i'm trying to build or run the project i get a lot of errors that VS can not find references and namespaces. If i open a new MVC project then i'm not getting this errors and everything runs fine. So it only occurs when i try to open an existing project.
Can someone help me with this please?
From the VS 2012 menu select Tools->Library Package Manager->Package Manager Settings. A window will appear. Check the checkbox labeled "Allow NuGet to download missing packages during build" under the Package Manager->General heading. Click the OK button to apply the setting.
Next in the Solution Explorer right-click the Solution node and select Enable NuGet Package Restore. Perform a Clean Solution and then a Build Solution. A .nuget folder should be downloaded into your solution and all compile errors related to missing references should be resolved.
This is what worked for me.

version of .net framework launch not match .net framework bootstrapper project

When I build the release project of the vb.net 2010 I just started using, I get two warnings:
the version of the .net framedwork launch condition does not match the selected .net framework bootstrapper package. Update the .net framewk launch condition to match the version of the .netfrk selected in the prerequisites dialog box.
The target version of the .net framework in the project does not match the .net framework launch condition version .net framework 4 client profile. Update the version of the .net framework launch condition to match the target version of the .net framework in the advanced compile options dialog box.
I changed the framework of the main project from client profile (which it was when I first created it) to frwk 4 because I read that crystal reports would not work with frwk 4 client profile. (is that true).
The bootstrap version Framework is for x64 and x86. I continued to look around the web and found that one can change the framework in the launch conditions of the setup project. These seem to be scattered around in numerous places which is a problem I don't recall ever having with other verions of .net. Anyway, That solved that problem, but there is still another issue associated with this.
I have changed anycpu to x86 for the main project and the secondary projects because I was having a problem with installing both msi's for crystal. Meanwhile, the other secondary projects (which were upgraded from 2008) I changed to x86 but in the configuration file, it says anycpu for these and as has been written here, cannot be changed to x86. I am not getting an error but have not yet tested whether the installation works.
I read an answer on your site to go into vbproj and change in notepad from x86 to x64 because they could not change from anycpu to x86 that way. But I don't want x64 so not sure what to do.
It seems that anyCPU would be a good selection but will that work with Crystal and do I need to attach other than the x86 msi if I do change it? Or can I leave it as is in this unclear situation.
This error is because of a mismatch. You can fix it by making either one of them match the other.
One is the "Launch Condition." The other is the "Prerequisite."
To change the Launch Condition:
right click your setup project in the Solution Explorer
click View - Launch Conditions
select the ".NET Framework" item under Launch Conditions
in the properties window, see the Version item. You can open the drop down menu to select the appropriate framework version.
To change the Prerequisite:
right click your setup project in the Solution Explorer
choose properties, a Properties Pages dialog appears
click the "Prerequisites..." button
check and uncheck framework versions as appropriate
Yet another poorly documented feature from our friends at Microsoft. With the Setup project selected there are an array of icons in the solution explorer toolbox; one of which is "Launch Condition Editor".
Select the setup project, select the "Launch Condition Editor", new window opens. Select "Launch Conditions", ".Net Framework" Look at properties, version. Select the present version, opens drop down menu, select desired framework.
Rebuild.
(Thanks to http://social.msdn.microsoft.com/Forums/windows/en-US/5167197a-12a5-473e-940a-569e92f08f37/error-the-version-of-the-net-framework-launch-condition-net-framework-4-does-not-match-the)
Okay so I ran into this issue as well. There are 3 places I found that need to match. Not 2 places. I am using VS2015 with the Add-in Setup Project available from Microsoft.
Place 1: Target Framework needs to be what you are targeting, variable X. To get to this go to the properties of your main project and select the target framework for your code.
Place 2: Right click your setup project and go to view > Launch conditions, click .Net Framework, and in the properties window select your target framework... variable X.
Place 3: Right click your setup project and go to properties > Prerequisites. This will show the pre-requisite from the program... In my case Variable X needed to match what was checked in this box.
This resulted in a successful build of the project without the warning.

How do I install DotNetZip?

As I am pretty new to Visual Studio, this question may sound kinda dumb:
How do I install DotNetZip library? I am using Visual Studio Express 2012 for Windows Desktop.
There is no setup for DotNetZip.
Simply download the package from its site, decompress the library somewhere in your disk and set the reference from your project to the release folder appropriate for your project type. Remember to distribute the DLL with your application.
Another simple way would be to use nuget extension to install the library.
There are many ways to add DotNetZip file in your project. I have mention only two ways below:
Way 1:
1. In Visual Studio go to- Tools->NuGet Package Manager -> Package Manager Console
2. Select your project from Default Project drop-down in Package Manager Console.
3. Type Install-Package DotNetZip and press enter.
Automatically the package will be included in your project.
Note: Sometime it does not work as expected.
Way 2:
1. In Solution Explorer go to your Project, then References folder.
2. Right click on References folder -> Manage NuGet Packages.
3. On the pop up window select Online from left menu.
4. Type DotNetZip on Seach text box.
5. From loaded list click Install button.
Manage NugGet Package PopUp window