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.
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). |
|
CI error:
|
When building locally these files get modified with the new keys. Looks like this was caused by #64532
When building locally these files get modified with the new keys. Looks like this was caused by #64532
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.