Using Visual Studio Community 2022, version 17.4.4.
I just created a WPF (.NET Framework) solution using the built in VS template. To this solution, I wanted to add a .editorconfig
file to aid with code formatting. However, when right clicking the solution in Solution Explorer and following Add -> New Item... -> editorconfig File (.NET)
and naming it .editorconfig
, Visual Studio simply does not create it.
I followed these same steps again, but instead selected to add a plain .txt
file and it seemed quite happy creating it.
It's worth noting that I can add a new .editorconfig
to projects within the solution, but as I plan to add more projects in the future, I would like the solution itself to contain a top level .editorconfig
rather than need to duplicate it per project.
I have tried restarting VS, updating it, repairing it, and creating a completely separate solution. I get the same results. I'm aware .editorconfig
files are just plaintext files themselves, and that I can create a blank file and type into it manually, but ideally I want all of the presets to be populated out of the box.
Any help would be appreciated.
EDIT: I managed to temporarily get around it by creating it from VS settings: Tools -> Options -> Text Editor -> C# -> Code Style
and selecting the Generate .editorconfig file from settings
option. From here I select the solution folder. This doesn't solve the original issue that the add
context menu option doesn't create it, however.
^ Choose between this and Kevin Scharnhorst's answer.
I also have this issue. I tried to create an issue using the Visual Studio submit Feedback option, but I was unable to get it to submit.
The best workaround that I have found is opening the solution in VS 2019. Add the .editorconfig item to the solution there. Save and close VS 2019. Open the solution in VS 2022 and viola the .editorconfig file is visible in the Solution Items pseudo folder as it should have appeared with VS 2022.
You can open the solution file in Notepad++ to see the differences that are being written to the file as you overwrite the 2022 version with 2019, and then again as you re-save the 2019 file in 2022.