How can vscode import sln/csproj and run? #283

Open
robertleeplummerjr opened this Issue May 6, 2016 · 22 comments

Projects

None yet

8 participants

@robertleeplummerjr

I asked this on stackoverflow, hoping it would help, & @bpasero thought it might be ideal to ask here. Link to stackoverflow question: http://stackoverflow.com/questions/37062818/how-can-visual-studio-code-on-osx-import-sln-csproj-and-run

Thanks!

@chuckries
Contributor

Visual Studio Code is meant to be a powerful editor, not a full IDE. It does not support projects the way that Visual Studio does, and therefore doesn't understand sln or csproj files. The C# extension (this repository) adds Intellisense and Debugging support for .NET Core projects (project.json projects). Information on .NET Core can be found here.

@robertleeplummerjr

Is there an example somewhere of what a sln/csproj equivalent json file would look like? Would creating a importer be of value for this project? I know it would for me.

@gregg-miskelly
Contributor

I should start by saying that both Chuck and I aren't the experts in this area - we are debugger people. But we will try to help.

@robertleeplummerjr are you building something for .NET Core, or are you making something for Mono/Xamerin/Unity?

For .NET Core, you can find some basic sample projects on https://github.com/aspnet/cli-samples, or you can create a blank console app with dotnet new. There are probably other examples too that I am not aware of. If you want something more real world, the .NET CLI itself is built using project.json -- https://github.com/dotnet/cli

If you aren't using .NET Core, I am not sure if it is going to be worth your time to use project.json. I suppose if you can do something quick to make VS Code happy it could work. But overtime I believe the plan in to make the C# extension do a better job handling .csproj.

@DustinCampbell do you have anything to add?

@robertleeplummerjr

The app is in asp.net latest, c#. I had a windows based laptop, where I was developing the app, die on me (motherboard failure) and decided to try and push myself to use cross platform, in this case osx. I got the project to run fine in both Xamarin and Rider, but VSCode I couldn't get to the point I could restore nuget packages and build and run the project. Of someone just had the asp.net json that VSCode needs working to launch a simple asp.net website I could probably hobble along, perhaps even creating a means of import.

@robertleeplummerjr

Sorry, butterfingers.

@gregg-miskelly
Contributor

Got it. In this case https://github.com/aspnet/cli-samples should have what you want.

@willl
Member
willl commented May 7, 2016

It sounds like you've built something which targets the full framework and probably ASP.NET MVC 5? At this stage omnisharp-roslyn has poor msbuild/csproj support at this point in time as the focus has largely been on supporting .NET Core.

VS Code should give you intellisense support, but as I said at this stage doesn't handle much of what is contained within your project/solution files. From what I understand, it purely uses solution/project filed to parse (using roslyn) to provide you with intellisense and largely ignores the rest.

Your options then if you don't want to make any changes would be to use Xamarin/monodevelop or Project Rider which you had noted work. From what I'm aware, Xamarin/monodevelop uses xBuild to provide MS Build support and Project Rider has their own thing built from Resharper.

It may get better support for it in the future, but I wouldn't expect it any time soon.

Converting your project over to ASP.NET Core MVC with full framework (eg: .NET 4.5.1 and higher) target is your other option. There is some documentation (that may be slightly out of date) that you can look at here: https://docs.asp.net/en/latest/migration/index.html

@robertleeplummerjr

If someone were to spend time ensuring that documentation was up to do, or there was a how to upgrade guide, it would really add a lot of momentum to the use of this project.

@robertleeplummerjr robertleeplummerjr referenced this issue in Microsoft/vscode Jun 12, 2016
Closed

csproj support? #7561

@robertleeplummerjr

Maybe if there was a csproj version of a launch file for asp.net, I could write an importer?

@willl
Member
willl commented Jun 13, 2016

It's actually mentioned in the readme.

Important! Breaking Changes as of 1.0.10

The C# extension now only supports .NET Core RC2. It no longer supports .NET Core RC1 or ASP .NET 5 RC1.
Support for .csproj projects has been temporarily disabled on OS X and Linux. This will impact anyone doing .csproj development on OS X or Linux (e.g. Unity, Xamarin, etc.). Rest assured that this will be restored in the near future. However, for now, you can use the Legacy C# Support extension.

@robertleeplummerjr

Wow, this stuff is moving right along! Seems now the problem is that packages are not yet accepting dotnet5. Any way to potentially use 4.5?

@gregg-miskelly
Contributor

@robertleeplummerjr I don't quite understand your question. Can you clarify what you mean?

@DustinCampbell
Collaborator

@gregg-miskelly: This issue seems to have grown stale. Do you want to close it?

@robertleeplummerjr

I'd like to reinstitute the original question asked: "How can vscode import sln/csproj and run?" and have an official response from a team member. Too, could we have answered which versions of .net that that OmniSharp supports?

To address as well: "Visual Studio Code is meant to be a powerful editor, not a full IDE." I humbly disagree, in that as soon as there was a "click to debug" button, Visual Studio Code because a full fledge ide.

