ASP.NET MVC 4 project not recognized in Visual Studio 2017 RC - asp.net-mvc-4

I have an older ASP.NET MVC 4 project in our solution. I just installed Visual Studio 2017 RC Community Edition (VisualStudio/public.d15rel/15.0.26020.0). We have been using VS2015 successfully.
When I load the solution in VS2017RC, I get the error:
The application which this project type is based on was not found.
I've re-installed ASP.NET MVC 4 after installing VS2017RC, but it didn't help.
I plan to upgrade that to a newer version of ASP.NET MVC, but I'm hoping to use VS2017 in the mean time.

Open the .csproj file in a text editor
Find the code (may be different):
<ProjectTypeGuids> {E3E379DF-F4C6-4180-9B81-6769533ABE47}; {349c5851-65df-11da-9384-00065b846f21}; {fae04ec0-301f-11d3-bf4b-00c04f79efbc} </ProjectTypeGuids>
Delete the section {E3E379DF-F4C6-4180-9B81-6769533ABE47};
Save the file and re-open the solution.
Not all MVC4 attributes (f.e. Viewbag) are recognised in Views.
But at least you can open and run the project until a patch is released.

RC is a "Release Candidate"; it may have known issues until the full release is ready. Your problem is one of them.
MVC4 Projects are not supported
You can keep up to date through the release notes.

They say it's fixed, pending release (at the moment).
Here's the UserVoice ticket: https://developercommunity.visualstudio.com/content/problem/2865/cannot-load-mvc4-web-project-in-vs-2017-rc.html

Related

VS2017 : Target framework drop down does not show .NET Core 2.1 option

I have already installed VS2017 Enterprise 15.6.4. Recently installed .NET Core 2.1.101 SDK from official site
I was expecting .NET Core 2.1 as one of the target framework available if I create console or asp.net core application. Can someone help me understanding what I am missing here.
As suggested in comments, I installed 15.7 preview 2. Still no luck and same issue.
I have faced the same problem. I solved this by installing the right SDKs with Runtime for .NET Core 2.1.
Basically to run/create 2.1 projects from VS Preview, you need to install the "2.1.300" (not 2.1.4) .NET Core SDKs and Runtime. https://www.microsoft.com/net/download/dotnet-core/sdk-2.1.300-preview1 (this includes required Runtime already)
The good explanation of this misleading with versions i found here https://github.com/dotnet/cli/issues/8309 (dasMulli commented on Feb 24).
In case this helps someone else... After installing VS 15.9.2 my project that was working fine with 2.2 preview-3 stopped working. VS could not see the preview SDK. I could build the solution using dotnet.exe but not VS.
To solve this I created a global.json at the root folder of this solution pointing to the preview sdk. That allowed VS to see the preview version.
This is a change of behavior in VS between 15.8.x and 15.9.x.
To create the global.json you can navigate to the desired folder and type this:
dotnet new globaljson
Make sure dotnet PATH variables are in correct order
If you have installed an SDK for a different system architecture (e.g., if you installed 32-bit/x86 SDK on a 64-bit computer), then a new entry in the PATH variable would have been created for that specific location (e.g., C:\Program Files\dotnet or C:\Program Files (x86)\dotnet).
The problem is that Visual Studio, when searching for installed frameworks, will stop at the first PATH variable entry it finds that contains an SDK. So, if the first version you installed used an incorrect architecture, then you'll have to adjust the position of those entries before any of the correct SDKs will appear in the Target Framework drop down.
Source: this absurdly-hard-to-find comment within issue #8309.
TL;DR: Make sure the first "C:\Program Files\dotnet\" entry in your path variable you see in the list matches your system architecture:
64-bit = C:\Program Files\dotnet\
32-bit = C:\Program Files (x86)\dotnet\
Make sure that Visual Studio 2017 is up to date. Go to "Tools" -> "Extensions and Updates" to install visual studio updates. This resolved the issue for me.
I have faced the similar situation I tried to install the preview version of the dot net but it did not help.
However after I updated visual studio (from 15.8 to 15.9.6 ).
I Could see dot net core 2.1 in the target framework.
Updated to Latest VS 2017 and installed latest .Net Core SDK.
Changed global.json to point to latest version installed.
This resolved for me.
I had faced the similar issue. I then just updated my Visual Studio 2017 to 15.9.16 version and restarted the system. The problem got resolved.
I was facing the similar issue, I uninstalled the .Net Core 2.2 runtime and then from the below link:
https://dotnet.microsoft.com/download/visual-studio-sdks?utm_source=getdotnetsdk&utm_medium=referral
Install the .Net Core 2.2 Visual Studio SDK, Restarted the Visual Studio and my issue got resolved, .Net Core 2.2 is now getting listed in Target Framework list in the project properties in Visual Studio 2017 Version 15.9.16
I created a new project under .net core 2.1 and it was ok but in my old project have not appeared. So I opened both ".cproject" files and compared them together and found the problem.
Open your project's ".cproject" file in a text editor then replace below line
<TargetFramework>netstandard2.1</TargetFramework>
with this one:
<TargetFramework>netcoreapp2.1</TargetFramework>

