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

眉间皱痕 提交于 2019-12-07 01:12:18

问题


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.


回答1:


If your project has an .xproj file

  1. Open Visual Studio.
  2. File > Open > Project/Solution.
  3. Open the xxx.xproj for your solution.

If your project lacks an .xproj file

  1. Install .NET Core SDK Preview 3 or higher.
  2. Open a command prompt at your project's directory.
  3. Run dotnet migrate.
  4. 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.



来源:https://stackoverflow.com/questions/41408500/how-to-open-dotnet-core-cli-project-in-visual-studio-2017

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!