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

Viewed 16803

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.

8 Answers

Restarting VS Code solved the problem in my case.

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.

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

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

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.

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

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).

enter image description here

Changing extension path manually helped me

Related