Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template Studio is unable to create an app with whitespaces or hyphen in AppName #2892

Closed
debjyotigorai opened this issue Feb 3, 2019 · 31 comments
Assignees
Labels
bug The issue relates to the wizard not working or a problem with the generated code. Can Close Out Soon Work relating to this issue has been completed. Generated Code Relates specifically to code contained in the generated project.
Milestone

Comments

@debjyotigorai
Copy link

debjyotigorai commented Feb 3, 2019

I am getting the following error while creating an UWP app in C# using MVVW Basic. I think the error is related to "Setting Storage".

Error

System.Exception: Error executing 'Microsoft.Templates.Core.PostActions.Catalog.Merge.MergePostAction'. Related template: wts.Feat.SettingsStorage. ---> System.IO.FileNotFoundException: There is no merge target for file 'C:\Users\Debjyoti Gorai\source\repos\DG DEV (UWP)\DG_DEV__UWP_\Strings\en-us\Resources_postaction.resw'. Related Template: 'wts.Feat.SettingsStorage'.
at Microsoft.Templates.Core.PostActions.Catalog.Merge.MergePostAction.HandleFileNotFound(String originalFilePath, String suffix)
at Microsoft.Templates.Core.PostActions.Catalog.Merge.MergePostAction.ExecuteInternal()
at Microsoft.Templates.Core.PostActions.PostAction.Execute()
--- End of inner exception stack trace ---
at Microsoft.Templates.Core.PostActions.PostAction.Execute()
at Microsoft.Templates.Core.Gen.GenController.ExecutePostActions(GenInfo genInfo, TemplateCreationResult generationResult)
at Microsoft.Templates.Core.Gen.GenController.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Templates.Core.Gen.NewProjectGenController.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Templates.UI.Services.GenerationService.d__5.MoveNext()

@crutkas
Copy link
Member

crutkas commented Feb 3, 2019

Possible to share the exact items you selected outside of MVVM Basic?

I do agree it seems like a resource file for setting storage is missing.

@debjyotigorai
Copy link
Author

I selected the following:

Project Type:

Navigational Pane

Design Pattern:

MVVM Basic

Pages:

Web View (6 Nos), Tabbed (1 Nos), Settings (1 Nos)

Features:

Selected by default

            1) Settings Storage
            2) Theme Selection

Other things that I selected

            1) VS App Center Analytics
            2) Deep Linking
            3) User Activity
            4) Web to App link
            5) Suspend and Resume
            6) Share Source
            7) Toast Notifications
            8) First Run Prompt

@mrlacey
Copy link
Collaborator

mrlacey commented Feb 3, 2019

The issue is the space in the project name.

Simpler repro:

  • Project name includes a space (e.g "with space")
  • Navigation Pane
  • MVVM Basic
  • No extra pages
  • No extra features

@mrlacey mrlacey added this to the 3.1 milestone Feb 3, 2019
@mrlacey mrlacey added bug The issue relates to the wizard not working or a problem with the generated code. Generated Code Relates specifically to code contained in the generated project. labels Feb 3, 2019
@mrlacey
Copy link
Collaborator

mrlacey commented Feb 3, 2019

Not MVVMBasic specific - applies to all frameworks

@debjyotigorai
Copy link
Author

Ok thanks for the information.

@mrlacey
Copy link
Collaborator

mrlacey commented Feb 3, 2019

@debjyotigorai use a name like DgDevUwp) instead of DG DEV (UWP) and it should work fine.

@mrlacey mrlacey self-assigned this Feb 3, 2019
@mrlacey
Copy link
Collaborator

mrlacey commented Feb 3, 2019

I'm taking this as I already have a fix, as also found this issue as part of work for #299

This issue is not new, so don't think it warrants a hotfix. It's not specific to 3.0.

@crutkas
Copy link
Member

crutkas commented Feb 3, 2019

Thanks Matt for the quick triage and workaround. Unit test + fix for 3.1 then.

@mrlacey
Copy link
Collaborator

mrlacey commented Feb 3, 2019

Will add a fix for this and commit separately so it can go in sooner.

X-Ref #1784 (Some project names cause generated apps to not work)

I propopse making that a higher priority. We should do a better job of handling different input.

