如何将msbuild中的cmd输出保存到for循环中的日志文件中?

如何将msbuild中的cmd输出保存到for循环中的日志文件中?,cmd,visual-studio-2015,msbuild,Cmd,Visual Studio 2015,Msbuild,我有几个Visual Studio 2015解决方案文件,我希望使用命令行构建这些文件。我希望输出存储在单个文件中 以下是构建解决方案的批处理文件的内容 echo off call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" set _SCRIPT_DRIVE=%~d0 echo DRIVE %_SCRIPT_DRIVE% set baseDir=%_SCRIPT_DRIVE%\Source

我有几个Visual Studio 2015解决方案文件,我希望使用命令行构建这些文件。我希望输出存储在单个文件中

以下是构建解决方案的批处理文件的内容

echo off

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"

set _SCRIPT_DRIVE=%~d0
echo DRIVE %_SCRIPT_DRIVE%


set baseDir=%_SCRIPT_DRIVE%\Source\Service\4.0\Branches\ARES
echo baseDir =  %baseDir%


set buildLog=%baseDir%\Build.log


rem these are the directory names / solution name of the projects I want to build
rem you can build 'n' solutions and use your own instead of me giving you the solution and code
set thirdParty=Cert,ManagedHooks,NLog,Newtonsoft.Json,RabbitMQ,MDTE
echo.
echo building  %thirdParty%
echo.


for %%p in (%thirdParty%) do (
  echo.
  echo building %%p

  cd %%p

  set thirdPartySolutionFile=%%p%.sln
  echo solution file : %thirdPartySolutionFile%

  MSBuild %thirdPartySolutionFile% /t:Rebuild /m /p:Configuration=Debug > %buildLog%

  cd ..
)
我只得到存储在日志文件中的最后一个项目构建信息,答案是

>覆盖%buildLog%文件

>>将输入附加到此文件

因此,调用构建工具并将输出发送到文件的那一行应该更改为包含>>而不是>

MSBuild %thirdPartySolutionFile% /t:Rebuild /m /p:Configuration=Debug >> %buildLog%