tags:

views:

106

answers:

2

I have written an MSBuild task that makes use of third-party assemblies.

When I use the task in my project, MSBuild complains that it can't load the third-party assemblies (not surprisingly).

Where should I place the third-party assemblies so that they are available to MSBuild. I tried adding project references to them without success.

A: 

You could add them to the GAC (Global Assemby Cache). This only works if it is strongly named.

You could also make sure that you have marked them with copy local = true when you added the reference in the project.

Shiraz Bhaiji
+2  A: 

I'm not sure if I expressed my problem very well, but now I've found the solution.

In my .proj file, I reference my custom task with the following syntax...

<UsingTask AssemblyFile="..\lib\MyCompany.MSBuild\MyCompany.MSBuild.dll" TaskName="CreateDatabase" />

My CreateDatabase task relies on various 3rd-party assemblies. However, some of these are only referenced via reflection, so weren't included by default in the folder "..\lib\MyCompany.MSBuild".

I had been trying to get the task to work by placing the required assemblies in the same directory as the .proj file invoking the task.

However, what I should have been doing was putting the assemblies in the referenced task directory "..\lib\MyCompany.MSBuild\".

Simple!

sandy