Search code examples
visual-studio-2010msbuildmsbuildcommunitytasks

Avoiding local dependencies for MSBuild Community Tasks within Visual Studio 2010


I'm trying to start taking advantage of the MSBuild Community Tasks so right after installing the .msi package I've imported MSBuild.Community.targets within the <Project> element this way:

<Import Project="lib\MSBuild.Community.Tasks.targets" />

Interestingly I've noticed such file have a reference to the local installation path in MSBuildExtensionsPath and given that in lieu of keeping code dependencies as clean as possible I'm willing to pay the overhead of distributing/versioning them with every project, I was wondering if is it possible to sort of override the default/installation location with a project-relative one in the .cproj file?

The actual layout would be like:

Dotnet.Samples.Foobar
\src
     Foobar.cs
\lib
     MSBuild.Community.Tasks.targets
     MSBuild.Community.Tasks.dll

Any guidance will be sincerely appreciated. Thanks much in advace for any suggestion you might want to share.


Solution

  • In MSBuild.Community.Tasks.targets specified the path to the dll.

    <PropertyGroup>
      <MSBuildCommunityTasksPath Condition="'$(MSBuildCommunityTasksPath)' == ''">$(MSBuildExtensionsPath)\MSBuildCommunityTasks</MSBuildCommunityTasksPath>
      <MSBuildCommunityTasksLib>$(MSBuildCommunityTasksPath)\MSBuild.Community.Tasks.dll</MSBuildCommunityTasksLib>
    </PropertyGroup>
    

    You can override the path in the project.

    <PropertyGroup>
       <MSBuildCommunityTasksPath>lib</MSBuildCommunityTasksPath>      
    </PropertyGroup>
    

    And leave import the same:

    <Import Project="lib\MSBuild.Community.Tasks.targets" />