在 Visual Studio 代码中运行构建
您可以通过使用各自的 tasks.json 文件和 Incredibuild 设置,在 Visual Studio Code IDE 中运行不同类型的项目(例如 Ninja、MSBuild,CMake)。
tasks.json 文件是 Visual Studio Code 为运行外部工具而设计的,必须为 Incredibuild 进行个性化设置。要了解更多信息,请参阅 Visual Studio Code 文档。
准备 tasks.json 文件
使用以下样本文件之一。修改命令行,使其与您的 Incredibuild 构建命令和项目相匹配。要了解有关 incredibuild 构建命令的更多信息,请参阅 在 Visual Studio 代码中运行构建 和 在 Visual Studio 代码中运行构建。
{
"version": "2.0.0",
"tasks": [
{
"label": "Incredibuild Build Solution",
"type": "shell",
"command": "buildconsole ${workspaceFolder}\\${solution file.sln} /build /cfg='Release|x64'",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": "$msCompile"
},
{
"label": "Incredibuild Rebuild Solution",
"type": "shell",
"command": "buildconsole ${workspaceFolder}\\${solution file.sln} /rebuild /cfg='Release|x64'",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": "$msCompile"
},
{
"label": "Incredibuild Build Project",
"type": "shell",
"command": "buildconsole ${workspaceFolder}\\${solution file.sln} /prj=${project file.vcxproj} /build /cfg='Release|x64'",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": "$msCompile"
},
{
"label": "Incredibuild Rebuild Project",
"type": "shell",
"command": "buildconsole ${workspaceFolder}\\${solution file.sln} /prj=${project file.vcxproj} /rebuild /cfg='Release|x64'",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": "$msCompile"
}
]
}
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "Clean",
"command": "C:\\CMake\\bin\\cmake.EXE --build ${workspaceFolder}\\build --config Release --target clean",
"group": "build",
"problemMatcher": [],
"detail": "CMake template clean task"
},
{
"type": "cmake",
"label": "CMake: clean",
"command": "clean",
"targets": [
"clean"
],
"group": "build",
"problemMatcher": [],
"detail": "CMake template clean task"
},
{
"type": "shell",
"label": "Incredibuild build Solution",
"command": "buildconsole /command='C:\\CMake\\bin\\cmake.EXE --build ${workspaceFolder}\\build --config Release --target ALL_BUILD -j 100'",
"group": "build",
"problemMatcher": [],
"detail": "CMake template build task"
},
{
"type": "cmake",
"label": "CMake: build",
"command": "build",
"targets": [
"ALL_BUILD"
],
"group": "build",
"problemMatcher": [],
"detail": "CMake template build task"
},
{
"type": "shell",
"label": "Incredibuild build Project",
"command": "buildconsole /command='C:\\CMake\\bin\\cmake.EXE --build ${workspaceFolder}\\build --config Release --target BlendThumb -j 100'",
"group": "build",
"problemMatcher": [],
"detail": "CMake template build task"
},
{
"type": "cmake",
"label": "CMake: build",
"command": "build",
"targets": [
"BlendThumb"
],
"group": "build",
"problemMatcher": [],
"detail": "CMake template build task"
},
{
"label": "Incredibuild Rebuild Solution",
"dependsOrder": "sequence",
"dependsOn": ["Clean", "Incredibuild build Solution"]
},
{
"label": "Incredibuild Rebuild Project",
"dependsOrder": "sequence",
"dependsOn": ["Clean", "Incredibuild build Project"]
}
]
}
上传并使用 tasks.json 文件
本步骤是根据 Visual Studio Code 文档 制作的,文档版本为 1.84。如果 Visual Studio Code 在后续版本中改变了处理这些文件的方式,本步骤可能会有所不同。