Anyone knows how can I add a dependency reference programmatically in C#?
The think is I am already generating a new project programmatically, but I need to add some references to that project.
Is it possible to do it programmatically?
Thanks.
Anyone knows how can I add a dependency reference programmatically in C#?
The think is I am already generating a new project programmatically, but I need to add some references to that project.
Is it possible to do it programmatically?
Thanks.
See Scott's answer here: c# Visual Studio ...adding references programmatically
EnvDTE80.DTE2 pEnv = null;
Type myType = Type.GetTypeFromProgID("VisualStudio.DTE.8.0");
pEnv = (EnvDTE80.DTE2)Activator.CreateInstance(myType, true);
Solution2 pSolution = (Solution2)pEnv.VS.Solution;
Project pProject = pSolution.Projects[0];
pProject.References.Add(string referenceFilePath);