How do I set a project as startup project in Visual Studio Code?


I am looking for a solution to set a project as start-up project in Visual Studio code, like in Visual Studio 2015/2017 or in any other recent version, I right click a project within solution explorer and set it as startup.

However, I am not able to do that in VS Code. So, how can I accomplish that in VS Code? Thanks.


Asked by:- LuneAgile
0
: 10894 At:- 12/14/2018 12:51:47 PM
Visual-Studio Visual-Studio-code







2 Answers
profileImage Answered by:- vikas_jk

In Visual Studio code, it's not done by clicking a button, in Visual Studio code you need to specify most of the similar things using tasks.json or launch.json.

So, I will copy paste my answer from stackoverflow's useful link

Choose a root project folder (i.e.: D:/anyfolder/myrootfolder)

Create two folders for two projects in the root folder
2.1 D:/anyfolder/myrootfolder/project1
2.2 D:/anyfolder/myrootfolder/project2

Open cmd and create two Console-Applications (I use .netcore 2.0)
3.1 go to folders project1 and project2 using cmd (Command: cd -foldername-)
3.2 for each of that folders execute the command: dotnet new console

Open the root project folder with Visual Studio Code

Add the following launch.json and tasks.json to the .vscode folder (usually the .vscode folder is generated after clicked the debug-button in VS Code)
For More information visit:https://code.visualstudio.com/docs/editor/debugging

Sample launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch Project1",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceRoot}/project1/bin/Debug/netcoreapp2.0/project1.dll",
            "args": [],
            "cwd": "${workspaceRoot}/project1",
            "stopAtEntry": false,
            "console": "internalConsole"
        },
        {
            "name": ".NET Core Launch Project2",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceRoot}/project2/bin/Debug/netcoreapp2.0/project2.dll",
            "args": [],
            "cwd": "${workspaceRoot}/project2",
            "stopAtEntry": false,
            "console": "internalConsole"
        }
    ]
}

Sample tasks.json file:

{
    "version": "0.1.0",
    "command": "dotnet",
    "isShellCommand": true,
    "args": [],
    "tasks": [
        {
            "taskName": "build",
            "args": [
                "${workspaceRoot}/project1/project1.csproj"
            ],
            "isBuildCommand": true,
            "problemMatcher": "$msCompile"
        },
        {
            "taskName": "build",
            "args": [
                "${workspaceRoot}/project2/project2.csproj"
            ],
            "isBuildCommand": true,
            "problemMatcher": "$msCompile"
        }
    ]
}

In the above sample .net core 2.0 is used, If you want to use another Target Framework, you have to customize the upper sample files of course.

After all you should now see two items in right of the Play(Debug-)button:
.NET Core Launch Project1 and
.NET Core Launch Project2

Other useful links which may help are

https://github.com/OmniSharp/omnisharp-vscode/issues/1876

https://elanderson.net/2018/04/run-multiple-projects-in-visual-studio-code/

Hope it helps.

 

1
At:- 12/15/2018 12:44:15 PM


profileImage Answered by:- LuneAgile

Thanks Vikas_jk.

 

0
At:- 12/17/2018 8:45:43 AM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use

Subscribe Now

Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly