Can Rider format cshtml files outside of a project/solution?

I'm using a CMS where the cshtml/Razor files are located in folders outside of a solution. Their examples tells us, we can create an empty project, load the correct assemblies, and then get correct markup, formatting, types, and so on. And that works great.

But, when Rider formats code (indentation, styles, etc), does it need the actual "context" of the file? Because whatever I do, I cannot get Rider to auto format my .cshtml files, when they are outside of a project/solution.

What can I do to make Rider able to format my Razor code, if I just use Rider as a text editor (for example)?

0
3 comments

Hello @...,

Currently, Rider works with files within the "Project" context - a file should be included in the project to be recognized by the formatting engine. Meaning that the example you mentioned is correct - the cshtml/Razor files should be located in directories within a solution/project.

If you encounter any formatting issues once you add the cshtml/Razor files to the project - let me know.

0
Avatar
Permanently deleted user

Kirill Filin That's unfortunate. And there is no way I can bypass it? Or does it use the context of the file for formatting, hence why it won't work if it's a standalone file?

0

@..., regrettably, Rider does not use the formatting engine on the files outside of the solution/project, so there is no way to bypass this.

Please feel free to create a new issue on the tracker (and mention the CMS you are using in the description) if using an empty project for the .cshtml/Razor files is inconvenient for you.

0

Please sign in to leave a comment.