Is there a way to use the MSBuild Extension Pack with a "local" reference that doesn't require you to run the installer? In other words, can you store the targets in a solution items folder so that every developer doesn't have to install it?
-
1The name for that kind of "installation" is called "xcopy deployment" – R. Martinho Fernandes Nov 21 '09 at 22:18
-
My last comment is a bit poor on grammar. Sorry, I'm sleepy... – R. Martinho Fernandes Nov 21 '09 at 22:19
-
I don't follow. I was wondering if you can reference the MSBuild Extensions at any location on the machine, without running the msi to install the Extensions. – Bob Nov 21 '09 at 22:20
-
@Bob: I understand your question (even though I can't answer it). I was just pointing that what you want is to "do xcopy deployment of the MSBuild Extension Pack". Just giving you the name for future reference. – R. Martinho Fernandes Nov 21 '09 at 22:23
-
You might want to evaluate NAnt as an alternative. http://nant.sourceforge.net/ - see also http://nantcontrib.sourceforge.net/ – TrueWill Nov 22 '09 at 05:35
2 Answers
You have to declare the property, ExtensionTasksPath, before the import statment for the tasks. For example take a look at:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ExtensionTasksPath Condition="'$(ExtensionTasksPath)' == ''">E:\Data\Development\My Code\Community\MSBuild\ExtensionPack\</ExtensionTasksPath>
</PropertyGroup>
<Import Project="$(ExtensionTasksPath)MSBuild.ExtensionPack.tasks"/>
<Target Name="Demo">
<MSBuild.ExtensionPack.FileSystem.File TaskAction="GetTempFileName">
<Output TaskParameter="Path" PropertyName="TempPath"/>
</MSBuild.ExtensionPack.FileSystem.File>
<Message Text="TempPath: $(TempPath)" />
</Target>
</Project>
The MSBuild Community tasks is similar but the property is named MSBuildCommunityTasksLib. I think for SDC tasks its called TasksPath.

- 27,943
- 17
- 79
- 125

- 43,864
- 17
- 144
- 178
-
Thank you! I just watched your DNRtv episodes on MSBuild and they were fantastic. – Bob Nov 22 '09 at 15:10
I had trouble getting this to work with relative paths (ie not c:\blah but ..\blah).
This is because you couldn't re-use the ExtensionTasksPath variable if it was relative, since your file (.csproj) and the MsBuild.ExtensionPack.tasks file are in different locations, resulting in a different value for the relative path.
In the end this is what got it working for me (put at top of your .csproj file):
<PropertyGroup>
<ExtensionTasksPath Condition="'$(ExtensionTasksPath)' == ''">..\4.0\</ExtensionTasksPath>
</PropertyGroup>
<Import Project="..\references\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/>
The reason why you need the "..\4.0\" instead of just "" (blank) is because the MsBuild.ExtensionPack.tasks file detects blank and does some different stuff if that is the case. I didn't want to hack the MsBuild.ExtensionPack.tasks file in case I wanted to upgrade it later.

- 1,721
- 2
- 14
- 18