Prelaunch task build terminated with exit code 1
Asked Answered
F

8

16

I'm trying to learn how to create method libraries but whenever I run my program a little pop-up window (with a surprisingly basic Windows graphical interface, post-update) shows up with the message "PreLaunch task 'Build' terminated with exit code 1."

I click on "Show error" and in the "problems" tab I see the message "No problems in the workspace so far."

Does anyone know what's going on?

Here are my launch configurations...

launch configurations

launch configurations

launch configurations 2/2

launch configurations 2/2

Here is a screenshot of that pop-up window bearing the message.

pop-up window

pop-up window

Also, I'm not sure if this is related but I noticed that this stuff started happening after I moved the .NET SDK files to another folder, and also when the debugging shortcut command stopped working.

Forwhy answered 2/2, 2018 at 20:43 Comment(2)
The configuration file as text, not images, would be more helpful.Nicholasnichole
I had the same problem and I had to download the version that specified in the console error. And then follow the steps in this link.. make sure to open a new command prompt to execute the commands microsoft.com/net/learn/get-started/windowsCloistered
N
17

I encountered the same error after renaming my project. The problems was that in my task.json file, the arguments were referencing my previous project csproj file.

task.json (old)

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/MyOldProject.csproj"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

`

I changed the csproj file name to the current project's name it worked without any errors.

Nonet answered 14/5, 2018 at 19:29 Comment(0)
M
8

The problem might be in the tasks.json file since the error is "PreLaunch task 'Build'" (that's in the tasks.json file).

With the latest vscode update all the warnings in the console were treated as errors and since I removed this line of configuration "problemMatcher": "$msCompile" (in tasks.json) it solved the problem for me.

Mottle answered 12/2, 2018 at 15:28 Comment(0)
C
1

In mac ensure the VSCode can detect .NET

Try doing a symbolic link.

sudo ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/

Also, ensure that terminal.integrated.inheritEnv is true in VSCode settings.

Counterplot answered 10/5, 2020 at 5:48 Comment(0)
K
0

In dotnet the Main() method needs to be a static. Try changing your definition from

public void main()

to

public static void Main()

and see if that helps. This microsoft doc will give you some more information https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/main-and-command-args/

Kesterson answered 2/2, 2018 at 21:8 Comment(1)
Thanks! I changed the definition, but the problem still seems to be persisting.Forwhy
K
0

There is a problem in your Launch.json, in your First Picture , in .Net Core Launch (web) section , in Program attribute, you should write the framework you are using and your project name instead of the default text.

for example netstandard2.0 and mylibrary.dll

And you can remove the web configuration if you are not going to write asp code.

Also you can delete Tasks.json because you can build and test your whole project by F5 by configuring your Launch.json like this Gist

Knossos answered 2/12, 2018 at 8:18 Comment(0)
N
0

Try to see any update is required or an extension is needed I searched for ms-dotnettools.csharp-1.21.13 and it worked ok.

Nailhead answered 9/3, 2020 at 21:27 Comment(0)
D
0

It is my first time to use Visual Studio Code IDE to create a C# program, I just follow the simple guideline to test the first case "Hello world". unfortunately, I got the same issue, so I had traced every step to look at what's wrong with me, the result was I didn't close my "Dotnet run Environment"

All my steps:
Step 1:using command line to create "Dotnet environment" enter image description here enter image description here

Step 2:using VS Code IDE to open this folder "MyWebsite" and I got the error message after ran it enter image description here enter image description here

Step 3: closing "command line" and VS Code is okay now enter image description here

Dishrag answered 26/3, 2020 at 7:3 Comment(0)
S
0

6/16/2023~

Hi, I got the same problem, reading online I found something related to the launch.js file. After just only removing a line it works:

"preLaunchTask": "build",

Sisneros answered 16/6, 2023 at 6:36 Comment(1)
The date tag is not necessary since the date is visible anyways. Also the code should be formatted. Otherwise your answer is a bit short, but fine. Please fix the mentioned points and then I am fine with it.Kermie

© 2022 - 2024 — McMap. All rights reserved.