none
MSBuild Task Multiple Reference Paths

    Question

  • I am building a project using MSBuild that contains multiple reference paths (i.e. Hint Paths) to assembly locations.  I can use the "Reference Path" property in the MSBuild task (as described in the post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=233361&SiteID=1) to set a single reference path, but how is it done for multiple paths?  I can't separate multiple paths with a semicolon, since that will terminate input for that specific property.  I've tried using an ItemGroup, but MSBuild complains that it isn't valid input for that field.

    Will simply specifying the reference path twice add both paths, or will the second overwrite the first?  Is there a better solution?

    Thanks,
    Dave
    Thursday, August 31, 2006 12:10 AM

Answers

  • Dave,

    This a modification of the reply in the post you refered to:

    <Project DefaultTargets="BuildOtherProjects" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
            <ProjectReferences Include="commerce/Commerce.Cache/Commerce.Cache.csproj" />
        </ItemGroup>

    <Target Name="BuildOtherProjects">
          <MSBuild
                Projects="@(ProjectReferences)"
                Properties="ReferencePath=C:\look\here%3BC:\also\look\here"
                Targets="Build">
                <Output
                    TaskParameter="TargetOutputs"
                    ItemName="AssembliesBuiltByChildProjects" />
            </MSBuild>
    </Target>

    The %3B escapes the ; so that is correctly passed into ReferencePath.

    Thursday, August 31, 2006 11:30 PM

All replies

  • Dave,

    I would use the AdditionalReferencePath ItemGroup like so:

    <ItemGroup>
        <!--  ADDITIONAL REFERENCE PATH
            The list of additional reference paths to use while resolving
            references. For example,
            <AdditionalReferencePath Include="C:\MyFolder\" />
            <AdditionalReferencePath Include="R:\Common\v1.4" />
        -->
        <AdditionalReferencePath Include="C:\References\Reference1 />
        <AdditionalReferencePath Include="C:\References\Reference2" />
        <AdditionalReferencePath Include="C:\References\Reference3" />
    </ItemGroup>

    Check out these articles for more info.

    Resolving file references in team build ( Part -2 ) - http://blogs.msdn.com/manishagarwal/archive/2005/09/28/474769.aspx
    Resolving references in Team Build ( Part 3 ) - https://blogs.msdn.com/manishagarwal/archive/2005/10/05/477363.aspx

    - Steve

     

    Thursday, August 31, 2006 2:02 AM
  • Dave,

    This a modification of the reply in the post you refered to:

    <Project DefaultTargets="BuildOtherProjects" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
            <ProjectReferences Include="commerce/Commerce.Cache/Commerce.Cache.csproj" />
        </ItemGroup>

    <Target Name="BuildOtherProjects">
          <MSBuild
                Projects="@(ProjectReferences)"
                Properties="ReferencePath=C:\look\here%3BC:\also\look\here"
                Targets="Build">
                <Output
                    TaskParameter="TargetOutputs"
                    ItemName="AssembliesBuiltByChildProjects" />
            </MSBuild>
    </Target>

    The %3B escapes the ; so that is correctly passed into ReferencePath.

    Thursday, August 31, 2006 11:30 PM
  • Actually that line should be

    Properties="ReferencePath=C:\look\here&#59; C:\also\look\here"

    Using %3B will not look up the assembly reference correctly, using the correct ASCII code however will.
    Thursday, May 14, 2009 2:10 AM