98

在我的VS2010中,當我構建我的解決方案時,我在文件Microsoft.Common.Targets中有超過100個警告。當我嘗試構建,發佈或運行我的程序時,我得到的只是警告,但是當我雙擊它以獲取更多信息時,Microsoft.Common.Targets彈出,然後我得到所有警告。在Microsoft.Common.Targets中構建「無效的子元素」警告

此文件Microsoft.Common.Targets是.net框架的一部分,並具有MSBuild內置目標等。它具有在屬性窗口中關聯的相關模式。

一些示例警告(2滿分100分):

Warning 2 The element 'PropertyGroup' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003' has invalid child element 'CustomBeforeMicrosoftCommonTargets' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003'. List of possible elements expected: 'Property' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003'. C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets 22 10 Miscellaneous Files 
Warning 3 The element 'PropertyGroup' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003' has invalid child element '_OriginalConfiguration' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003'. List of possible elements expected: 'Property' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003'. C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets 60 10 Miscellaneous Files 

爲什麼是這個文件突然在我的編輯器,當它是不是我的項目的一部分,以及如何告訴Visual Studio來忽略這個框架文件同時建設。

回答

161

如果我關閉所有編輯器窗口,然後構建它,所有的警告消失了!即使關閉&重新啓動visual studio並沒有解決這個問題,但只是關閉編輯器窗口中的所有文件,包括Microsoft.Common.Targets,修復了這個問題。 Arghhh微軟!

我發現了這一點,在看這個鏈接後:

http://social.msdn.microsoft.com/Forums/en/Vsexpressvb/thread/31f52b76-b0de-406d-9c25-2f329dd7cf1c

也適用於2013年和2015年版本

+0

同樣的事情發生在我和像你這樣我也擺脫了警告。謝謝 – Sheen

+0

哈哈這是可笑的...張貼解決方案! – womp

+0

剛剛在VS 2013發生了我。 – Palec