Respondida Add reference path to IProject?

  • sábado, 10 de marzo de 2012 8:44
     
     

    Hi,

    Is there any way I can add folder reference path using IProject object?  Similarly as we can do it from Project Properties window.


    Adil Mughal (MCPD, MCT, MVP) - http://AdilMughal.com

Todas las respuestas

  • miércoles, 14 de marzo de 2012 20:23
    Propietario
     
     Respondida Tiene código

    Hi Adil - I don't think it is possible to add "folder" reference paths to an IProject. I could be wrong, but I think this is because folder reference path is a VS concept while the Roslyn Workspace APIs (i.e. IWorkspace, IProject, ISolution) only represent the view of solutions, projects, documents that the C# and VB language services consume. Take a look at Dustin's answer on this thread for another VS feature (i.e. nested docuements) that is not supported in the Workspace APIs. I think his answer would also apply to this thread.

    You can add reference to a particular assembly programatically as follows -

    IProject project = ...;
    ISolution solution = project.Solution;
    solution = solution.AddMetadataReference(project.Id, new AssemblyFileReference(@"D:\MyAssembly.dll"));

    You could also use solution.AddMetadataReferences() which would allow you to add multiple assembly references in one go. Note that the objects are immutable. So anytime you make any changes to an existing ISolution or IProject object, you would get back a new ISolution or IProject object with your changes.


    Shyam Namboodiripad | Software Development Engineer in Test | Roslyn Compilers Team

  • sábado, 17 de marzo de 2012 16:44
     
     

    Yes make sense...

    Thanks.


    Adil Mughal (MCPD, MCT, MVP) - http://AdilMughal.com