Reputation: 2881
I've broken my vscode project by renaming the folder or something. Not totally sure what happened. The problem is whilst I can still build and run no problems, something has been messed up so that when I get a compilation error for example when I double click on the message it says
Unable to open 'XXXController.cs':File Not Found (file://Controllers/XXXController.cs)
Somewhere along the line it seems to have lost the full path to the cs files for 1 of 3 projects in my source folder. I was under the impression that vscode doesn't maintain a list of files in the project so I'm at a loss to work out how I can recover other than recreating the project?
There are other issues as well - intellisense doesn't seem to work for this project either.
Does anyone have any ideas how I try and fix this?
Edit: It presents an option to create the 'missing' file. When I do so it creates a new file in C:\Controllers\ rather than in the \Controllers folder under the *.csproj location?
Regards Dave
Upvotes: 6
Views: 8319
Reputation: 2881
The problem appears to be that msbuild by default doesn't output full paths when it reports errors, omnisharp-vscode requires full paths to resolve files so adding GenerateFullPaths=true to the .vscode\tasks.json seems to resolve the issue.
i.e.
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Test.Api/Test.Api.csproj",
// Ask msbuild to generate full paths for file names.
"/property:GenerateFullPaths=true"
],
"problemMatcher": "$msCompile"
}
]
}
Upvotes: 12