Harry Rawlins
Harry Rawlins

Reputation: 241

Could not locate .NET Core project. Assets were not generated

I just started learning C# a couple hours ago, but have since run into this error.

Ctrl + Shift + P

.NET:Generate Assets for Build and Debug

But when I click it, an error pops up bottom right of the window:

Could not locate .NET Core project. Assets were not generated.

Upvotes: 23

Views: 42043

Answers (16)

DanB-Web
DanB-Web

Reputation: 45

I've found just removing all other projects from the explorer and having only the project you want to generate the assets for loaded seems to work. This even works for generating multiple different assets for different projects under the same solution.

Reading through the above, I think it could be an issue with VSCode not being able to interpret which project you want to generate the assets for.

Upvotes: 0

SDHEER
SDHEER

Reputation: 56

The problem is you may not have an active solution, may be it is the solution which is opened as a folder. so the thing to do is

  1. Ctrl+Shift+p -> .Net: Open Solution.
  2. Ctrl+Shift+p -> .Net: Generate Asset for build and debug
  • this will list out the csproj available in the solution. Hope this helps

Upvotes: 0

illu
illu

Reputation: 11

I ran

dotnet new sln

and then

dotnet sln add .

in the terminal like another reply said and it fixed for me

Upvotes: 1

Kepol
Kepol

Reputation: 419

Had this problem on Unity too, and I finally I solved it by downgrading C# to any version lower than 2.0 this way I'm using Omnisharp instead of the C# extension. To downgrade an extension click the little arrow on the left of uninstall button. It also helped to uninstall from the package manager in Unity the visual studio code extension. Even though I still get an error asking me to upgrade C# extension. I still get intellisense and Omnisharp commands when pressing Ctrl+P

Upvotes: 0

Olivier Van den Nest
Olivier Van den Nest

Reputation: 11

Solved it by installing the C# Dev Kit extension

Then found this article:

https://code.visualstudio.com/docs/csharp/debugging

where the 'No launch.json' scenario helped me further creating an automatic debug configuration.

Hope it helps.

Upvotes: 1

Taksah
Taksah

Reputation: 221

I had this issue recently and to resolve it I installed C# Dev Kit and I switched to pre-release version v0.4.6. I couldn't generate debug files with C# extension. .NET sdk was 8 preview

Upvotes: 1

Connor94
Connor94

Reputation: 11

I had the same problem. Turns out I had the wrong .Net extension dowbloaded. Make sure you download the .Net Core tools extension. After I downloaded that, it worked fine for me.

Upvotes: 1

Honza Vojtěch
Honza Vojtěch

Reputation: 933

This happened when I had multiple C# projects and solutions in the directory. What I had to do was to open the command palette by pressing Ctrl+Shift+P and execute Omnisharp: Select Project. After choosing the right project, VS Code offered me the assets generation automatically.

Upvotes: 2

Manjeet deswal
Manjeet deswal

Reputation: 785

enter image description here

Changing extension path manually helped me

Upvotes: 3

In my case I just uninstall the c# extension and reload the vscode, after I install again (The vscode will ask to install some assets and somethings that miss in the project too).

Upvotes: 0

kiko carisse
kiko carisse

Reputation: 1784

This same thing started happening to me on my mac on vscode. For me, it was because I didn't add my dotnet project to my solution file after I created the solution file and project.

This is essentially how I created my project:

  1. Create empty project folder mkdir RecipeApp && cd RecipeApp

  2. Add Solution File to Project (uses the name of containing folder) dotnet new sln

  3. Create Backend .NET API dotnet new webapi -o API

Then this is the part I forgot to do (which actually solved a few other problems I was having, like I couldn't use the CMD + . feature to auto import classes and assets etc, too):

  1. Add the sub project to the solution file dotnet sln add API

After I added the API subproject to the solution file, I could open the main top level project folder in vscode, and everything started working again.

Upvotes: 15

OuttaSpaceTime
OuttaSpaceTime

Reputation: 986

for me it helped to open the project with opening project_name.csproj with vs-code instead of loading the folder

Upvotes: 0

SomeDudeWhoExists
SomeDudeWhoExists

Reputation: 1

What I recommend doing is pressing "Run" then start debugging, which should open up a launch.json. If you open it, it will have about 17 warnings and then you can delete the warnings. Then, you press f5, which will give you an option to open a tasks.json. Do that and configure all of the tasks for running your project and it should work.

Upvotes: 0

how you doin
how you doin

Reputation: 31

In my way helped to change the folder name to a name without spaces.

Upvotes: 3

AlexProutorov
AlexProutorov

Reputation: 707

Restarting VS Code solved the problem in my case.

Upvotes: 28

Sai Gummaluri
Sai Gummaluri

Reputation: 1404

This issue could be because the launch.json, which ideally should have been populated with the necessary details isn't generated in case. This issue seems to be linked to Omnisharp. If you go through the issue, you understand the root cause more clearly. You may need to perform the steps mentioned in this comment to get around the issue. These steps involve re-configuring the C# extension inside of your VS Code instance.

Alternately, ensure that all the folders which the extensions uses have appropriate access.

If the issue is also involving task.json, take a look at this answer

Upvotes: 3

Related Questions