How to add a reference to a website project by automation
In a previous post I explained how to add a reference to a project by automation.
http://weblogs.asp.net/gmilano/archive/2004/09/23/233494.aspx
This method is not going to work with a website project, for website projects you should:
- Add a reference to VsWebSite.Interop dll
- Now you can do something like this:
Imports VsWebSite
Dim project As Project
Dim site As VsWebSite.VSWebSite
project = DTE.Solution.Projects.Item(1) ' I suppose it is a website project
site = CType(project.Object, VsWebSite.VSWebSite)
site.References.AddFromGAC("System.Data.dll")
This sample add a reference to the first project in the solution to System.Data.dll.