I'm fairly new to using EnvDTE, but I've managed to get it to generate a project using a copy of the Visual Studio-included csConsoleApplication template*. Problem is, I need it to be a net6.0 app, not .NETFramework v4.0, which is what's being generated. I don't know how to change this. It could very well be because the project containing the EnvDTE code to generate this project is a Framework one.
*As I'm using a copy of the template (there are reasons for this which are irrelevant here), if I can edit the .csproj or .vstemplate files (or any of the other template files) to accomplish my goal, that would be fine. Otherwise, there must be a way to do it in the DTE code.
Speaking of which, here's the generation code in case it becomes relevant:
// ... Code to get the DTE instance
dte.Solution.Create(solutionDirectory, currentProject.CodeSafeName);
Solution solution = dte.Solution;
// Don't worry, this won't remain a hard-coded path!
solution.AddFromTemplate(@"C:\Users\Logix\Desktop\TEMPLATE\csConsoleApplication.vstemplate", $@"{solutionDirectory}\{currentProject.CodeSafeName}", currentProject.CodeSafeName, true);
// ... Code to add DLL references
dte.ExecuteCommand("File.SaveAll");
dte.Solution.Close();
dte.Quit();
The template was copied from:
C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\ProjectTemplates\CSharp\Windows\1033\ConsoleApplication
though of course if you need to take a look at those files, you may have to change this path to match your VS version.
Thanks in advance.