Yossi Dahan [BizTalk]


Monday, April 21, 2008

GAC assembly as a post build event

With BizTalk server every DLL we use has to be in the GAC.

Much too often, after making a change to such DLL, I forget to GAC it in time before running a test which would, naturally, result in the test failing; in most cases the error is obvious and I simply have to return to the infamous build-gac-restart host cycle before running my test, but every now and then I get thrown by the error and do not realise it is a simple case of me forgetting to GAC an assembly.

To avoid those annoying moments I have developed a habit of adding the command to GAC an assembly to the project's post-build event.

The command required looks like this -

"$(DevEnvDir)..\..\SDK\v2.0\Bin\GacUtil.exe" /i "$(TargetPath)" /f

and it can be used to make sure that on a successful build the assembly generated will be added to the GAC.

Of course this has downsides - it is quite possible that you do not want to GAC on every build; further more - the post-build event is part of the project properties and as such goes into whatever source control you're using - now you have to worry about all those other developers who might get that code and build it - do they want it in the GAC?

Having said all that I find that - for me - having the post build event is usually better than not having it.



  • Hi Yossi, hope you're well.

    I just wanted to point out that pipeline components are the only BizTalk assembly that doesn't get GAC'd.

    Also, you could add your GAC'ing command as an "External Tool" command on the visual studio Tools menu, OK you'd have to remember to run it, but you'd get round the shard source issue.

    I use a combination of Scott Colestock's build scripts and the visual studio external tools to re gac even if I'm not building with Scott Colestock's scripts.

    See you at the next UK BizTalk User Group meeting (if they ever get organised...!)


    By Anonymous Anonymous, at 21/04/2008, 23:56  

  • Good one! Sure beats doing it manually.

    By Anonymous Anonymous, at 22/04/2008, 00:09  

  • Hey Jack, Thiago - thanks for the comments.

    Actually, Jack, as far as I know as of BizTalk 2006 pipeline components can be gac-ed as well (they only need to be in the pipeline components folder for the designer).

    I like the idea of adding it as an external command to VS, I already have a right-click-on-file-thingy to allow me to GAC assemblies from windows explorer, but doing so directly from VS is clearly easier.

    I do use MSBuild extensively but I don't always want to run the full blown deploy scripts, mostly I just want to test a small change I made to a helper class or something.

    Anyway - these are all just flavours of the same thing, aren't they? at the end of the day each has it's cons and pros, you win some and lose some...wish these were our troubles! :-)

    By Blogger Yossi Dahan, at 23/04/2008, 08:17  

  • Hi Yossi,

    Post-build GACing is definitely helpful and timesaving.
    Just a small tip: when you add post-build event you can choose "When the build updates the project output" option rather then "On successful build" which is the default. In this case only actually changed ddls will be copied to GAC and not all the dependencies.

    Cheers and see you soon :-).

    By Anonymous Anonymous, at 23/04/2008, 11:35  

  • Thanks for the tip Oleg! good point!

    Glad to have you around, as always...I think I will not fire you this week then :-)

    By Blogger Yossi Dahan, at 23/04/2008, 12:00  

Post a comment

<< Home