Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
robertleeplummerjr opened this issue May 6, 2016 · 25 comments
Closed

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

robertleeplummerjr opened this issue May 6, 2016 · 25 comments
Labels

Comments

@robertleeplummerjr
Copy link

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
Copy link
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
Copy link
Author

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
Copy link
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
Copy link
Author

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
Copy link
Author

Sorry, butterfingers.

@gregg-miskelly
Copy link
Contributor

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

@willl
Copy link

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
Copy link
Author

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
Copy link
Author

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

@willl
Copy link

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
Copy link
Author

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
Copy link
Contributor

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

@DustinCampbell
Copy link
Member

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

@robertleeplummerjr
Copy link
Author

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
Copy link
Member

@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
Copy link
Author

robertleeplummerjr commented Sep 16, 2016

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
Copy link
Member

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
Copy link

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
Copy link
Contributor

gregg-miskelly commented Oct 13, 2016

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
Copy link

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
Copy link

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
Copy link
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.

@hansvonn
Copy link

I would like to add my support to the concept touched on by @robertleeplummerjr. I started very recently with VSCode so please redirect me if I am off topic.

At first glance VSCode appears to be a great replacement for the Visual Studios in a lot of situations. I would love to work in VSCode rather than Visual Studio for a number of reasons. It has impressive extensibility and is lightweight. After spending quite a bit of time on it, I am still unable to get it to import the .sln or .csproj files from an existing application started in Visual Studio. I read that it should scan the folders for these files as mentioned above, but do not see this happening. Does VSCode detect .sln and .csproj files and allow the user to debug?

I would love to be a convert to VSCode. I really like what you all are doing, or at least what I think your all's vision includes. I hope it allows interoperability with Visual Studio (allow team members to develop in either environment). To do this I noticed we will need an extension to manage the .csproj file (https://marketplace.visualstudio.com/items?itemName=lucasazzola.vscode-csproj)

Keep up the good work, I have high hopes for this project.

@rchande
Copy link

rchande commented Jun 13, 2018

@hansvonn The C# extension for VS Code (if you have it installed) should automatically scan for and load sln/csproj files. This bug is very old and I'm going to close it, but feel free to file additional issues if you have more questions.

@rchande rchande closed this as completed Jun 13, 2018
@vsalvino
Copy link

I found myself wanting to use VS Code for an older non dotnet-core project. Ended up getting it working to satisfy my own needs as a functioning editor with ability to build profiles from the command line.

https://www.coderedcorp.com/blog/using-vs-code-with-a-legacy-net-project/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests