[Mono-dev] Performing assembly resolution

Robin Neatherway robin.neatherway at gmail.com
Sat Dec 29 11:42:47 UTC 2012


Hi,

I want to perform the following task:

1. Read in a project file
2. Resolve all the assembly references to full paths

This is for the purpose of integrating with the F# compiler service,
which needs to be given the full path to all required assemblies in
order to return completion information.

So given an entry like:

    <Reference Include="System" />

in my project file, I would like it to resolve to:

/Library/Frameworks/Mono.framework/Versions/3.0.0/lib/mono/4.5/System.dl

modulo the GAC location. If a HintPath is present, this should be respected.

Now clearly this is possible given that xbuild does it, so presumably
the machinery is all there in the Microsoft.Build namespace, but much
googling and searching through the code of xbuild and
Microsoft.Build.* haven't enabled me to come up with complete solution
yet. The best I have been able to do is to read the project file using
the Project type. Each of the references like the one to System above
gives me a BuildItem. I then create a new TaskItem from each of these
using the FinalItemSpec and do an ad hoc copy of the HintPath metadata
(if found) over to the new TaskItem. Feeding this into an instance of
ResolveAssemblyReference gives the full paths. Although it has worked
for the examples I've tried so far it feels quite brittle. For example
there may be other important metadata I'm ignoring.

So, what is the best way to do this, or are there any pointers as to
where I've missed this in the mono codebase (or monodevelop for that
matter)?

Thanks,
Robin


More information about the Mono-devel-list mailing list