ASP.Net Core 1.1 - Migration Failure

I know VS 2017 is only RC but there seem to be some major issues with migrating an ASP.Net Core 1.0 project to 1.1. The migration tool fails converting 2 of my 8 projects in the solution (I prefer to adopt a layered architectural approach for my projects) the sample project is located here. One project in particular is the class library I moved my web api controller methods into. In trying to re-create this class library it doesn't seem one is able to declare a controller class after installing Microsoft.AspNetCore.Mvc nuget. It is installed but the compiler is not finding the Controller, RouteAttribute classes, etc. The same issue occured with trying to setup a DI layer IServiceCollection. Nuget Microsoft.Extensions.DependencyInjection doesn't seem to be doing it.
The migration log quite honestly isn't really helping me. It seems to indicate an issue with my service project and the project.json file but as you can tell it is in the repository.
It feels like Microsoft is forcing us down the path of cramming all the "web" stuff into a single project file. Maybe these tools aren't far enough along yet but an RC would indicate they should be closer to ship ready?
ReciPiBook.Api
Message
src\ReciPiBook.Api\ReciPiBook.Api.xproj: Failed to migrate XProj project ReciPiBook.Api. 'dotnet migrate -s -p "C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Api" -x "C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Api\ReciPiBook.Api.xproj"' exited with error code 1.
src\ReciPiBook.Api\ReciPiBook.Api.xproj: Could not find file 'C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Services\project.json'. Migration failed.
src\ReciPiBook.Api\ReciPiBook.Api.xproj: Backing up C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Api\ReciPiBook.Api.xproj to C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\Backup\src\ReciPiBook.Api\ReciPiBook.Api.xproj.
src\ReciPiBook.Api\project.json: Backing up C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Api\project.json to C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\Backup\src\ReciPiBook.Api\project.json.
I can't directly speak to VS2017 as I'm staying away from it as even though it's a RC, the core tooling is in ALPHA. The VS 2015 core tooling is at least in a "RC" state (actually only preview).
In VS2015 I migrated from 1.0.x to 1.1 manually (per https://blogs.msdn.microsoft.com/dotnet/2016/11/16/announcing-net-core-1-1/):
Download the 1.1 sdk
Change your global.json "sdk":{"version": "1.0.0-preview2-1-003177"} (yes it's a different version string).
Update all the project.json package versions from 1.0 to 1.1 (some are preview some arn't). Just open up the nuget package manager, allow preview versions, then install all the updates.
Fix any of your project.json tool entries as the package manager clobbers those.

How can I debug the source code of .Net Core or the Base class libraries (coreFx)?

I am using .NET Core 1.0 and Visual Studio 2015 Update 3 to make a simple Asp.Net Core MVC website.
How can I debug my application and "Step Into" the .NET Core source code that is available on GitHub?
Specifically, I am trying to troubleshoot one issue with Microsoft.AspNetCore.Authentication.Facebook 1.0.0 assembly that I fetched from NuGet.
I wrote this article more than 1 year ago so it's a bit out of date but the idea is still the same:
You sync to the correct tag from GitHub. In your case, you probably want to sync to tag 1.0.0
Build that repository by running build.cmd or build.sh
Add the src folder path to your app's global.json file. For example, if you cloned Security in D:\Security, then you add D:/Security/src to global.json in the projects property.
Rebuild everything and it should work.
PS: If you use VS and don't see immediately the new code, try restarting it. It's a known issue that sometimes it doesn't pick up the changes to global.json
Update to fit new VS 2017
In Visual Studio 2017 15.3.5 and later
We can use SourceLink support for debugging .NET Core and ASP.NET Core sources.
To enable source link support just Disable Enable Just My Code and and Enable Enable Source Link Support.
Then Enable Microsoft symbol servers.
Victors answers works well with vs 2015.For some one who is looking for a solution with vs 2017,
In vs 2017 there is no global.json availble.So instead of adding folder path in global.json a project reference has to be added and rebuild.
All the others mentioned in Victors article works same as with 2015.
It is important that the git hub tag and the nuget package matches have the same versions.
Also make sure that on a solution level, you have your project "configration", set to debug. See screenshot. .
.
(For the solution properties to show up, right click on the .sln in the solution explorer.)
If you have debugged an app before with the previous version of .NET, delete the %TEMP%/SymbolCache directory as it can have old PDBs that are out of date. Per Debug .NET and ASP.NET Core source code

When updating to .NET Core 1.0 RC2 should "/Program Files/DNX/" be deleted?

These instructions https://www.microsoft.com/net/core#windows indicate that all previous version of .NET Core should be removed from Windows via the Add/Remove Programs before installing .NET Core SDK 1.0 RC2 on Windows.
However after running the uninstall from Add/Remove Programs in Windows 7 and installing .NET Core SDK I see that my /Program Files/DNX/ folder still exits.
This makes me wonder if I should delete it to clean up the system. But perhaps it's needed when working with older projects that were created with RC1 under DNX.
I'd like to know if it's ok to delete the dnx folder and it associated runtimes?
It's up to you. If you leave them there nothing bad will happen because the executables have different names (dnx/dotnet).
You can have dnx and dotnet side by side.
You should not delete this folders if you have old (DNX-based) projects that you still want to run. Otherwise, you will need to reinstall the dnx runtimes again to work with your old (RC1) apps.
Your new (RC2, dotnet cli) projects will known nothing about this old dnx-based folder and will ignore it completely.
Microsoft advise you to remove any old version of .Net Core. The DNX was the runtime and toolset used to build .Net Core and .Net Core apps as per Microsoft. It was consisted of DNVM, DNX and DNU.
With the .Net Core CLI all above (DNVM, DNX and DNU) are part of a single toolset.
You'll may find some issues when removing DNX, also when migrating a existing solution on any beta/rc version of clr or coreclr which were (dnxcore50 or dnx46) and others deprecated now.
NOTE: when uninstalling MS ASP.NET 5 RC1 Update 1 (old version), you
may have issues on your VS 2015 regarding to some projects templates,
existing MVC or WebAPI projects may not load.
I'd suggest you to migrate to .Net Core 1.0 as I did in my side, it was a little pain but you won't go anywhere with a project target to a deprecated version.
You can follow these links to migrate your app:
1) https://chsakell.com/2016/05/21/migrating-asp-net-5-rc1-apps-to-asp-net-core/
2) http://dotnet.github.io/docs/core-concepts/dnx-migration.html

Missing assembly reference from a ASP.Net 5 application

I am working on a team. The three other people on my team pulled down the new asp.net 5 application with no problems. I attempted to pull the application down from TFS and None of my DNX references are resolving. The errors I am getting is that I am missing namespaces / assembly references for the common libraries:
System,
Microsoft,
ASP.Net etc
None of my references are resolving.
As stated the three other people who pulled the project from TFS are not having any issues.
What could be causing this problem?
Make sure you install the .NET Version Manager (DNVM). You can do this by installing the ASP.NET and Web Tools 2015 (Beta7) for Visual Studio 2015.
Or: install it manually using the instructions from here. After that, run dnvm upgrade to download the latest stable DNX bits and you will be able to run dnu restore and so will Visual Studio.