Visual Studio代码在Windows提示中运行构建任务,使用快捷方式Ctrl+ shift+ b

发布于 2025-02-13 20:52:51 字数 279 浏览 0 评论 0原文

我有一个C程序,我需要运行两个管理所有编译工具链的批处理文件。第一个设置了环境变量,下一个要执行的变量执行编译和链接。由于某种原因,尽管我正在使用第一个批处理文件设置所有所需的环境变量,但第二批批次文件调用的一些.exe尚未通过VS代码内部终端(扩展错误消息:“ file.exe is” IS我不认为是内部命令或/和一个可执行程序或批处理文件”)。在VS代码和C程序中,通过使用快捷方式CTRL+Shift+B在Windows提示中运行我的构建任务(此批处理文件)是否可以运行我的构建任务(此批处理文件)?在设置中有一些选项,但它们不起作用。

I have a C program and I need to run two batch file which manage all the compilation toolchain. The First one sets the enviroment variables and the next one to be executed performs the compilation and the linking. For some reason, eventhough I am setting all the needed enviroments variables with the first batch file, some .exe that are called by the second batch file are not recognized by the VS code internal terminal (extended error message: "file.exe" is not recognized as internal command or/and an executable program or a batch file"). I have tried to run in sequence this two batch files (by directly calling it, without any shortcut) in the Windows prompt opened in VS code and the C program is successfully compiled. Thus, Is there a way to run my build task (this batch file) in the Windows prompt opened in VS code by using the shortcut ctrl+shift+b? I have tried to set some option in the settings but they do not work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

宣告ˉ结束 2025-02-20 20:52:51

问题在于,我是在两个批处理文件中序列的,即在任务中定义。但是,这样,两个批处理文件将在提示的两个不同实例中执行,因此Enviroment变量仅在第一个提示中才存在。这就是为什么当执行汇编批处理时,我会遇到这个问题“'file.exe'不被识别为内部命令或/和/和/和可执行程序或批处理文件”。
为了在同一提示下执行这两个批次文件,必须在任务中定义任务。

command: "batch1 && batch2",

The problem is that I was calling in sequence this two batch file, namely by defining in the task.json that the compilation batch file must be executed after the other batch. But in this way, the two batch files will be executed in two different instances of the prompt, so the enviroment variable will exist only in the first prompt. That is why when the compilation batch is executed I get that problem "'file.exe' is not recognized as internal command or/and an executable program or a batch file".
In order to execute these two batch files in the same prompt it is necessary to define a task in the task.json with this command:

command: "batch1 && batch2",
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文