We have created our own Visual Studio Template extension. We have this working for many years, but in our upgrade to .NET 6 we have to make a few changes.
When trying to create a new project from our template, we get this exception:
The error itself is not much helpfull. I tried to find ways to get more logging out of VS, the only option i found is the run DevEnv.exe with -Log. Which i did, it gave me more meaningless details about the error, still nothing i could work with.
<entry>
<record>2531</record>
<time>2023/11/24 06:08:07.091</time>
<type>Error</type>
<source>Template provider aggregator</source>
<description>System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
 at Microsoft.VisualStudio.CommonIDE.Solutions.Interop.IVsNativeEnvironmentInternal.WizLoadAndRunFile(String pwszWizard, String pwszDestination, Boolean bCloseSolution, Boolean bRunSilent, Array psaCustomParams, String pwszFrameworkVersion)
 at Microsoft.VisualStudio.CommonIDE.Solutions.Dte.DteSolution.<AddFromTemplateExAsync>d__256.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at Microsoft.VisualStudio.CommonIDE.Solutions.Dte.DteSolution.<AddFromTemplateExAsync>d__256.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
 at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()
 at Microsoft.VisualStudio.CommonIDE.Solutions.Dte.DteSolution.AddFromTemplateEx(String FileName, String Destination, String ProjectName, String SolutionName, Boolean Exclusive, UInt32 Options)
 at Microsoft.VisualStudio.CommonIDE.Solutions.Dte.DteSolution.<>c__DisplayClass25_0.<EnvDTE100.Solution4.AddFromTemplateEx>b__0()
 at Microsoft.VisualStudio.NewProjectDialog.LegacyVsTemplateProvider.GetInstantiationResult(CreateProjectResult result)
 at Microsoft.VisualStudio.NewProjectDialog.LegacyProjectTemplateProvider.<InstantiateTemplateAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at Microsoft.VisualStudio.TemplateProviders.TemplateProviderSupport.ExceptionLoggingTemplateProviderDecorator.<InstantiateTemplateAsync>d__9.MoveNext()</description>
</entry>
In older versions of Visual Studio, you could use a 2nd instance and attach it to the other instance. This does not work anymore, i cannot get any information out of my attached process.
What other options do i have to figure out which file Visual Studio appears to be missing?
Try to attach the Visual Studio debugger to another instance and replicate the error. This way you may be able to get more insight as to what is wrong.
In older versions of Visual Studio, you could use a 2nd instance and attach it to the other instance. This does not work anymore, i cannot get any information out of my attached process.
It does work. I faced a similar issue recently and did just that. Be sure to have the "Just My Code" checkbox disabled in Debug -> Options. Otherwise the debugger will not report the exception.