mic*_*ael 3 msbuild error-handling command batch-file command-prompt
我不知道该怎么做.我有一个批处理脚本文件,我用来做多个msbuild调用.我不希望msbuild输出污染我的命令窗口,而是希望它转储到日志文件中.我不知道该怎么做,但到目前为止这是我的脚本:
@ECHO Building shared libraries ...
msbuild "SharedLibraries.sln"
:: Not sure how to catch an unsuccessful build here for my GOTO ERROR?
:: Copy dll files to specific location
@ECHO Building primary application...
msbuild "Myapp.sln"
:: Not sure how to catch an unsuccessful build here for my GOTO ERROR?
:ERROR
Run Code Online (Sandbox Code Playgroud)
那么,我该怎么做:
Tho*_*fer 11
添加/fileLogger命令行开关会导致MSBuild将构建输出写入当前目录中的文件msbuild.log,而/noconsolelogger交换机会导致MSBuild不再写入标准输出.可以使用/flp开关设置文件名,如下例所示:
msbuild "SharedLibraries.sln" /nologo /noconsolelogger /fileLogger /flp:logfile=buildlog.txt
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅MSBuild命令行参考.
关于你的第二个问题; 如果构建失败,MSBuild将返回非零退出代码,可以照常处理:
msbuild "SharedLibraries.sln" /nologo /noconsolelogger /fileLogger /flp:logfile=SharedLibraries.log
if not errorlevel 0 goto ERROR
msbuild "Myapp.sln" /nologo /noconsolelogger /fileLogger /flp:logfile=Myapp.txt
if not errorlevel 0 goto ERROR
:ERROR
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4716 次 |
| 最近记录: |