简体   繁体   English

空行而不是MSBuild中的任务控制台输出

[英]Blank lines instead of a task console output in MSBuild

My product is being migrated from Delphi 6 to the newer Delphi XE3. 我的产品正在从Delphi 6迁移到更新的Delphi XE3。 The Delphi 6 compiler used to output list of files that were compiled to an executable: Delphi 6编译器用于输出已编译为可执行文件的文件列表:

Borland Delphi Version 14.0
Copyright (c) 1983,2002 Borland Software Corporation

ProjectName.dpr(X) 
...
PathToSomeUnit.pas(X) 
...
PathToSomeIncludedFile.inc(X)     
...
X lines, X.XX seconds, X bytes code, X bytes data.

where "X" mean some numbers 其中“X”表示某些数字

We have an internal software for analyzing dependencies between applications and particular files - units and included files. 我们有一个内部软件,用于分析应用程序和特定文件之间的依赖关系 - 单元和包含的文件。 This software uses the dcc32 console output (like this one above) as its input. 该软件使用dcc32控制台输出(如上所述)作为输入。

With the new Delphi XE3 we no longer call dcc32 directly, but we use MSBuild. 使用新的Delphi XE3,我们不再直接调用dcc32,但我们使用MSBuild。 Unfortunately, the console output is not the same as with Delphi 6. When the "Quiet compile" option is disabled, the console output has multiple blank lines in place of the compiled file list. 不幸的是,控制台输出与Delphi 6不同。当禁用“Quiet compile”选项时,控制台输出有多个空行代替编译文件列表。

Embarcadero Delphi for Win32 compiler version 24.0
Copyright (c) 1983,2012 Embarcadero Technologies, Inc.

[multiple blank lines]

X lines, X.X seconds, X bytes code, X bytes data. (TaskId:65) 

With the /verbosity:diagnostic parameter it looks as follows 使用/ verbosity:diagnostic参数,如下所示

Embarcadero Delphi for Win32 compiler version 24.0 (TaskId:65)
Copyright (c) 1983,2012 Embarcadero Technologies, Inc. (TaskId:65)
(TaskId:65)
(TaskId:65)
(TaskId:65)
(TaskId:65)
(TaskId:65)
(TaskId:65)
...
X lines, X.X seconds, X bytes code, X bytes data. (TaskId:65)

When calling dcc32 directly, there was a similar problem, but it was resolved with the "-B" compiler switch (-B = Build all units). 直接调用dcc32时,出现了类似的问题,但是使用“-B”编译器开关(-B = Build all units)解决了这个问题。 I tried a similar approach with MSBuild by adding /p:DCC_AdditionalSwitches=-B but still it outputs multiple blank lines. 我通过添加/ p:DCC_AdditionalSwitches = -B尝试了与MSBuild类似的方法,但仍然输出多个空行。

Here's a possible solution: 这是一个可能的解决方案:

  1. Back up your files, etc. 备份文件等
  2. Open a .NET Framework SDK v2.0 command prompt. 打开.NET Framework SDK v2.0命令提示符。
  3. Disassemble Borland.Build.Tasks.Delphi.dll (located in your $(BDS)\\bin directory): 反汇编Borland.Build.Tasks.Delphi.dll (位于你的$(BDS)\\bin目录中):

    ildasm Borland.Build.Tasks.Delphi.dll /out=Borland.Build.Tasks.Delphi.il

  4. Edit Borland.Build.Tasks.Delphi.dcctask.xml (created by the previous step) and comment out the Ignore subnode of the OutputParsing node. 编辑Borland.Build.Tasks.Delphi.dcctask.xml (由上一步创建)并注释掉OutputParsing节点的Ignore子节点。

  5. Reassemble it: 重新组装:

    ilasm Borland.Build.Tasks.Delphi.il /dll

  6. Register a strong name exception for it: 为它注册一个强名称例外:

    sn -Vr Borland.Build.Tasks.Delphi.dll

If you turned off the quiet mode as described in this answer , building your Delphi projects with MSBuild should now show the detailed compiler output. 如果您按照本答案中的描述关闭了安静模式,那么使用MSBuild构建Delphi项目现在应该显示详细的编译器输出。

Add --depends to DCC32 command line or /p:DCC_OutputDependencies=true to msbuild, it will output a .d file that can be easily parsed, like the example below: 添加到--depends DCC32命令行或/ P:DCC_OutputDependencies = true来的msbuild,它会输出可以很容易地解析时,如下面的例子一个.D文件:

C:\publico\BUILD\temp\YourDPR.exe: YourDPR.dpr \
        C:\blabla blabla\FrameWork\Base\biblioteca\dcus\unit15.dcu \
        C:\blabla blabla\FrameWork\Base\biblioteca\dcus\unit13.dcu \
        C:\bla bla\bla\LIBD5\Units\unit12.dcu \
        C:\blabla blabla\FrameWork\Base\biblioteca\rxlib\units\unit1.dcu \
        C:\blabla blabla\FrameWork\Base\biblioteca\rxlib\units\unit13.dcu \
        C:\bla bla\bla\LIBD5\Units\unit1.dcu \
        C:\bla bla\bla\LIBD5\Units\unit12.dcu \

Ps. PS。 You can hide those blank msbuild lines with /p:DCC_Hints=false; 你可以用/ p隐藏那些空白的msbuild行:DCC_Hints = false;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM