我收到消息“找不到任务'build''".当我尝试启动我的C#代码时 [英] I get the message ''could not find the task 'build'" when I try to start my C# code
问题描述
我是C#的新手,正在学习使用复数视力
我完全遵循了教程的操作,但是遇到了一个教程没有解决的问题.
当您通过.Net制作C#代码时,我拥有一个简单的"Hello World"程序
在Visual Studio Code中,如果选择开始调试"或不进行调试开始",则会弹出以下错误消息
''找不到任务'build'"
然后我仍然单击调试,然后出现以下错误
启动:程序目录\<insert-project-name-here> .dll不存在有一个选项可以打开launch.json
令人困惑的是,.dll文件确实存在...
进一步,检查launch.json,我有以下内容:
{//使用IntelliSense了解可能的属性.//将鼠标悬停以查看现有属性的描述.//有关更多信息,请访问:https://go.microsoft.com/fwlink/?linkid=830387"version":"0.2.0",配置":[{"name":".NET Core启动(控制台)","type":"coreclr","request":启动","WARNING01":"*****************************************************************************************,"WARNING02":"C#扩展名无法自动解码当前的项目","WARNING03":用于创建可运行的launch.json文件的工作区.launch.json文件具有模板,""WARNING04":已创建为占位符.","WARNING05":","WARNING06":如果OmniSharp当前无法加载您的项目,则可以尝试解决","WARNING07":通过还原所有丢失的项目依赖项(例如:运行'dotnet restore')进行此操作","WARNING08":并且通过修复在工作区中构建项目所报告的任何错误.","WARNING09":如果这允许OmniSharp现在加载您的项目,则-","WARNING10":"*删除此文件","WARNING11":"*打开"Visual Studio代码"命令面板(视图"->命令面板"),"WARNING12":"*运行命令:'.NET:生成用于构建和调试的资产'.","WARNING13":","WARNING14":如果您的项目需要更复杂的启动配置,则不妨删除","WARNING15":此配置并使用'添加配置...'选择其他模板","WARNING16":此文件底部的按钮.","WARNING17":"*****************************************************************************************,"preLaunchTask":"build",程序":"$ {workspaceFolder}/bin/Debug/<在此处插入目标框架->/<在此处插入项目名称-> .dll,"args":["link"],"cwd":"$ {workspaceFolder}","console":"internalConsole","stopAtEntry":否},{"name":".NET Core Attach","type":"coreclr","request":"attach","processId":"$ {command:pickProcess}"}]}
简单方法
在VS Code中,加载代码库之后.调出
并确保您单击是
复杂的方式
您需要更改当前读取的 task.json
文件中的行:
程序":"$ {workspaceFolder}/bin/Debug/< insert-target-framework-here>/< insert-project-name-here> .dll,
在您的csproj中用目标框架绰号替换< insert-target-framework-here>
,这可能类似于以下内容:
< TargetFramework> netcoreapp2.1</TargetFramework>
您还需要用生成的DLL的名称替换< insert-project-name-here> .dll
字符串.
I am new to C# and am learning using pluralsight
I have followed exactly what the tutorials are doing but have ran into a problem that the tutorial does not.
I have the simple ''Hello World'' program built when you make C# code via .Net
In Visual Studio Code, if go with Start Debugging or Start Without Debugging, the following error pops up
''could not find the task 'build'"
I then click on debug anyway then the following error shows up
launch:program dir \ < insert-project-name-here >.dll does not exist there is an option to open launch.json
the confusing thing is, the .dll file DOES exist...
Further, checking launch.json, I have 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": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"WARNING01": "*********************************************************************************",
"WARNING02": "The C# extension was unable to automatically decode projects in the current",
"WARNING03": "workspace to create a runnable launch.json file. A template launch.json file has",
"WARNING04": "been created as a placeholder.",
"WARNING05": "",
"WARNING06": "If OmniSharp is currently unable to load your project, you can attempt to resolve",
"WARNING07": "this by restoring any missing project dependencies (example: run 'dotnet restore')",
"WARNING08": "and by fixing any reported errors from building the projects in your workspace.",
"WARNING09": "If this allows OmniSharp to now load your project then --",
"WARNING10": " * Delete this file",
"WARNING11": " * Open the Visual Studio Code command palette (View->Command Palette)",
"WARNING12": " * run the command: '.NET: Generate Assets for Build and Debug'.",
"WARNING13": "",
"WARNING14": "If your project requires a more complex launch configuration, you may wish to delete",
"WARNING15": "this configuration and pick a different template using the 'Add Configuration...'",
"WARNING16": "button at the bottom of this file.",
"WARNING17": "*********************************************************************************",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
"args": ["link"],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
The easy way
In VS Code, after you've loaded the code base. Bring up the command pallet and enter > .NET Generate Assets for Build and Debug
then hit return/enter.
This will force VS Code to recreate the launch.json
and task.json
files.
Keep an eye on the lower-left corner of the VS Code window for a toast message which looks like this:
and ensure that you click Yes
The complicated way
You need to alter the line in your task.json
file which currently reads:
"program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
replacing <insert-target-framework-here>
with the target framework moniker in your csproj, which might look like something similar to this:
<TargetFramework>netcoreapp2.1</TargetFramework>
You'll also need to replace the <insert-project-name-here>.dll
string with the name of your produced DLL.
这篇关于我收到消息“找不到任务'build''".当我尝试启动我的C#代码时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!