生成时 Microsoft.Common. Targets 中的“有无效子元素”警告

在我的 VS2010中,当我构建解决方案时,在文件 微软,通用,目标中有超过100个警告。当我尝试构建、发布或运行我的程序时,我得到的只是警告,但当我双击它以获得更多信息时,微软。常见。目标突然出现,然后我得到所有的警告。

此文件 Microsoft。常见。目标是。网络框架,并具有 MSBuild 内置的目标等。并且它在属性窗口中具有相应的模式。

一些示例警告(100个中有2个) :

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 在构建时忽略这个框架文件。

56993 次浏览

If I close all the editor windows, and then build it, all the warnings have disappered! Even a close & restart of visual studio did not fix this, but just closing all files from the editor window, including Microsoft.Common.Targets, fixed the problem. Arghhh Microsoft!!

I found this out after looking at this link :

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

Also works on 2013 and 2015 editions

If you are using VS 2017 or newer version, than you can remove the namespace part and the error will gone.

"The schema link in an MSBuild project file is not required in Visual Studio 2017 and later. If present, it should be http://schemas.microsoft.com/developer/msbuild/2003 regardless of the version of Visual Studio."

Reference: MSBuild project file schema reference