简体   繁体   English

预启动任务构建以退出代码 1 终止

[英]Prelaunch task build terminated with exit code 1

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."我正在尝试学习如何创建方法库,但是每当我运行我的程序时,都会出现一个小弹出窗口(带有令人惊讶的基本 Windows 图形界面,更新后)显示消息“预启动任务‘构建’因退出而终止代码 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 2/2发射配置 2/2

发射配置 2/2

Here is a screenshot of that pop-up window bearing the message.这是带有消息的弹出窗口的屏幕截图。

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.另外,我不确定这是否相关,但我注意到在我将 .NET SDK 文件移动到另一个文件夹后,以及调试快捷方式命令停止工作后,这些事情开始发生。

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文件中,参数引用了我以前的项目csproj文件。

task.json (old) task.json(旧)

 { "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.我将 csproj 文件名更改为当前项目的名称,它没有任何错误。

The problem might be in the tasks.json file since the error is " PreLaunch task 'Build' " (that's in the tasks.json file).问题可能出在 tasks.json 文件中,因为错误是“ PreLaunch task 'Build' ”(在 tasks.json 文件中)。

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.随着最新的 vscode 更新,控制台中的所有警告都被视为错误,因为我删除了这一行配置"problemMatcher": "$msCompile" (in tasks.json) 它为我解决了问题。

In mac ensure the VSCode can detect .NET在 mac 中确保 VSCode 可以检测到 .NET

Try doing a symbolic link.尝试做一个符号链接。

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

Also, ensure that terminal.integrated.inheritEnv is true in VSCode settings.另外,请确保在 VSCode 设置中 terminal.integrated.inheritEnv 为 true。

In dotnet the Main() method needs to be a static.在 dotnet 中,Main() 方法需要是静态的。 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://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/main-and-command-args/该微软文档将为您提供更多信息https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/main-and-command-args/

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.您的 Launch.json、您的第一张图片、.Net Core Launch (web) 部分、Program 属性中存在问题,您应该编写您正在使用的框架和您的项目名称,而不是默认文本。

for example netstandard2.0 and mylibrary.dll例如netstandard2.0mylibrary.dll

And you can remove the web configuration if you are not going to write asp code.如果您不打算编写 asp 代码,则可以删除 web 配置。

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您也可以删除 Tasks.json 因为您可以通过 F5 像这样配置 Launch.json 来构建和测试整个项目Gist

尝试查看是否需要任何更新或需要扩展我搜索了 ms-dotnettools.csharp-1.21.13 并且它工作正常。

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".这是我第一次使用 Visual Studio Code IDE 创建 C# 程序,我只是按照简单的指南来测试第一个案例“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"不幸的是,我遇到了同样的问题,所以我跟踪了每一步以查看我的问题,结果是我没有关闭我的“Dotnet运行环境”

All my steps:我所有的步骤:
Step 1:using command line to create "Dotnet environment"第一步:使用命令行创建“Dotnet环境” 在此处输入图片说明 在此处输入图片说明

Step 2:using VS Code IDE to open this folder "MyWebsite" and I got the error message after ran it第 2 步:使用 VS Code IDE 打开此文件夹“MyWebsite”,运行后收到错误消息在此处输入图片说明 在此处输入图片说明

Step 3: closing "command line" and VS Code is okay now第 3 步:关闭“命令行”,VS Code 现在就可以了在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到启动前任务“构建” - Could not find the preLaunch task 'build' 错误:preLaunchTask 'build' 以退出代码 1 终止 - Error:The preLaunchTask 'build' terminated with exit code 1 Visual Studio:preLaunchTask“内部版本”终止,退出代码为129 - Visual Studio: The preLaunchTask 'build' terminated with exit code 129 尝试使用VS代码调试C#程序时,提示“prelaunchtask 'build'已终止,退出代码为1”,如何解决? - when trying to debugging an C# program by using VS code,says“prelaunchtask 'build'has been terminated, exit code is 1”,how to solve it? 计划的任务终止时如何运行代码 - How to run code when a scheduled task is terminated 在C#中以Process.Kill()终止的进程的退出代码 - Exit code of a process terminated with Process.Kill() in C# 在C#中以Process.Kill()终止进程的退出代码 - Exit code of a process terminated with Process.Kill() , in C# 生成任务退出,代码为-2146233082 - Build task exits with code -2146233082 如何摆脱这个问题(在从 VSCode 添加 nuget 包时,它说以退出代码终止:1。)? - How to get rid of this problem ( On adding a nuget packages from VSCode it says terminated with exit code: 1.)? 带有任务计划程序的C#控制台应用程序退出代码 - C# Console App Exit Code with Task Scheduler
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM