Phobis
Phobis

Reputation: 7754

Is there a way to fix the imported project error for Microsoft.CSharp.targets, other than changing the reserved property to $(MSBuildBinPath)?

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?

Upvotes: 0

Views: 3804

Answers (1)

Bolek Tekielski
Bolek Tekielski

Reputation: 1214

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>

Upvotes: 2

Related Questions