2011-01-12 62 views
0

我试图创建一个CodeActivity对象,它将在TFS生成期间在远程系统上注册DLL。我成功地模拟了我自己的用户帐户,该帐户拥有我的计算机的管理员权限。 (我正在尝试在我的机器上注册DLL。)请注意,如果我在本地运行工作流程,而不是从构建服务器运行,所有尝试都奏效。另外,如果我手动运行regsvr32,该DLL将正确注册并取消注册。使用CodeActivity从TFS生成注册DLL

这是我使用的高度精简代码:

Private DllType As Type 'Type of the DLL being registered is handled elsewhere' 
Dim Result As Integer 
Result = CInt(DllType.InvokeMember("DllUnregisterServer", BindingFlags.InvokeMethod, Nothing, Activator.CreateInstance(DllType), Nothing)) 

当我运行它,我得到这个消息,最相关的可能是内部异常,“无法找到切入点在DLL“RptBarcodeLabel.dll”

错误=异常已被调用的目标抛出名为“DllUnregisterServer的”。,堆栈=在System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo方法,对象目标,对象[]参数,SignatureStruct & sig,MethodAttribu (Object.Object,Object []参数,Signature sig,MethodAttributes methodAttributes,RuntimeType typeOwner)在System.Reflection.RuntimeMethodInfo.Invoke上的 (Object obj,BindingFlags invokeAttr, Binder binder,Object []参数,CultureInfo culture,布尔skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object [] parameters,CultureInfo culture) at System.RuntimeType.InvokeMember(String BindingFlags invokeAttr,BindingFlags invokeAttr,BindingFlags bindingFlags,Binder binder,Object target,Object [] providedArgs,ParameterModifier [] modifiers,CultureInfo culture,String [] namedParams)在TfsCopyFile.TfsRegisterDLL.Execute(CodeActivityContext上下文),内部异常=无法找到名为'DllUnregisterServer'的入口点在TfsCopyFile.DllRegServer.UnRegister() 在TfsCopyFile.DllRegServer.InternalRegServer(布尔fUnreg) 对象[] args) 在DLL'RptBarcodeLabel.dll'中。

另一种远程注册dll的方法也可能有效 - 只要在从TFS构建过程中可以触发该过程,我就可以接受建议。

回答

0

这是我已经采取了类似的要求的办法:

在TFSBuild.proj,使用Exec的行动创造上部署服务器在运行.bat文件;该批处理文件由PsExec远程执行。这个例子创建一个批处理文件来运行msiexec,但你可以很容易地改变它来注册一个DLL使用regsvr32。

<Exec Condition="'$(DeploymentServer)'!=''" Command='echo @echo off >"\\$(DeploymentServer)\C$\Temp\Install.bat"' ContinueOnError="true" /> 
<Exec Condition="'$(DeploymentServer)'!=''" Command='echo start /wait msiexec /uninstall "{98056358-8984-4554-b0c3-9f2af248a029}" /passive /log "C:\Temp\Uninstall.log" >>"\\$(DeploymentServer)\C$\Temp\Install.bat"' ContinueOnError="true" /> 
<!-- Kill the psexec service, otherwise it never terminates. --> 
<Exec Condition="'$(DeploymentServer)'!=''" Command='echo taskkill /IM PSEXESVC.EXE >>"\\$(DeploymentServer)\C$\Temp\Install.bat"' ContinueOnError="true" /> 
<Exec Condition="'$(DeploymentServer)'!=''" Command='"C:\Program Files\Sysinternals\psexec" -accepteula \\$(DeploymentServer) -u myuser -p mypassword -w "C:\Temp" "C:\Temp\Install.bat"' ContinueOnError="true" /> 

如果你不使用类似PSEXEC,你可以尝试在远程服务器上执行命令时遇到的权限等问题。

+0

谢谢 - 我检查了psexec,并与CodeActivty项目结合在一起。 – Scott 2011-01-24 17:55:53