Visual Studio Project MSBuild Import Error Fix

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 …

image

 

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:

clip_image001

 

How to fix

Change the MSBuild Property $(MSBuildToolsPath) to $(MSBuildBinPath) and the project should load.

Like so:

clip_image001[7]

  • Aaron

    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

    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