0

So I am getting the error:

The imported project "C:\Microsoft.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

When I run this command:

%WINDIR%\Microsoft.NET\Framework\v2.0.50727\msbuild.exe MyProject.csproj /target:publish

I found others stating that I should change the following in my project file:

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

To this:

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

I have already tried this and am still getting the same error. It seems as if both reserved properties are empty or set to "C:" does any one have any suggestions?

Phobis
  • 7,524
  • 10
  • 47
  • 76

1 Answers1

2

Errors you're receiving might indicate .NET framework installation issues.
Create simple MSBuild file which will show you if that's the case:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt; <Target Name="PrintInfo"> <Message Text="MSBuild tools path is:$(MSBuildToolsPath)" />
</Target>
</Project>

Bolek Tekielski
  • 1,194
  • 2
  • 10
  • 25
  • Can you explain a little bit how that msbuild file helps diagnose the issue? – Frank Schwieterman Jan 30 '12 at 21:42
  • @Frank, it will basically print out the contents of those properties when the project is built. From the values that are returned the OP should be able to debug what path is being used to resolve those required files. – Adam Jan 14 '13 at 10:39