下面主要想通过msbuild编译
#include <stdio.h>
int main (int argc, char *argv[])
{
char Buffer[2000];
printf("TEST");
gets(Buffer);
}
批处理文件调用 msbuild:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild main.vcxproj
pause
msbuild工程文件如下
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<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" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ItemGroup>
<ClCompile Include="main.c" />
</ItemGroup>
</Project>
到目前为止整个设置都有效,但我需要找到一个好的资源来帮助我了解更多关于 msproject 文件的信息。 我想学习多种东西。我怎样才能:
有一本很棒的书,里面有很多示例代码可以完成您所说的一切。
深入了解 Microsoft® 构建引擎:使用 MSBuild 和 Team Foundation Build
这里是如何调用 clean,然后调用构建目标,并让它编译调试和发布配置。 C:\Windows\Microsoft.NET\Framework 4.0.30319\msbuild main.vcxproj /t:clean;build /p:Configuration=Debug;Release /p:platform=Win32
复制任务:
<ItemGroup>
<MySourceFiles Include="c:\MySourceTree\**\*.*"/>
</ItemGroup>
<Target Name="CopyFiles">
<Copy
SourceFiles="@(MySourceFiles)"
DestinationFiles="@(MySourceFiles->'c:\MyDestinationTree\%(RecursiveDir)% (Filename)%(Extension)')"
/>
此链接可能会帮助您解决其他一些问题。