microsoft / TemplateStudio

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

Project Creation Stuck on Creating Project #4601

Open iltan987 opened 2 years ago

iltan987 commented 2 years ago

Describe the bug

I have installed Template Studio for UWP using Visual Studio Extensions Market. Screenshot 2022-10-10 182652 I didn't change any settings. I am just creating new default Template Studio for UWP Project. I have waited a lot but nothing happens. Everything is latest version. If necessary I can give more details but it's simple. Please help me if I am doing something wrong. Thanks.

To Reproduce

Start Visual Studio Press Create New Project and select Template Studio for UWP. On the Details section, do not change any settings and directly press Create. It stuck on Creating Project screen with a progress bar.

Additional context

No response

Applies to the following platforms:

About your setup

mikebattista commented 2 years ago

I could not repro on Windows 11 22H2. It took a minute to create the project but it eventually did complete.

GF-Huang commented 1 year ago

Same issue when creating WinUI.

Win11 22H2 VS2022 17.5.3 Template Studio for WinUI (C#) 5.3

honehone12 commented 1 year ago

Same or related isuue on WinUI, WPF, and UWP. Versions are same with last comment, but I can see error message in my case.

System.UnauthorizedAccessException: Access to the path 'C:\Users\myname\AppData\Local\Application Data' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileSystemEnumerableIterator`1.AddSearchableDirsToStack(SearchData localSearchData)
   at System.IO.FileSystemEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Microsoft.Templates.Core.PostActions.PostActionFactory.AddMergeActions(GenInfo genInfo, List`1 postActions, String searchPattern, Boolean failOnError)
   at Microsoft.Templates.Core.PostActions.NewProjectPostActionFactory.FindPostActions(GenInfo genInfo, ITemplateCreationResult genResult)
   at Microsoft.Templates.Core.Gen.GenController.ExecutePostActions(GenInfo genInfo, ITemplateCreationResult generationResult)
   at Microsoft.Templates.Core.Gen.GenController.<GenerateItemsAsync>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.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()
mrlacey commented 1 year ago

@honehone12 That indicates a permission issue.

To help identify the exact issue:

Do you have any restrictions on the account your using on that machine? Do you have Visual Studio installed on a drive other than 'C'? Do you get the same result if you run Visual Studio as an Administrator?

honehone12 commented 1 year ago

@mrlacey I have an update. After making "solution and project in same directory" unchecked, template studio works. It might be my case was related to https://github.com/microsoft/TemplateStudio/issues/4416#issue-1183910370. Thank you anyway!

GF-Huang commented 1 year ago

@mrlacey I have an update. After making "solution and project in same directory" unchecked, template studio works. It might be my case was related to #4416 (comment). Thank you anyway!

It is unchecked in default, not work for me.

mrlacey commented 1 year ago

@honehone12 and @GF-Huang What directory are you trying to create the project in? (If it's a subdirectory of AppData that might also be a factor)

For note, even if this is tied to the same underlying issue as #4416, I'd still like to fix this so it doesn't hang indefinitely. (Which I suspect is due to an exception being swallowed and something never completing.)

GF-Huang commented 1 year ago

What directory are you trying to create the project in?

Desktop.

honehone12 commented 1 year ago

@mrlacey C:/Users/myname

mrlacey commented 1 year ago

Thank you both. I can repro what you're seeing. (Although not the infinite hang) Yes, this is the same issue as #4416 The wizard is trying to access directories it shouldn't and (rightly) doesn't have permission to access.

Note. This doesn't reflect the issue in the original screenshot, as that is using a path that shouldn't be affected.

GF-Huang commented 1 year ago

Thank you both. I can repro what you're seeing. (Although not the infinite hang) Yes, this is the same issue as #4416 The wizard is trying to access directories it shouldn't and (rightly) doesn't have permission to access.

Note. This doesn't reflect the issue in the original screenshot, as that is using a path that shouldn't be affected.

Any workarounds?

mrlacey commented 1 year ago

Any workarounds?

The workaround for putting the solution and project in the same directory is to not do this during generation. You can then move them after creation.

For hangs of another reason, I don't have a solution or workaround as we're unable to recreate.

I'm working on solution for the same directory issue but a lot of the original logic was based on the assumption that there will always be a solution directory,

GF-Huang commented 1 year ago

@mrlacey Where can I find the log files? I want to post you for solves this issue.

mrlacey commented 1 year ago

@mrlacey Where can I find the log files? I want to post you for solves this issue.

Logs will be in something equivalent to C:\Users\matt\AppData\Local\TS4WinUICs\Logs

and look like this: image

Another thing you can try is to:

image

GF-Huang commented 1 year ago

Ha, I create project successful today. Is it depends network during creation?

mrlacey commented 1 year ago

Ha, I create project successful today. Is it depends network during creation?

The only network-related thing it does is restore NuGet packages. If you've never built with that version of WinAppSDK before it could bring down a lot and that may take a lot of time....

GF-Huang commented 1 year ago

I compare today and previous log files, previous day it stucks at

Information Generating the template ts.WinUI.Project.Core.AddPlatforms to C:\Users\MyName\Desktop\App1.

I think it maybe the issue as you thought. If it is, maybe do the restoring NuGet package step after VS main window display will be better if template studio can control this; otherwise peoples who creating project from Start Window can not see the bottom status bar.