@crutkas
Copy link
Member

crutkas commented Feb 3, 2019

I thought we grabbed the VS code for file names. Maybe the logic needs to be diff for solution/project naming.

@mrgatesjunior
Copy link

I am also getting this error and I believe it is due to a "-" in the project main name. I will check it without the dash and report back.

@debjyotigorai
Copy link
Author

debjyotigorai commented Feb 3, 2019

Now it is working. Thanks for the workaround. It should warn the users of choosing a invalid project name and it's workaround before the wizard start creating the project.

@mrgatesjunior
Copy link

Here is the output of the main issue:

System.Exception: Error executing 'Microsoft.Templates.Core.PostActions.Catalog.Merge.MergePostAction'. Related template: wts.Feat.SettingsStorage.VB. ---> System.IO.FileNotFoundException: There is no merge target for file 'C:\Users\jesse\source\repos\TNO-Crypt\TNO_Crypt\Strings\en-us\Resources_postaction.resw'. Related Template: 'wts.Feat.SettingsStorage.VB'.
at Microsoft.Templates.Core.PostActions.Catalog.Merge.MergePostAction.HandleFileNotFound(String originalFilePath, String suffix)
at Microsoft.Templates.Core.PostActions.Catalog.Merge.MergePostAction.ExecuteInternal()
at Microsoft.Templates.Core.PostActions.PostAction.Execute()
--- End of inner exception stack trace ---
at Microsoft.Templates.Core.PostActions.PostAction.Execute()
at Microsoft.Templates.Core.Gen.GenController.ExecutePostActions(GenInfo genInfo, TemplateCreationResult generationResult)
at Microsoft.Templates.Core.Gen.GenController.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Templates.Core.Gen.NewProjectGenController.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Templates.UI.Services.GenerationService.d__5.MoveNext()

@debjyotigorai
Copy link
Author

      Here is the output of the main issue:

System.Exception: Error executing 'Microsoft.Templates.Core.PostActions.Catalog.Merge.MergePostAction'. Related template: wts.Feat.SettingsStorage.VB. ---> System.IO.FileNotFoundException: There is no merge target for file 'C:\Users\jesse\source\repos\TNO-Crypt\TNO_Crypt\Strings\en-us\Resources_postaction.resw'. Related Template: 'wts.Feat.SettingsStorage.VB'.
at Microsoft.Templates.Core.PostActions.Catalog.Merge.MergePostAction.HandleFileNotFound(String originalFilePath, String suffix)
at Microsoft.Templates.Core.PostActions.Catalog.Merge.MergePostAction.ExecuteInternal()
at Microsoft.Templates.Core.PostActions.PostAction.Execute()
--- End of inner exception stack trace ---
at Microsoft.Templates.Core.PostActions.PostAction.Execute()
at Microsoft.Templates.Core.Gen.GenController.ExecutePostActions(GenInfo genInfo, TemplateCreationResult generationResult)
at Microsoft.Templates.Core.Gen.GenController.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Templates.Core.Gen.NewProjectGenController.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Templates.UI.Services.GenerationService.d__5.MoveNext()

Choose a project name with only alphabets (both uppercase and lowercase).

@mrgatesjunior
Copy link

Yes, took the dash out and all seem to work fine.

@mrgatesjunior
Copy link

mrgatesjunior commented Feb 3, 2019

BTW, it is not an invalid project name. It is accepted across the board anywhere except with this extension, so in my opinion, needs to be resolved.

@debjyotigorai
Copy link
Author

      BTW, it is not an invalid project name.  It is accepted across the board anywhere except with this extension, so in my opinion, needs to be resolved.

I know that. I have created project names with empty spaces, dashes, underlines etc. I think Template Studio doesn't support till yet.

@mrgatesjunior
Copy link

Just referencing your comment of:

Now it is working. Thanks for the workaround. It should warn the users of choosing a invalid project name and it's workaround before the wizard start creating the project.

@crutkas
Copy link
Member

crutkas commented Feb 3, 2019

Great feedback, we are 100% fixing this issue :). Big decision is hotfix vs wait until next release.

@mrlacey
Copy link
Collaborator

