microsoft / TemplateStudio

Template Studio accelerates the creation of new WinUI 3, WPF, and UWP apps using a wizard-based experience.
Other
2.68k stars 459 forks source link

Unable to create a project in VS 2022 #4652

Closed polymood closed 1 year ago

polymood commented 1 year ago

Describe the bug

Whenever creating a new project (no matter the configuration of the project) and clicking "Create" an error message appears :

image

Here is the complete error message :

========== Exception Tracked [2023-04-16 22:45:30.953] ==========
[22:45:31.025 - Information]::Creating 'Template Studio for WinUI' project...
Additional Message: Language: 'C#'
ProjectType: 'Blank'
Front End Framework: 'MVVMToolkit'
appmodel
Pages: 'Main - ts.WinUI.Page.Blank, Settings - ts.WinUI.Page.Settings'
Features: 'MSIX Packaging - ts.WinUI.Feat.MSIXPackaging, Settings Storage - ts.WinUI.Feat.SettingsStorage, Theme Selection - ts.WinUI.Feat.ThemeSelection'

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Templates.Core.Gen.GenController.ValidateUserSelection(UserSelection userSelection, Boolean isNewProject)
   at Microsoft.Templates.Core.Gen.NewProjectGenController.<UnsafeGenerateProjectAsync>d__4.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.Templates.UI.Services.GenerationService.<GenerateProjectAsync>d__5.MoveNext()
----------------------------------------------------------------
========== Exception Tracked [2023-04-16 22:47:52.768] ==========
Additional Message: Exception when generating the project
Microsoft.VisualStudio.TemplateWizard.WizardCancelledException: Exception of type 'Microsoft.VisualStudio.TemplateWizard.WizardCancelledException' was thrown.
   at Microsoft.Templates.UI.VisualStudio.GenShell.VsGenShellUI.CancelWizard(Boolean back)
   at Microsoft.Templates.UI.Services.GenerationService.<GenerateProjectAsync>d__5.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.Templates.UI.VisualStudio.SolutionWizard.<RunFinishedAsync>d__35.MoveNext()
----------------------------------------------------------------

I have tried multiple different combinations of features for the project during initial setup, same error every time. I have never used Template Studio before, this is the first time.

To Reproduce

  1. Create a new WinUI 3 Project
  2. Select features
  3. Click "Create" button
  4. error message appears

Additional context

No response

Applies to the following platforms:

About your setup

polymood commented 1 year ago

UPDATE: When creating a project, choosing not to "Place solution and project in the same directory" seems to solve the issue.

mrlacey commented 1 year ago

Can you create a WinUI app without using Template Studio? (Blank App, Packaged (WinUI 3 in Desktop)) I suspect there's a dependency that's missing but not been detected. If you try and create an app with the default template you might get an exception message that points to the underlying issue

polymood commented 1 year ago

Can you create a WinUI app without using Template Studio? (Blank App, Packaged (WinUI 3 in Desktop)) I suspect there's a dependency that's missing but not been detected. If you try and create an app with the default template you might get an exception message that points to the underlying issue

Creating a Blank App, Packaged (WinUI 3 in Desktop) works fine.

mrlacey commented 1 year ago

UPDATE: When creating a project, choosing not to "Place solution and project in the same directory" seems to solve the issue.

What directory are you trying to create the project in?

This sounds like a duplicate of #4416

polymood commented 1 year ago

In an empty directory on a non-boot drive. I think it is a duplicate of #4416 indeed