Frage

Ich wollte wissen, wie die Vorlage für ein leeres Visual C ++ - Projekt verwendet wird, um mit diesem leeren Projekt programmgesteuert eine neue Lösung zu erstellen.Der Code (C #), den ich gerade habe, lautet:

string VSProgID = "VisualStudio.Solution.10.0";
Type solnObjType = System.Type.GetTypeFromProgID(VSProgID, true);
Solution4 soln = (Solution4) System.Activator.CreateInstance(solnObjType, true);
soln.Create(@"C:\NewSoln", "New");
soln.SaveAs(@"C:\NewSoln\New.sln");
string emptyVCProjPath = soln.GetProjectTemplate("General/Empty Project", "VC++"); // Here's where I need help
soln.AddFromTemplate(emptyVCProjPath, @"C:\NewSoln\NewProj", "New.vcxproj", false);

Ich konnte die VC ++ Empty Project-Vorlage nicht an der Stelle finden, an der sich alle anderen Vorlagen (C # / F # / VB) befinden.Die leere VC ++ - Projektvorlage wird in den installierten Vorlagen angezeigt, wenn ich ein neues Projekt manuell über die IDE erstelle.Was sollten die Parameter für soln.GetProjectTemplate() sein?"VC++" scheint keine Sprache zu erkennen.Ich weiß, dass "CSharp" und "VisualBasic" gültige Optionen sind.Aber ich wollte ein VC ++ Empty Project.Jede Hilfe wird sehr geschätzt.

War es hilfreich?

Lösung

I am posting this answer in the hope that it may help someone facing the same problem that I was facing.

Apparently the Visual Studio Extensibility framework API doesn't provide an option to create an Empty Visual C++ project programmatically. I had to generate the solution and project files to achieve this. Specifically, the [solution_name].sln, [project_name].vcxproj, and [project_name].vcxproj.filters files had to be generated. A GUID had to be generated for the new project and inserted at the appropriate places. If one needs to add files to this empty project, ClInclude tags need to be generated for header files, and ClCompile tags for source files. These tags are added to the [project_name].vcxproj, and [project_name].vcxproj.filters files. Refer to an existing Visual C++ project's files to help you figure out what goes where. It is pretty straightforward.


UPDATE

For some reason, the VC++ solution generated this way does not open directly (by double-clicking the solution file in Windows Explorer). I have to launch Visual Studio and open the solution from there.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top