The imported project "C:\Microsoft.CSharp.targets" was not found
Solution 1:
Open your csproj file in notepad (or notepad++) Find the line:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
and change it to
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Solution 2:
This is a global solution, not dependent on particular package or bin.
In my case, I removed Packages folder from my root directory.
Maybe it happens because of your packages are there but compiler is not finding it's reference. so remove older packages first and add new packages.
Steps to Add new packages
- First remove, packages folder (it will be near by or one step up to your current project folder).
- Then restart the project or solution.
- Now, Rebuild solution file.
- Project will get new references from nuGet package manager. And your issue will be resolved.
This is not proper solution, but I posted it here because I face same issue.
In my case, I wasn't even able to open my solution in visual studio and didn't get any help with other SO answers.