My csproj file is suddenly become empty due to which project is not getting loaded in visual studio. How to recreate or restore csproj file
Loading
My csproj file is suddenly become empty due to which project is not getting loaded in visual studio. How to recreate or restore csproj file
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Gurpreet AroraPosted Jun 26, 2021, 7:36 PM
Open a fresh copy of Visual Studio
Create a project in a different location of the same type as
B, with the same name.Close that copy of Visual Studio
Copy the newly created
B.csprojfile to the directory where all your source forBis, overwriting the existingB.csprojfile (but take a copy of it, just incase you need it!).Load Visual Studio and open Solution
A.You'll note that the project doesn't contain any of the files / references you'd expect and will probably contain a "broken" reference to
Class1.csor any other files that were added to the new project file when Visual Studio created it. Now:Make sure Project B is selected in Solution Explorer and click the "Show All Files" icon. It's the one that has a picture of 3 files overlaying each other in it, to the left of the Refresh icon.
You'll be able to see all the content of your project but "greyed out". Select each file/folder you want to add back, right click and choose "Include In Project".
Assuming there's nothing too complicated about your project, you should only now need to re-add any References and it should compile and run.
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-restore
Nabin AgarwalaPosted Jul 3, 2021, 12:20 PM
Rajanikant HawaldarPosted Jun 26, 2021, 2:48 PM
Salman BegPosted Jun 26, 2021, 1:39 PM