@DustinCampbell
Collaborator

@robertleeplummerjr: thanks for the feedback, but it is true that VS Code is meant to be a powerful editor and not an IDE. The way a like to think of the difference is that an IDE (like VS) pulls together all of the pieces of a development tool chain to create a single solution, whereas an editor (like VS Code) is intended to be a part of a development tool chain. Whether or not that is the reason for not being able to open a csproj/sln and run is a different discussion.

Today, the C# extension for VS Code has no problem opening an sln, assuming it contains csproj's that it knows how to read. On OS X, you need to have at least Mono 4.0.1 installed, and it does a best effort to try and provide IntelliSense and other editor tooling. In fact, there are a number of developers doing Unity development on OS X with VS Code today. It's a bit DIY, but https://code.visualstudio.com/docs/runtimes/unity shows how this works.

@robertleeplummerjr
robertleeplummerjr commented Sep 16, 2016 edited

You are free to identify VS Code as you wish, but https://en.wikipedia.org/wiki/Integrated_development_environment
quotes: "is a software application that provides comprehensive facilities to computer programmers for software development"
I'm afraid I'm not smart enough to see the difference.

As far as I'm aware (and I am very naive), Unity isn't directly related to sln/csproj, and gives me little insight on how to run said type of project. I did ensure that I have "Legacy C# Support" installed in VS Code, and low and behold there is an area that has:

This extension can be used to target ASP.NET 5 RC1 and older DNX-based projects. If you need to install ASP.NET 5 RC1, you can still find it in the following locations:

Windows: https://docs.asp.net/en/1.0.0-rc1/getting-started/installing-on-windows.html
OS X: https://docs.asp.net/en/1.0.0-rc1/getting-started/installing-on-mac.html. (Be sure to follow the instructions for using Mono.)
Linux: https://docs.asp.net/en/1.0.0-rc1/getting-started/installing-on-linux.html. (Be sure to follow the instructions for using Mono.)

Wow! And so I follow the link "https://docs.asp.net/en/1.0.0-rc1/getting-started/installing-on-mac.html", to its destination, only to find a very interesting set of instructions:

        \          SORRY            /
         \                         /
          \    This page does     /
           ]   not exist yet.    [    ,'|
           ]                     [   /  |
           ]___               ___[ ,'   |
           ]  ]\             /[  [ |:   |
           ]  ] \           / [  [ |:   |
           ]  ]  ]         [  [  [ |:   |
           ]  ]  ]__     __[  [  [ |:   |
           ]  ]  ] ]\ _ /[ [  [  [ |:   |
           ]  ]  ] ] (#) [ [  [  [ :===='
           ]  ]  ]_].nHn.[_[  [  [
           ]  ]  ]  HHHHH. [  [  [
           ]  ] /   `HH("N  \ [  [
           ]__]/     HHH  "  \[__[
           ]         NNN         [
           ]         N/"         [
           ]         N H         [
          /          N            \
         /           q,            \
        /                           \
@DustinCampbell
Collaborator

An easy way to think about the difference is Visual Studio or Eclipse vs. Notepad++ or Sublime Text.

I would recommend using the latest version of the C# extension and not the Legacy C# Support extension. Being legacy, that extension is no longer updated and is only provided as a stop-gap for people working on older projects.

Unity does generate an sln and csproj files and that's what people are using with VS Code. As I mentioned before, the C# extension supports sln and csproj files with Mono on OSX, but can only do so with a best effort. The debugger support that we provide is only for CoreCLR-based project.json apps today.

@schaveyt

Is there recommended/best practice to migrate from a sln/csproj setup to the project.json.

I am looking to migrate a large code base to dotnet core and vscode and the dev use the platform of their choice. Given the choice, the devs prefer vscode to xamarin-develop

@gregg-miskelly
Contributor
gregg-miskelly commented Oct 13, 2016 edited

Unless you absolutely need to convert over now, I would probably recommend waiting a little bit longer (or maybe there is tooling you can try now?), as with .NET Core 1.1 the default build system will be unified on .csproj. See the Scott Hunter's blog post for a bit more information.

@AlecBoutin

When I open a folder containing a .csproj and VS Code doesn't recognize it as a C# project, is there any way to debug what the issue might be?

@mika76
mika76 commented Dec 15, 2016

Is it possible to get a wiki page or something which describes what has been done towards compiling and debugging non-.net code code and what the roadmap is? I see currently that .sln files are detected and compiled but there is no debugging profile? How would someone code an MVC 5 app with vscode? Any way to debug if running in IIS?

@gregg-miskelly
Contributor

@mika76 #813 tracks general support for debugging full framework applications. We don't have a real timeline for when this support will be added, but we have gotten enough feedback on it that I suspect this support will eventually be added. IIS launch is a special case, and I don't think it would be part of any initial support for Full framework applications. Though if it is a common request maybe it will eventually come. Manually attaching to IIS would certainly be possible.

In case this isn't obvious - I would recommend full Visual Studio for these scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment