MSBuild: How to force ProjectReference to search elsewhere for an assembly

build-automationmsbuildtfsbuild

We have a large number of Visual Studio Solutions that contain the same shared 15 projects, and most solutions only differ by a web application.

I'm trying to consolidate everything into a single build that builds the shared projects only once, then have the web application projects reference the output shared assemblies.

I'm finding that, since the web project points to the shared projects via the <ProjectReference> element, I can't tell it to look elsewhere for an assembly inside of my custom build project. I would like to use something similar to:

<MSBuild Projects="@(Solutions)" Targets="Rebuild" Properties="ReferencePath=$(MyReferencePathFolder)">

but that will only work if the web project references the dll of the shared assembly through a <Reference> element. It seems that if it can't find what's pointed at in <ProjectReference>, it doesn't try to look in any ReferencePath folder. It just gives up.

Best Answer

You may want to consider referencing the 15 shared assemblies from a well known location.

You could create a solution that contains the 15 projects and copies the output to a specific folder. Then you can change your web app projects to reference the assemblies, and not the shared projects.

What you lose with this method is the ability to automatically rebuild your shared projects from a web app solution. If you want to automatically rebuild the 15 assemblies when working on one of the web app solutions, you could add a pre-build step in your web app solutions to build your new shared project solution.