1

I just installed VSCode and am trying to format a C# file. However none of the suggestions here work. When I use the search functionality provided via Ctrl +Shift+ P and then searching for format code., nothing comes up.

I've tried this for many different file types, and formatting never is an option. How can I fix this?

Community
  • 1
  • 1
WhiskerBiscuit
  • 4,795
  • 8
  • 62
  • 100

1 Answers1

0

If you already have the C# extension installed, make sure that there is a project.json with minimal content in the root directory of your project.

enter image description here

There does need to be minimal content in the project.json file. Here an example of minimal content for the project.json file:

{
  "frameworks": {
    "netcoreapp1.0": { }
  }
}
Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467
  • Well, that *does* show the command now, but it does nothing. What goes inside the JSON? So if you open individual files, you are out of luck with formatting? – WhiskerBiscuit Nov 08 '16 at 23:31
  • @WhiskerBiscuit The JSON contains the .NET Core project configuration. I've added an example. I do not now know how to use C# formatting commands without a project.json file in the workspace root. – Shaun Luttin Nov 08 '16 at 23:51