如何使用 VS Code(Windows 平台)编译控制台应用程序? [英] How do you compile a console application with VS Code (Windows platform)?

查看:62
本文介绍了如何使用 VS Code(Windows 平台)编译控制台应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题很简单.使用 VS Code(不是 Visual Studio),我已经能够使用 dnx run 命令运行它,但是我应该如何要求任何人安装它才能运行应用程序?

The question is pretty straightforward. Using VS Code (not visual studio), I've been able to run it using the dnx run command but how am i supposed to ask for anyone to install it in order to run the application?

换句话说,是否可以从 VS 代码生成可执行文件?

In other words, is it possible to generate an executable from VS code?

更新 1:

所选的答案已基本完成.我必须下载 Microsoft Build Tools 才能使用 msbuild,还必须创建一个 .csproj 文件,我用来创建项目的 Yeoman 生成器没有提供该文件.

The selected answer is almost complete. I had to download the Microsoft Build Tools in order to use msbuild, and also had to create a .csproj file, which wasn't provided by the Yeoman generator i used to create the project.

推荐答案

这并不像应该的那么简单,但实现的方法是通过命令面板(F1 键)并键入 run task,它应该是这样的:

This is not as simple as it should be, but the way to do this is through the command palette (F1 key) and type run task, it should look like this:

单击此按钮后,您可能会收到一个错误,提示您没有创建任务运行程序,您可以按下按钮或返回命令面板并编辑任务运行程序.

After you click this you will probably get an error in which you do not have a task runner created, you can either press the button or go back to the command palette and edit task runners.

这将创建一个包含 tasks.json 文件的 .vscode 目录,您可以翻阅并取消对 msbuild 部分的注释,或者简单地将其粘贴为覆盖:

What this will do is create a .vscode directory with a tasks.json file in it, you can either rummage through and uncomment the msbuild section or simply paste this as an override:

{   
    "version": "0.1.0",
    "command": "msbuild",
    "args": [
        // Ask msbuild to generate full paths for file names.       
        "/property:GenerateFullPaths=true"  
    ],
    "taskSelector": "/t:",
    "showOutput": "silent",
    "tasks": [
        {
            "taskName": "build",
            // Show the output window only if unrecognized errors occur.            
            "showOutput": "silent",
            // Use the standard MS compiler pattern to detect errors, warnings          
            // and infos in the output.
            "problemMatcher": "$msCompile"
        }   
     ] 
 }

完成后,您可以编辑构建规范,命令面板或 CTRL+SHIFT+B 将运行构建器.以下是任务的链接信息:visual Studio Code 中的任务

Once you've done that you can edit to your build specifications and either the command palette or CTRL+SHIFT+B will run the builder. Here is the link information for the Tasks: Tasks in visual Studio Code

这篇关于如何使用 VS Code(Windows 平台)编译控制台应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