2010-01-29 47 views
0

所以我得到的錯誤:

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.

當我運行此命令:

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

我發現別人指出我應該改變我的項目文件中的以下內容:

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

對此:

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

我已經試過這個,我仍然得到相同的錯誤。看起來好像兩個保留屬性都是空的或設置爲「C:」有沒有人有任何建議?

回答

2

您收到的錯誤可能表明.NET框架安裝問題。
創建簡單的MSBuild文件,該文件會告訴你,如果是這樣的話:

< XML版本= " 1.0 "編碼= " UTF-8 "? >
< Project xmlns = " http://schemas.microsoft.com/developer/msbuild/2003"&gt; <目標名稱= " PrintInfo " > <消息文本= "的MSBuild工具的路徑是:$(MSBuildToolsPath)"/>
< /目標>
< /項目>

+0

你能解釋一下怎麼說msbuild文件有助於診斷問題? – 2012-01-30 21:42:59

+0

@Frank,它將基本打印出項目構建時這些屬性的內容。根據返回的值,OP應該能夠調試用於解析那些所需文件的路徑。 – Adam 2013-01-14 10:39:15

相關問題