mrlacey commented Feb 3, 2019

      I am also getting this error and I believe it is due to a "-" in the project main name.  I will check it without the dash and report back.

Yes, hyphens cause issues too. A fix is coming.

@mrgatesjunior
Copy link

Thank you all, appreciate it. And yes, dash is technically a hyphen :-)

@mrgatesjunior
Copy link

So, just curious, did the problem arise with this commit ?

7c185ae

@mrlacey
Copy link
Collaborator

mrlacey commented Feb 3, 2019

So, just curious, did the problem arise with this commit ?

No the issue is much older. There are places where the project name is being used for the namespace without first making it safe.

The merge is, for example, comparing My-App (the project name) with My_App (the "safe" project name) and failing because they're not equal. It's not specifically about file paths.

@mrgatesjunior
Copy link

Can you point me to the compare method / logic, just curios to see where you are referencing that from. I know in the previous release to this latest one, I could have a hyphen in the name and it worked fine.

@mrlacey
Copy link
Collaborator

mrlacey commented Feb 3, 2019

@mrgatesjunior https://github.com/Microsoft/WindowsTemplateStudio/blob/dev/code/src/Core/PostActions/Catalog/Merge/MergePostAction.cs#L37 is failing because namespaces are not matching.
As per this diff
image

On the right, line 1 has a spaces in "namespace App141 Space.Activation" while on line 6, on the left, it is "namespace App141_Space.Activation" - notice the underscore.

That is where the error is coming from.

I can't point to a specific chage that introduced the issue as it's lost in the vast number of changes that were made for v3.0.

If it did work with hyphens before then we'll release a hotfix for this.

@mrlacey
Copy link
Collaborator

mrlacey commented Feb 3, 2019

I now have it so it can handle assorted characters that previously caused issues.

If you really wanted, you could even do this:

image

Just need to add some more testing and then add some UI to handle some extra issues.

'$' is a valid character in a project name but using it will cause WTS to fail to generate the app. This is because it is used as an identifier in the filenames of global postactions.
'^' is a valid character in a project name but if it's included in the file name or path it will prevent Visual Studio from opening the solution. For that reason I also think we should not generate apps with this character in the name.

I think we should add a warning/error when openign the wizard if the name contains any of these characters. That could then be extended to handle scenarios from #1784

@mrgatesjunior
Copy link

Thank you for this. I would strictly follow what is allowed as a valid name within VS as a project name. That is just my two cents. I think one could get crazy with naming standards and conventions, but to me, the bottom line is whatever is allowed as a normal naming standard within VS is probably what you would want to follow.

@mrlacey
Copy link
Collaborator

mrlacey commented Feb 4, 2019

Following up elsewhere to get official rules about what is or isn't valid in a name.

mrlacey added a commit to mrlacey/WindowsTemplateStudio that referenced this issue Feb 4, 2019
For microsoft#2892
Tempaltes use  Param_RootNamespace instead of Param_ProjectName or wts.DefaultProject for namespaces
@mrlacey
Copy link
Collaborator

mrlacey commented Feb 4, 2019

Deferring the UI warning change to #1784 (and moving that to the 3.1 milestone) so this can go in ASAP.

@mrlacey mrlacey added the in-progress The issue is currently being actively worked on. label Feb 4, 2019
mrlacey added a commit to mrlacey/WindowsTemplateStudio that referenced this issue Feb 4, 2019
@mrlacey mrlacey added Can Close Out Soon Work relating to this issue has been completed. and removed in-progress The issue is currently being actively worked on. labels Feb 6, 2019
@mrgatesjunior
Copy link

Thank you for working on this !

@sibille sibille changed the title Template Studio is unable to create an app (C#) Template Studio is unable to create an app with whitespaces or hyphen in AppName Feb 7, 2019
@sibille
Copy link
Collaborator

sibille commented Feb 7, 2019

Just released Hotfix for this. Updating the extension to version 3.0.19038.01 should fix this.
Thanks again for reporting this!

@sibille sibille closed this as completed Feb 7, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Jun 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug The issue relates to the wizard not working or a problem with the generated code. Can Close Out Soon Work relating to this issue has been completed. Generated Code Relates specifically to code contained in the generated project.
Projects
None yet
Development

No branches or pull requests

5 participants