Unable to generate assets to build and debug. OmniSharp server is not running
Asked Answered
S

12

18

On Visual Studio (VS) Code, coding on C#. I'm trying to generate assets to build and debug and I'm getting the following error message: Unable to generate assets to build and debug. OmniSharp server is not running.

I'm running:

  • .NET version 3.1.301
  • Windows 8.1
  • Visual Studio Code 1.46.1 (user setup)
  • Powershell 5.1

So far I've tried unistalling VS code and the C# extention, I updated the omnisharp.path to latest at settings.json and updated the powershell version.

The code I'm trying to generate the assets for build and debug does run, so I'm uncertain where else I should look for the source of the problem.

If you require any more details feel free to ask

Scenarist answered 24/6, 2020 at 15:38 Comment(0)
S
3

Ended up discovering the issue. I needed to add a PATH variable to C:\Windows\System32 in the System Variables. Now it works as intended.

Adding the variable depends on your Windows version. You should be able to find guides on adding Paths to your Environment Variables. Here's Microsoft's guide.

As for which path variable you need to add it'll look something like: C:\Windows\System32\WindowsPowerShell\v.1.0

Scenarist answered 24/6, 2020 at 20:16 Comment(0)
U
11

CTRL + SHIFT + P

Use of the command :

OmniSharp: Restart OmniSharp

worked for me

enter image description here

Unfeigned answered 18/9, 2021 at 11:14 Comment(0)
M
5

This worked for me:

Ctrl + Shift + P

Then type the command:

OmniSharp: Select Project

enter image description here

Malemute answered 23/9, 2021 at 15:49 Comment(0)
E
5

Install the C# Extension, once installed click on the arrow on the side of the uninstall button and then click install another version. First I tried one from 2 months ago, it did not work, then I tried one from 6 months and it worked perfectly!

Exegetic answered 13/2, 2022 at 13:37 Comment(0)
M
4
  1. Added omnisharp.json file to the root folder with below content:

    { "msbuild": { "useBundledOnly": true } }
    
  2. Select the Command Palette using Ctrl + Shift + P and select the option "OmniSharp: Restart Omnisharp"

  3. Using the Command Palette, select the option "NET: Generate Assets for Debug and Build"

  4. The launch.json and tasks.json files will be added under the .vscode folder

  5. Now you should be able to debug your code

This solution worked for me.

Mcvey answered 22/9, 2021 at 16:47 Comment(0)
S
3

Ended up discovering the issue. I needed to add a PATH variable to C:\Windows\System32 in the System Variables. Now it works as intended.

Adding the variable depends on your Windows version. You should be able to find guides on adding Paths to your Environment Variables. Here's Microsoft's guide.

As for which path variable you need to add it'll look something like: C:\Windows\System32\WindowsPowerShell\v.1.0

Scenarist answered 24/6, 2020 at 20:16 Comment(0)
P
1

Quit VS Code completely.

Reinstall C# extension.

Regenerate C# Debug Assets. This will be prompted, or you could do this manually by

enter image description here

Percheron answered 21/10, 2022 at 8:52 Comment(0)
H
0

I had this problem using .NET 2.1.

Note that the C# for VS Code Extension (OmniSharp) now requires .NET 6 SDK or newer or a Full Framework runtime and MSBuild tooling. See requirements section.

After setting the extension setting omnisharp.useModernNet to false and installing Mono, I was able to able to generate assets to build and debug normally with the VS Code extension.

Huihuie answered 6/6, 2022 at 12:27 Comment(0)
B
0

I created .net project with dotnet CLI and started with "code ." command. But somehow, omnisharp didn't worked with that.

My problem solved like this;

I went to the file that i created. I dragged that file to visual studio code and launched with that.

And it worked :)

Broad answered 29/6, 2022 at 21:59 Comment(0)
R
0

Under Extensions in VS code - Clicking the arrow on the Uninstall button -> Install Another Version and then selecting the 2nd most recent one fixed this for me.

Robbirobbia answered 18/7, 2022 at 12:34 Comment(0)
U
0

Install Another Version Click Install Another Version under "Uninstall" and do a Reload window. Reload window Then a popup appears asking required assets. required assets Click "Yes"

Unamuno answered 24/8, 2022 at 6:35 Comment(0)
L
0

I am going to post this as an answer as I've faced this error and did not understand what was causing it. As a beginner I was trying to create a new .cs file and run it. As it appears, the correct way to create a .cs file and run it using dotnet inside of VSCode, is to:

  1. Open the console to the folder where you wish to run the file
  2. Create a new .cs project using the dotnet SDK using the command dotnet new console -o app (where "app" is the name of the project)
  3. Enter the project using the console and open VSCode there (e.g. cd .\app and then run code .)
  4. In order to run your .cs file run this command (dotnet run) either in the previously open terminal or a new terminal open in VSCode

Omnisharp should now be able to generate inside a .vscode file the necessary ".json" for debugging using CTRL + SHIFT + P and then using .NET: Generate Assets for Build and Debug

Hope this helps. P.S. This is my first post on stack overflow

Lucio answered 13/3, 2023 at 17:57 Comment(0)
H
0

i have tried many of these solutions and others without any success but i accidentally stumbled on a pretty simple solution,

i install the c# dev kit, now anytime i need to generate assets i just disable it, it prompts a restart then when i click it, it asks me if i want to generate assets.

ive tried to restart other ways including disabling other extenions or ctrl shf p restart and no other way will prompt me to add missing assets, hope this helps anyone who has struggled with this

Hanks answered 11/8, 2023 at 18:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.