none
Add reference path to IProject?

Réponses

  • 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

    mercredi 14 mars 2012 20:23
    Propriétaire

Toutes les réponses

  • 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

    mercredi 14 mars 2012 20:23
    Propriétaire
  • Yes make sense...

    Thanks.


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

    samedi 17 mars 2012 16:44