在我的解決方案中,我有項目引用(例如)「使用特定版本」設置爲false的System.ServiceModel.dll。 一切都與MSBuild 3.5良好。我可以使用msbuild 4.0來定位dotnet 3.5嗎?
我想使用msbuild 4.0以便使用property functions。我嘗試傳遞屬性「TargetFrameworkVersion = 3.5; ToolsVersion = 3.5」。但是,我收到以下錯誤:
Could not load file or assembly 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.configuration.dll' or one of its dependencies.
如果我使用msbuild 3.5,則不會發生這種情況。
我可以在不指定項目文件中的版本的情況下進行此項工作嗎? (今後我們可能想升級應用程序到dotnet 4)
編輯:我嘗試在「外部」調用中使用msbuild 3.5,併爲那些需要新功能的目標調用msbuild(使用<msbuild>
任務)4.0。這種要麼沒有運氣 - 內調用提供了以下錯誤信息:
error MSB4062: Could not load file or assembly 'Microsoft.Build.Tasks.v4.0, Version=4.0.0.0 or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, and that the assembly and all its dependencies are available.
標題問題的答案是「是」。我懷疑第二個問題的答案(針對沒有項目更改的程序集引用)可能是「否」。 您是否將特定項目定位到.NET 3.5?我的意思是,不是它的依賴關係,而是項目本身的目標框架。您可以在將來更輕鬆地修改這些內容。 – CJBrew 2012-02-27 11:50:56
解決方案是VS2008。所有項目都以3.5或2.0爲目標。 – Rob 2012-02-27 11:55:18
你確定你確實在調用MSBuild.exe 4.0版本的可執行文件嗎?它安裝在'%windir%\ Microsoft.NET \ Framework \ v4.0.30319 \'(對於32位)。或者確保您使用VS2010命令提示符(不是VS2008命令提示符)。 – 2012-02-28 09:23:44