-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix post actions for Razor Class Library template #64532
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
base: main
Are you sure you want to change the base?
Fix post actions for Razor Class Library template #64532
Conversation
The Razor Class Library template has an option, `SupportsPagesAndViews` that causes it to produce one of two sets of files. If true, then `Areas/MyFeature/Pages/Page1.cshtml` is created. If false, then `Component1.razor` is created. The issue with the previous template is that the set of primary outputs and the corresponding `openInEditor` post-actions were not taking this option into account, and were always trying to open the `Page1.cshtml` file, even if it didn't exist on disk. This led to the bug described in microsoft/vscode-dotnettools#2489 C# Dev Kit has been patched to not show warnings when a template specifies that non-existent files should be opened. With the change here, users creating this template will now see the correct file opened. This applies both to VS and CDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug in the Razor Class Library template where post-actions were attempting to open files that didn't exist. The template supports two modes controlled by the SupportPagesAndViews parameter: when true, it creates Areas/MyFeature/Pages/Page1.cshtml; when false, it creates Component1.razor. Previously, the template always tried to open Page1.cshtml regardless of which mode was used.
Key changes:
- Added conditional logic to
primaryOutputsto specify the correct file based onSupportPagesAndViewsparameter - Added a new
openInEditorpost-action for theComponent1.razorfile with appropriate conditions - Updated the existing
openInEditorpost-action forPage1.cshtmlto only apply whenSupportPagesAndViewsis true
|
I can't see how the pipeline failures are related to this change. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
The Razor Class Library template has an option,
SupportsPagesAndViewsthat causes it to produce one of two sets of files. If true, thenAreas/MyFeature/Pages/Page1.cshtmlis created. If false, thenComponent1.razoris created.The issue with the previous template is that the set of primary outputs and the corresponding
openInEditorpost-actions were not taking this option into account, and were always trying to open thePage1.cshtmlfile, even if it didn't exist on disk.This led to the bug described in microsoft/vscode-dotnettools#2489
C# Dev Kit has been patched to not show warnings when a template specifies that non-existent files should be opened.
With the change here, users creating this template will now see the correct file opened. This applies both to VS and CDK.