If you get this error:
Unable to read the project File <path.to.project>.csproj.
C:\<path>\<to>\<projecct>\Project.csproj 77, 11): The imported project “C:\Microsoft.CSharp.targets’ was not Found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
As shown in this screen shot …
Take a look at your project file. Open it in a text editor (such as NotePad++) and look for the import statement.
Mine looked like this:
How to fix
Change the MSBuild Property $(MSBuildToolsPath) to $(MSBuildBinPath) and the project should load.
Like so:
Aaron says
You are a life saver. I did not have this error opening the project in Visual Studio, but I had a similar error using MSBuild on our build machine. I think we are using an older version of MSBuild.
s:….xxx.csproj (74, 11): The imported project “s:Microsoft.CSharp.targets” was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
I changed the MSBuild property you suggested and my build works now.
Aftab says
you can also use the /p switch to override the MSBuildToolsPath to specify the .net framework folder where the msbuild.exe is located:
C:WindowsMicrosoft.NETFrameworkv2.0.50727msbuild.exe yourProject.vbproj /p:MSBuildToolsPath=C:WindowsMicrosoft.NETFrameworkv2.0.50727
Coach Factory Outlet says
http://buycoachfactoryoutletsz.com
Johan says
Which file should i open in notepad? I cannot find in the project file!
JD says
Thanks for the short tip. 2 days of research later, the key was to open the file in notepad not visual studio. Much appreciated!
Christian Edholm says
For those of you who still have this problem: I myself am running VS 2015 and fixed this by deleting the Microsoft.Net.Compilers.1.0.0 folder. VS restored the folder when i opened the project and it was able to load the project.
matthewcanty says
I did “git clean -xdf” and it solved the problem. Probably same issue. Thanks for nudging me there.
kapil says
where to find