在InvokeProcess TF工作流程活动中捕获regsvr32的输出 [英] Capture output of regsvr32 in an InvokeProcess TF Workflow Activity

查看:71
本文介绍了在InvokeProcess TF工作流程活动中捕获regsvr32的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个构建过程设置,可以使用团队构建来构建托管解决方案.此解决方案要求在我们通过COM与之交互时,在构建解决方案之前,必须向服务器注册一个非托管组件.

I have a build process setup to build a managed solution using team build. This solution requires an unmanaged component be registered with the server before we build the solution as we interface with it via COM.

我用来注册ComObject的活动(InvokeProcess)看起来像这样

The activity (InvokeProcess) I use to register the ComObject looks something like this

regsvr32.exe /s ComObject.ocx

我用来注销它的活动(InvokeProcess)看起来像这样

The activity (InvokeProcess) I use to unregister it looks something like this

regsvr32.exe /u /s ComObject.ocx

我还使用stdOutput和errOutput作为每个动作的消息将WriteBuildMessageWriteBuildError添加到了两个InvokeProcess活动中.我还要确保将构建消息的重要性设置为很高.

I have also added the WriteBuildMessage and WriteBuildError to both InvokeProcess activities using stdOutput and errOutput as the message for each action. I also make sure to set the build message importance to high.

据我了解,这应该将标准输出和错误输出重定向到这些日志记录活动中.

It's my understanding that this should redirect the standard output and error output into these logging activities.

只要我未将MSBuild的/maxcpucount参数设置为大于1的范围,注册,构建和注销都可以正常工作.

The registrion, build, and unregistrion works just fine as long as I do not set the /maxcpucount argument of MSBuild to anything greater than 1.

一旦我将其设置为大于1的值,尝试删除有问题的文件时,在过程结束时我们的清理脚本将失败,并显示此错误消息.

Once I set it to something greater than 1, our cleanup script at the end of the process fails with this error message when attempting to delete the file in question.

Access to the path '...\ComObject.ocx' is denied.'

我认为正在发生的事情是,取消注册活动无法从服务器取消注册ComObject.ocx,因为在多个CPU上运行MSBuild时,MSBuild并未完成.然后,当我尝试从构建服务器中删除它时,它仍在系统中注册,并且会因拒绝访问错误而失败.

I think what's happening is that the unregister activity is failing to unregister ComObject.ocx from the server because MSBuild isn't done with it when it's running across multiple cpu's. Then when I get down to try and delete it from the build server, it's still registered with the system and will fail with the access denied error.

因此,我如何将regsvr32输出输出到stdOutput和errOutput,以便WriteBuildMessage和writeBuildError活动将其正确显示在构建日志中.如果我使用不存在的文件调用regsvr32,则在构建日志中看不到任何内容.

So how do I get regsvr32 output to the stdOutput and errOutput so that the WriteBuildMessage and writeBuildError activities will properly display it in the build logs. If I call regsvr32 with a file that doesn't exist, I see nothing in the build log.

我希望这是有道理的.

更新

该问题的解决方案来自pantelif解决方案的一小部分调整.我所做的是在if块中引发异常,我使用此作为消息来执行WriteBuildError:

The solution to this problem came from a minor tweak of pantelif's solution. What I did was in the if block that throws an exception, I do a WriteBuildError using this as the message:

String.Format("ErrorMessage: {0}", New System.ComponentModel.Win32Exception( System.Runtime.InteropServices.Marshal.GetL‌​astWin32Error() ).ToString() )

这使我可以从regsvr32.exe中获取错误并将其写入构建日志.

This allows me to get the error from regsvr32.exe and write it to the build log.

推荐答案

第一个问题:
我相信,通过应用E.Hofman提出的技术此处.

更具体地说,如果您在"InvokeProcess"中构造一个类似于所示的序列(也来自Ewald的帖子,请参见图):

&然后分配"WriteBuildMessage"以标记"ErrorMessage",您可能最终会在生成的构建日志中获得所需的输出.

As for your first question:
I believe it's possible to capture the output, by applying the technique presented by E.Hofman here.

More specifically, if you construct within your 'InvokeProcess' a sequence like presented (pic also from Ewald's post):

& then assign 'WriteBuildMessage' to stamp the 'ErrorMessage', you shall probably end up with getting the output you desire in the generated build log.

这篇关于在InvokeProcess TF工作流程活动中捕获regsvr32的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