How should I import MSBuild.ExtensionPack.tasks?

Mar 11, 2009 at 6:09 PM
In the sample XML in the online help documentation, this file is imported like this:
<PropertyGroup>
  <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
  <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')"
>$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath> </PropertyGroup> <Import Project="$(TPath)"/>
Which I think means the MSBuild.ExtensionPack.tasks file should be one folder above the project file that's importing it, or in the Common directory that's two directories above the project file that's importing it.
 
When I install the extension pack the file ends up in "c:\Program Files\MSBuild\ExtensionPack\", so I just import it directly from there. I'm curious though what prompted the help authors to use the mechanism above to import the file. Is this just the way it is because of where the samples sit in the source tree relative to MSBuild.ExtensionPack.tasks?

Thanks.
Coordinator
Mar 11, 2009 at 7:55 PM
Hi

Take a look at 'Using the Samples' in the help file or online help

It covers your question. Basically you just need

<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.tasks"/>


Regards

Mike


Mar 12, 2009 at 5:24 PM
Thanks Mike.
Oct 15, 2009 at 1:00 PM

 

PS

 

Keep in mind that if you run multiple import projects

(for example:

 

    <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />

<!-- and -- >
    <Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.tasks"/>

 

)

You will need to un-ambiguit-ize (http://en.wikipedia.org/wiki/Ambiguity) any tasks that overlap in name.

 

Example:

(the below is incomplete, but emphasizes the ambiguous portion of my comment)

 

Before both libraries are used (only MSBuildCommunityTasks for instance):

<Target Name="ZipItUp" DependsOnTargets="Build">
<Zip Files="@(ZipFiles)" ZipFileName="$(DeploymentZipFileName)" WorkingDirectory=".\bin\" />
</Target>

After both libraries are imported:

<Target Name="ZipItUp" DependsOnTargets="Build">
<MSBuild.Community.Tasks.Zip Files="@(ZipFiles)" ZipFileName="$(DeploymentZipFileName)" WorkingDirectory=".\bin\" />
</Target>

 

Because "Zip" exists in both the MSBuildCommunityTasks and the MSBuild.ExtensionPack........you need to fully qualify the task name.

 

Anyway.....this is obvious (for me now), but the first time I hit it, I was like "Huh, what broke my build??".

 

................