Hi,
I am writing a Visual Studio plugin and have created a new solution
programmatically (C#):
// Assuming applicationObject is a valid DTE2 instance.
Solution2 solution = (Solution2)_applicationObject.Solution;
solution.Close(true);
solution.Create(p.StartInfo.WorkingDirectory, "testSln");
Then I create a new VCProject programmatically:
VCProjectEngine projectEngine = new VCProjectEngineObject();
VCProject project = projectEngine.CreateProject("testProject");
project.AddPlatform("Win32");
project.AddConfiguration("TestConf");
VCConfiguration configuration = (VCConfiguration)
project.Configurations).Item("TestConf");
configuration.ConfigurationType = ConfigurationTypes.typeUnknown;
So far so good. I've looked around for a way to add the VCProject to
the solution but haven't found anything. I have tried doing the following:
project.ProjectFile = "C:\\testProj.vcproj";
project.Save();
solution.AddFromFile(project.ProjectFile, false);
But AddFromFile throws an exception: "Error HRESULT E_FAIL has been
returned from a call to a COM component.".
I am hoping somebody on this list has a solution or is able to point
me to some other forum/mailinglist, where it would make sense to ask.
Best Regards,
Morten Nielsen