开发者

Teamcity and register dll

开发者 https://www.devze.com 2023-03-21 23:44 出处:网络
I\'m trying to build a project with TeamCity Professional 6.5.2 I have a MVC Visual Studio 2010 project using a visual foxpro dll.

I'm trying to build a project with TeamCity Professional 6.5.2 I have a MVC Visual Studio 2010 project using a visual foxpro dll. The build fails because the dll is not registered. How can I r开发者_运维问答egister that dll in the build machine, as part of the build process?

Thanks!!


There are two different scenarios Rodrigo, your scenario will fall into one of these:

Assemblies which can be referenced by the project: Wherever possible, include dependent assemblies in your source control repository (the 10th Commandment), usually in a "libs" folder which is referenced by the necessary projects. This centralises all your dependencies, makes it easy for new developers to get started and solves your TeamCity build problem.

Assemblies which need GAC installation: There are times when the assembly simply has to be installed in the GAC (i.e. RightFax). Frankly, the easiest thing to do in this case is just to install the damn thing in the GAC. It's an exception and whilst some people will philosophically argue against it, alternatives can get a bit complex (i.e. automating installation as part of the build), and for money I'd rather invest the time elsewhere.


Installing assemblies on each machine (dev, build, prod) will make future updates and any continuous integration system difficult to maintain in the future.

It would be better to create a folder in your working directory (I call it "Resources") which contains a folder for each group of DLLs. Then you just reference the assembly directly from the Project each time. You get duplicate DLLs across different projects, but it keeps everything very clean and simple.

In Visual Studio 2010 you can download a little utility called NuGut which I believes helps to manage assemblies in a better way.


It is a bad idea to register all DLLs on build agent machine, sometime you can find out that you have to install Visual Studio on a build agent machine, for instance ;)

I would suggest to place such libraries along with your code base in Source Control system (I assume you are using it), and just reference lib's folder by declaring a MSBUild property like

<PropertyGroup>
  <LibFolder>$(PathFromCommandLineOrJustHardCodedPath)</LibFolder>
</PropertyGroup>

And then before doing a Build/Compile just copy files from $(LibFolder) into the build $(OutputFolder) using standard MSBuild command Copy by specifying source and destination files, and thats it.

To force TeamCity to pickup Lib (dlls) files from VCS folder just add path mapping into the:

TeamCity Configuration Settings -> Edit Build Configuration -> VCS Root settings -> Client Mapping

EDIT:

In your case looks like you have integration test which depends on external COm Server which you need to launch, so you can programatically registr this DLL, for instance in TestSetup, and then do not forget to unregister it in test TearDown. Anyway you have to just reference this DLL as VS Project -> Add Existing Item -> Add as Link + set Copy to Output Directory -> Copy if newer

How-To register COM dll: see this SO post


Finally I added a prebuild event in Visual Studio running the regsvr32 command. The dll was in a known location, so I referenced this way: regsvr32 /s $(SolutionDir)Lib\ProjDataAccess\ProjDataAccess.dll


Agree with Troy Hunt.

For a Continuous Integration with TeamCity 8.0.2 where you need an assembly (custom made shared assembly) reference from GAC, do the following.

1. Add the assembly to the build pack (In my case its nuget package).
2. Before starting the build process (MSBuild, Visual Studio etc), register the assembly to GAC with the help of a command line build runner.
3. Continue with the build process.

By following the above steps, if you are using MSBuild, the build process can link to a valid reference from GAC, which can produce an expected build result.

In my case, where the code refers a custom component from GAC, MSBuild ignored the assembly reference and completed the build process without an exception. But the deployment with the build output failed. To overcome this situation, I've used the give steps.

Note: It is mandatory that the TeamCity agent needs to run under an elevated user account. Else the addition to GAC won't be permitted and the build process can fail.

0

精彩评论

暂无评论...
验证码 换一张
取 消