VS CODE / MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file - visual-studio-code

I've tried many different ways but I get the error MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file. in Visual Studio code when trying to run my Net Core.
I think I have this configured correctly. The project builds with no errors. I even tried building a new empty project and still get the error.
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/API/API/bin/Debug/net5.0/API.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
}
]
}
Tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "shell",
"args": [
"build",
// Ask dotnet build to generate full paths for file names.
"/property:GenerateFullPaths=true",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"/consoleloggerparameters:NoSummary"
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
}

Related

How do I create output folder for MSVC generated files in Visual Studio Code?

I am following the tutorial here which shows how to use the VS C++ in Visual Studio Code.
Everything runs smoothly. The only problem is the auto-generated files (.lnk, .pdb, .exe and the likes) get generated in my src itself. How do I get the task to generate an output folder and store the auto-generated files there?
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}"
],
"problemMatcher": ["$msCompile"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "cl.exe build and debug active file",
"type": "cppvsdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"preLaunchTask": "cl.exe build active file"
}
]
}

Debugging Fortran code with gdb under Visual Studio Code in Windows

I saw other posts like this that explain how to debug with gdb. But it still wont work with me. I installed the following extensions:
I created the following launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Run GDB",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}\run.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"externalConsole": false,
"MIMode": "gdb",
"preLaunchTask": "compile_with_gfortran"
}
]
}
and the following tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "compile_with_gfortran",
"type": "shell",
"command": "gfortran -o run.exe example.f90 -g",
"options": {
"cwd": "${workspaceFolder}"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Both json files are inside the folder .vscode. By hitting shift-ctrl-B the task builds correctly and creates the executable. When I click F5 to start the compiler, the preLaunchTask runs, the compiling buttons (step in etc...) show up but nothing attaches to the Fortran file, although I added breakpoints into proper locations. And nothing shows up in the debug console. Any suggestion?

vscode cpp build tasks.json type:"cppbuild" error

VSCode : 1.61.0
Linux: Ubuntu 20.04.3 LTS
I'm trying to build c++ program using by VSCode.
when the run build, VSCode showing this message.
I know build tasking need matching launch.json file's preLaunchTask with tasks.json file's label. and I'm already set it.
tasks.json
{
"tasks": [
{
"type": "cppbuild", // but "shell" is working
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
The problem is, if I change the "type" value in tasks.json, from shell to cppbuild, It doesn't work and show the error message like to.
showing error message when the run build
what is different "cppbuild" and "shell"? and What should I do how using "cppbuild" value?
Te values of cppbuild are fine. Try changing in launch.json the value:
"preLaunchTask": "C/C++: g++ build active file",
to:
"preLaunchTask": "cppbuild",
The difference between shell and cppbuild is that the first open the BASH and runs a command you write, the second, cppbuild, runs an specific binary (or program).

Blazor client WASM launch configuration for VSCode

Where can I find an example of the .NET Core Launch (Blazor Standalone) launch configuration? And before you refer me to this https://learn.microsoft.com/en-us/aspnet/core/blazor/debug?tabs=visual-studio-code&view=aspnetcore-3.1#vscode I have already been there. No actual example of the configuration file is present.
I struggled with this too; Just debug with ".Net Core" should be first choice; should auto generate:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (Blazor Standalone)",
"type": "coreclr",
"request": "launch",
"program": "dotnet",
"args": [
"run"
],
"cwd": "${workspaceFolder}/src/Project.UI",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
{
"name": ".NET Core Debug Blazor Web Assembly in Chrome",
"type": "pwa-chrome",
"request": "launch",
"timeout": 30000,
"url": "https://localhost:5001",
"webRoot": "${workspaceFolder}/src/Project.UI",
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
}
]
}
You need to create a build task (task.json) first for the blazor WebAssembly
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/BlazorSVgTest.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
]
}
And then create a launch task (launch.json) with debug enabled
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/BlazorSVgTest.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
]
}
Okay, after revisiting this I now understand. in the launch.json I needed to add a line for "url": "https://localhost:{PORT}" and use the first port mentioned in Properties/launchSettings.json.
To get the browser to open I added "browser": "edge" but it does not automatically open the page so I do still need to manually navigate to the url but I can live with that. If anyone figured out how to get the working feel free to share. My launch.json looks like the following:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch and Debug Standalone Blazor WebAssembly App",
"type": "blazorwasm",
"request": "launch",
"url": "https://localhost:7051",
"browser": "edge"
}
]
}

Chain pre-launch tasks in VS Code

Is it possible to invoke more than one pre-launch task using VS Code?
I try to restore packages then build then run but I can only get to configure build.
My launch.json:
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/src/myProject/bin/Debug/netcoreapp1.0/myProject.dll",
"args": [],
"cwd": "${workspaceRoot}/src/myProject",
"stopAtEntry": false,
"externalConsole": false
},
My tasks.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"./**/project.json"
],
"isBuildCommand": true,
"showOutput": "always",
"problemMatcher": "$msCompile"
}
]
}
so I tried to specify the dotnet restore command however it does not work.
I know this is long over due. However, I think I figured out the solution. Steps I did.
Create a workspace to include all the projects in the workspace.
Go to Run and Debug, and click on "Add Config (workspace)
the format is the following:
{
"folders": [
{
"path": "project1"
},
{
"path": "project2"
},
],
"launch": {
"version": "0.2.0",
"compounds": [{
"name": "Chain Stars",
"configurations": [
"ConfigurationName1",
"ConfigurationName2",
]
}]
}
}
ConfigurationName1, and ConfigurationName2 is the profile name you would like to put them in sequence to launch your website.
4. Save the profile. In this case. "Chain Stars" is going to show up in the profile name for you to run it. Let me know if you have any questions.