How to retrieve a list of assembly references from the current project in build order?

Im currently working on an extension to that needs to retrieve a list of assemblies from the current project.

This is easy enough to do via IdeApp.Workbench.ActiveDocument.Project.References but what I need to do is retrieve them in build order rather than simply the order listed in the project.

Is there anyway to do this at the moment or would I have to call into build/msbuild functionality to do this?

Cheers
Dave

Posts

  • mhutchmhutch USMember, Xamarin Team Xamurai

    What do you mean, "build order"? The order they have in the project is the order they have in the project file.

  • 7sharp97sharp9 GBBeta

    Once the project builds the references are resolved into the correct dependency tree order. Msbuild has a ResolveAssemblyReference task.
    task that does this. I just wondered if anything like this was available from within XS.

  • LluisSanchezLluisSanchez ESXamarin Team Xamurai

    Maybe what you want is DotNetProject.GetReferencedAssemblies(). This method returns the list of assemblies referenced by a project. If the project is being built using msbuild instead of XS's build system, it ends calling the ResolveAssemblyReferences task to get the list.

  • 7sharp97sharp9 GBBeta
    edited March 2013

    So is 'GetReferencedAssemblies' returning them in topological order?

  • LluisSanchezLluisSanchez ESXamarin Team Xamurai

    GetReferencedAssemblies returns full paths to all assemblies you need to build the project. I don't understand how ordering matters here. Can you explain what are you trying to do? what do you need it for?

  • 7sharp97sharp9 GBBeta

    In this instance I'm grabbing a list of current assemblies and applying them to the fsharp interactive window as #r assembly references. References are applied in the order submitted and if you pass in a dependent assembly before the parent then you get a assembly not found error.

    I can get round it by using the msbuild task I mentioned to order them but it would be great if I could use XS's build ordering.

  • LluisSanchezLluisSanchez ESXamarin Team Xamurai

    Ok, I see. GetReferencedAssemblies will return assemblies in the order they are defined in the project file, it doesn't take into account dependencies between assemblies. BTW, I'm not sure the implementation of ResolveAssemblyReference in xbuild takes into account those dependencies, as C# doesn't need assembly references to be provided in any specific order. Maybe it would be safer to topologically sort the assemblies yourself.

  • 7sharp97sharp9 GBBeta

    It looks like they come back in reverse topological order. I thought that the c# compiler get references sorted that way too via the msbuild task.

    The ResolveAssemblyReference task also resolves fully qualified assembly names into full paths which is something else I need.

  • 7sharp97sharp9 GBBeta
    edited March 2013

    On closer inspection it doesn't look like xbuild is ordering them correctly. Theres a comment in the code that eludes to this: ResolveAssemblyReference.cs#L83

Sign In or Register to comment.