How to open dotnet-core CLI project in Visual Studio 2017 - asp.net-core

I have been developing a simple application using dotnet Core (for an API) and Angular2 for the purpose of learning both.
I created the project using Yeoman on the command line and have been happily coding away in Visual Studio Code (on Windows). All seems to hang together well and it's been an enjoyable experience.
I thought I might try out Visual Studio 2017 and see what the experience of developing a dotnet Core project in VS is like for a while.
However, having installed VS2017 and cloned the project from github I am unsure how to proceed. I can't see any way to restore/build/run the project.
After cloning the repo, I see my project displayed in the Solution Explorer with the project.json file visible. However, Debug | Start is greyed out. I read somewhere about VS2017 needing to convert project.json to the new (old?) XML format and also I have a feeling I am missing a .sln file.
I would appreciate it if someone could point me in the right direction.

If your project has an .xproj file
Open Visual Studio.
File > Open > Project/Solution.
Open the xxx.xproj for your solution.
If your project lacks an .xproj file
Install .NET Core SDK Preview 3 or higher.
Open a command prompt at your project's directory.
Run dotnet migrate.
Open the resulting .csproj in Visual Studio 2017.
Troubleshooting
View migration help with dotnet migrate -h.
If you have a global.json file, update its SDK version before running migrate. E.g.
{
"sdk": {
"version": "1.0.0-preview4-004233"
}
}
View installed SDK versions with dir 'C:\Program Files\dotnet\sdk\'.
Update Visual Studio 2017 and its installer. On my machine, the above works with Microsoft Visual Studio Community 2017 RC Version 15.0.26014.0 D15REL.
Update .NET Core SDK. On my machine, the above works with SDK 1.0.0-preview4-004233.

Related

Brand new CLR Class Library project won't build: missing MSCOREE.lib

Using the latest Visual Studio 2019 version, a brand new project will not build:
fatal error LNK1104: cannot open file 'MSCOREE.lib'
I have tried to re-install Visual Studio but that didn't change anything unfortunately.
These components have been selected by the installer but apparently it's not enough:
MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.24)
Windows 10 SDK (10.0.18362.0)
C++/CLI support for v142 build tools (14.24)
Question:
Are there any tricks to get CLR Class Library (.NET Framework) projects to build ?
Here is the solution:
Apparently, no matter what framework version you will target, the $(NETFXKitsDir)Lib\um\x86 macro will always point to C:\Program Files (x86)\Windows Kits\NETFXSDK\4.7.2\lib\um\x86.
Now here's the problem, even though you install 4.7.2 SDK in Visual Studio Installer, this file is nowhere to be seen.
But if you download .NET Framework 4.7.2 Developer Pack Offline Installer and press the Repair button, it gets correctly installed and a brand new project will build succesfully.
Alternatively:
Re-installing VS also fixes the issue ...

Not able to restore nuget packages/Manage nuget packages not working in visual studio 2017

I tried to open a .Net Core solution which was working fine in 2015. Recently they added some .Net Core projects to the solution and asked us to upgrade to Visual Studio 2017 to be able to run them. We installed Visual Studio 2017 and tried to open the solution, but I am not able to build it. I get the following errors when I right-click and try to select "Manage Nuget packages".
I tried to open the PackageManager console from Tools: even this is not working
I also performed the "repair Visual Studio" process too.
Finally i resolved it by deleting my nuget.config both at project level and also in %appdata%/roaming/nuget .I think the issue is because of broken config file due to change from visual 2015 to visual studio 2017 .Not sure about the exact issue though

Package [some package] is not compatible with netcoreapp

I recently installed Visual Studio 2017. I migrated the existing project which created in Visual Studio 2015. It got migrated without any errors. But when I build the solution I get 100+ errors stating Package [Microsoft.AspNetCore...] is not compatible with [netcoreapp...]
There are more than 100 items listed like this. I tried
renaming the sdk value in global.json
removing sdk value in global.json
repair, uninstall & reinstalling Visual Studio 2017. But none of them work.
I'm not sure where to add net451 in imports as explained here because the project.json file is deleted while migration.
The same project was working fine in Visual Studio 2015. All issues started after migrating to Visual Studio 2017.
Please let me know how to fix this error.
Due to your last comment I believe your problem is with the Nuget cache. I've seen this before where Nuget is pulling older packages after updating to .NET Core Tooling RTM and or VS 2017. To fix this run dotnet nuget locals --clear all. Then try creating a new .NET Core project.
You have to do this solution
open menu>project>'your project name'proprties...
in the opened window Application Tab change 'Target Framework' combo to '.Net Core 2.0'
now close the window and update again
enjoy it:)
If you are coming here after VStudio 2019 and you can't install the upgrade-assistant to get you to .net 5, upgrade your Visual Studio to 16.9+

Unable to load solution created in VS for Mac in Xamarin Studio

I am testing out the new Visual Studio for Mac, and I created a new .NET Core empty web application - was able to build and run the project.
Then I tried opening the solution with Xamarin Studio and I got the following error message:
Project file doesn't have a valid ProjectGuid
Am I trying to do something that is not possible at the moment, or am I missing some configuration?
Xamarin Studio does not support .NET Core projects created by Visual Studio for Mac.
The project file format is very different for .NET Core projects created by Visual Studio for Mac. One example is that the project does not have a GUID however there are many differences.
The DNX addin was created to support the older style .NET Core projects, which use .xproj and project.json files. Visual Studio for Mac creates the newer MSBuild SDK style project files which are .csproj files.

Visual Studio 2015 Build Tools missing DNX

I've installed Visual Studio 2015 Build Tools onto our TeamCity server but the DNX folder is missing from within its installation root.
MSBuild 14 won't build an xproj because it imports Microsoft.DNX.targets
I've installed the latest DNX via the DNVM but it didn't create the DNX folder I was hoping it would.
The folder is obviously there on my dev box with VS2015 installed. I guess I could install the VS Community Edition, but why would the build tools be missing a crucial component??
Right now the DNX MSBuild targets are only installed with Visual Studio 2015 (specifically the Web Development Tools component).
https://github.com/aspnet/dnx/issues/2207#issuecomment-120076364
So it looks like I'll have to install Visual Studio 2015 Community Edition on the build server.
People are saying I should be using dnu from the command line, but the issue is that I need to make an MSDeploy package, and AFAIK, only MSBuild can do this.
Looks like I need to read this.
http://docs.asp.net/en/latest/publishing/iis.html