Can I Create a Project from Existing Code in Visual Studio Code

REVOLUTION

I am working on an application on a remote host. I am trying to use Visual Studio Code for debugging the application and have been asked to 'Create a Project from Existing Code' in Visual Studio. I am using Ubuntu and after bit of digging I realised that I need 'Visual studio IDE' and not 'Visual studio code' if I want some of the features. I want to know if it is possible to Create a project from existing code in VS-code.

TonyG

I'm an experienced developer but just getting familiar with using VSCode with Java, so I might not have the details correct here. All I can provide is my recent experience and observations. It seems all of this has been consistent for about a year, so this is not new detail that's only been available after the original question and self-accepted answer.

Important: While checking my facts AFTER writing everything here, and double-checking to ensure I properly understood comments and assertions here, I found that @revolution was using C++, not Java. Grrrrr, missed that. OK. The question and applied tags were about VSCode, not tagged as specifically C++. My notes here confirm that VSCode is capable of doing what the OP asked ... This is the correct answer to this question. The OP did not ask specifically about C++. The answer to his question is Yes, VSCode can do that. The answer to the question that he actually wanted to ask "can VSCode do that with C++?" ... I don't know. Sorry. In summary, I hope others stumbling on this thread will benefit from the notes here.

My goal here is to correct some assertions in this thread:

  • "it is not possible to create a project out of existing code" - Incorrect, see below.
  • "as my requirement was to debug the project, I realised it was necessary to create a project" - Incorrect, see below.
  • "The concept of a creating, saving, or loading a "project" is not included in Visual Studio Code because what a "project" is depends on the specific programming language and compiler you are using." This one is correct, with no VSCode extensions. But we all use extensions. It's a requirement for exactly the reason cited. So with extensions we have solutions, which precludes the summary that follows that comment.

Actually we can create projects and workspaces in VSCode using extensions. Refs: https://code.visualstudio.com/docs/languages/java
https://code.visualstudio.com/docs/java/java-project
https://blog.usejournal.com/visual-studio-code-for-java-the-ultimate-guide-2019-8de7d2b59902
Please excuse the links, there are numerous similar pages, search for "VSCode Java Extensions" if required."

  • VSCode Workspaces are simple "convenience" groupings of primary folders, similar in concept to a VS Solution but less (some would say 'not') integrated. You can have a workspace with different root folders of any languages or types. They all build and run independently.

VSCode Projects as discussed here are Java-specific:

  • A project folder has a .project file, .classpath, and other files that help to manage a single project.
  • A project is not the same as a Visual Studio project. It's Eclipse-style because the underpinnings of the extensions are based on Eclipse.
  • A project is not directly linked to build details. Building and debugging is facilitated in a project with launch files and others, but you can use Ant, Maven, etc., to augment your build process.
  • Each primary folder in a Workspace can be a Project : just like in VS where .xxproj folders and files are organized under a .sln.
  • Primary folders in a Workspace do not need to be Project. The concept of a Project augments the folders and allows VSCode to do special things within the primary folder, but it's perfectly valid to have root folders in a Workspace that are mixed as projects and non-projects. This is different from Visual Studio, as noted above, where we expect "projects" in solutions, except for solution folders. In VS terms (not VSCode) you might look at a Workspace as having zero or more solution folders with zero or more project folders.

To the original question about creating a project from existing code, that's how I stumbled onto this page:

