如何将 msbuild 的 cmd 输出保存到 for 循环中的日志文件?
How do I save cmd output from msbuild to a log file in a for loop?
我有几个 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.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 ..
)
我只得到日志文件中存储的最后一个项目构建信息
>> 是答案
https://www.tutorialspoint.com/batch_script/batch_script_appending_files.htm
> 覆盖 %buildLog% 文件。
>> 将输入附加到此文件
因此您调用构建工具并将输出发送到文件的行应该更改为在其中包含 >> 而不是 >
MSBuild %thirdPartySolutionFile% /t:Rebuild /m /p:Configuration=Debug >> %buildLog%
我有几个 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.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 ..
)
我只得到日志文件中存储的最后一个项目构建信息
>> 是答案
https://www.tutorialspoint.com/batch_script/batch_script_appending_files.htm
> 覆盖 %buildLog% 文件。
>> 将输入附加到此文件
因此您调用构建工具并将输出发送到文件的行应该更改为在其中包含 >> 而不是 >
MSBuild %thirdPartySolutionFile% /t:Rebuild /m /p:Configuration=Debug >> %buildLog%