2017-11-19 16 views
1

Visual Studioコードを使用してC++プロジェクトを構築しようとしています。MsBuildを使用したVisual Studioコードのビルド

自動ビルドのために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" 
     } 
    ] 
} 

以下の例外をスローします。

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 

ビルドタスクは、MSBuildのに基づいています。 MSBuildはビルドに.vcxprojファイルが必要でした。

nugetまたはmsbuildによって.vcxprojを生成できるコマンドはありますか。

答えて

-1

私はあなたのための1つを生成するためのツールを認識していないですが、この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> 

ClCompileインクルード属性では、プロジェクトファイルを継続的に更新する必要がないため、ワイルドカードを使用できます。 MSBuildの項目の詳細については

は、このMSDNの記事を参照してください。

https://msdn.microsoft.com/en-us/library/ms171453.aspx

+0

このリンクは質問に答えるかもしれないが、ここでは答えの重要な部分が含まれており、参考のためにリンクを提供することをお勧めします。リンクされたページが変更された場合、リンクのみの回答は無効になります。 - [レビューから](/レビュー/低品質の投稿/ 18006086) –

+0

xml設定を自分で書く必要がありますか? MicrosoftはVisual Studio以外のファイルを生成するツールを提供していますか? –

+0

私が知る限り、それを生成するツールはありません。私はサンプルで自分の反応を更新しました。貼り付けるだけで、ClIncludeを更新して必要なファイルを含めることができます。 – mageos

関連する問題