In VSCode, you create a New project from F1 and Create Java Project. I don't think we can integrate a project into an existing folder (yet). What I've done is to create a new project and then manually re-incorporate existing code into it. This is a huge pain, especially with a .git folder, the need to delete/replace the src folder, and the need to manually modify the .classpath XML file with new "lib" details. (I'm guessing someone in the FOSS world is/will be addressing some of that.)

After all of that shuffling is done, be sure to save the new project, save it into a workspace, exit the app and come back in to reload everything. Yes, this does seem to be required, I think because it's required in Eclipse, this environment is using Eclipse code, and that code has details that require a reload after manipulations like this.

Since @revolution was focused on debugging :

VSCode with these Java Extensions does support debugging with breakpoints, watches, step-in/out, and other features similar to Visual Studio. (See refs above.) There is even a Hot option to allow modifying code while stepping through it. Having used VS since it was first introduced I'll confirm VSCode is nowhere near as powerful a debugger, but it gets the job done.

RE: "I am working on an application on a remote host." The VSCode extension does support remote debugging but I have not yet used that advertised feature and cannot comment on its use.

Again, I hope this answer is helpful to someone, if not to the OP who accepted his own incorrect answer.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How can I clear the terminal in Visual Studio Code?

From Java

How to create a Java / Maven project that works in Visual Studio Code?

From Java

How can I view the Git history in Visual Studio Code?

From Java

How can I exclude a directory from Visual Studio Code "Explore" tab?

From Java

How can I rename a project folder from within Visual Studio?

From Java

How can I change keyboard shortcut bindings in Visual Studio Code?

From Dev

Visual Studio: How to create project from existing GitHub repository?

From Dev

Can I run Visual Studio Code Analysis on a custom set of projects?

From Dev

How can I create a method using my existing code

From Dev

Can fortify static code analyzer scan visual studio 2013 project?

From Dev

How to: Create an asp.net Project from Existing Code Files

From Dev

How can I update SSAS Visual Studio project from an existing server?

From Dev

Can I create a SQL database in Visual Studio Code for OS X?

From Dev

Why can't I create Shared Project in Visual Studio 2015?

From Dev

How to Create a Sequence Diagram in Visual Studio 2015 Enterprise from existing code?

From Dev

Move project from Visual Studio Code to Visual Studio 2015

From Dev

Visual Studio changes designer generated code when I create a new class inheriting from Form

From Dev

How can I debug Python 3 code in Visual Studio Code?

From Dev

What can I do when Visual Studio won't allow me to view a file of code, close the project, or close VS?

From Dev

How to create a Java / Maven project that works in Visual Studio Code?

From Dev

How to create a Java / Maven project that works in Visual Studio Code?

From Dev

How to create a Java / Maven project that works in Visual Studio Code?

From Dev

How can I create PHP templates for PhpStorm with existing code inside?

From Dev

Can I create a Visual Studio project file from files on a server?

From Dev

How to open project from source code in Visual Studio 2005

From Dev

Visual Studio - Can I view the code of an older version of a project?

From Dev

Visual Studio changes designer generated code when I create a new class inheriting from Form

From Dev

How can I create a configuration entry to start server and debug Protractor tests in Visual Studio Code?

From Dev

I can't install Visual Studio Code

Related Related

  1. 1

    How can I clear the terminal in Visual Studio Code?

  2. 2

    How to create a Java / Maven project that works in Visual Studio Code?

  3. 3

    How can I view the Git history in Visual Studio Code?

  4. 4

    How can I exclude a directory from Visual Studio Code "Explore" tab?

  5. 5

    How can I rename a project folder from within Visual Studio?

  6. 6

    How can I change keyboard shortcut bindings in Visual Studio Code?

  7. 7

    Visual Studio: How to create project from existing GitHub repository?

  8. 8

    Can I run Visual Studio Code Analysis on a custom set of projects?

  9. 9

    How can I create a method using my existing code

  10. 10

    Can fortify static code analyzer scan visual studio 2013 project?

  11. 11

    How to: Create an asp.net Project from Existing Code Files

  12. 12

    How can I update SSAS Visual Studio project from an existing server?

  13. 13

    Can I create a SQL database in Visual Studio Code for OS X?

  14. 14

    Why can't I create Shared Project in Visual Studio 2015?

  15. 15

    How to Create a Sequence Diagram in Visual Studio 2015 Enterprise from existing code?

  16. 16

    Move project from Visual Studio Code to Visual Studio 2015

  17. 17

    Visual Studio changes designer generated code when I create a new class inheriting from Form

  18. 18

    How can I debug Python 3 code in Visual Studio Code?

  19. 19

    What can I do when Visual Studio won't allow me to view a file of code, close the project, or close VS?

  20. 20

    How to create a Java / Maven project that works in Visual Studio Code?

  21. 21

    How to create a Java / Maven project that works in Visual Studio Code?

  22. 22

    How to create a Java / Maven project that works in Visual Studio Code?

  23. 23

    How can I create PHP templates for PhpStorm with existing code inside?

  24. 24

    Can I create a Visual Studio project file from files on a server?

  25. 25

    How to open project from source code in Visual Studio 2005

  26. 26

    Visual Studio - Can I view the code of an older version of a project?

  27. 27

    Visual Studio changes designer generated code when I create a new class inheriting from Form

  28. 28

    How can I create a configuration entry to start server and debug Protractor tests in Visual Studio Code?

  29. 29

    I can't install Visual Studio Code

HotTag

Archive