Ben*_*eng 5 c++ msbuild nuget visual-studio-code
我正在尝试使用 Visual Studio 代码来构建 C++ 项目。
我为自动构建创建了一个 task.json。
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "msbuild",
"args": [
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true",
"/t:build"
],
"group": "build",
"presentation": {
// Reveal the output only if unrecognized errors occur.
"reveal": "silent"
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$msCompile"
}
]
}
Run Code Online (Sandbox Code Playgroud)
它抛出以下异常。
MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
The terminal process terminated with exit code: 1
Run Code Online (Sandbox Code Playgroud)
由于构建任务基于 MSBuild。MSBuild 需要一个 .vcxproj 文件进行构建。
是否有任何可以通过 nuget 或 msbuild 生成 .vcxproj 的命令。
我不知道有什么工具可以为您生成一个工具,但是这篇 MSDN 文章将为您提供您所需要的:
https://msdn.microsoft.com/en-us/library/dd293607.aspx
工作项目的完整示例是:
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.default.props" />
<PropertyGroup>
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="main.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Targets" />
</Project>
Run Code Online (Sandbox Code Playgroud)
在 ClCompile Include 属性中,您可以使用通配符,这样您就不必不断更新项目文件。
有关 MSBuild 项的详细信息,请参阅此 MSDN 文章:
https://msdn.microsoft.com/en-us/library/ms171453.aspx
归档时间: |
|
查看次数: |
3675 次 |
最近记录: |