107

In my VS2010, when I build my solution, I have over 100 warnings in the file Microsoft.Common.Targets. When I try to build, publish or run my programs, I get just the warnings, but the moment I double click it to get more info, the Microsoft.Common.Targets pops up and then I get all on the warnings.

This file Microsoft.Common.Targets is part of the .net framework and has the MSBuild in-built targets, etc. And it has the approperiate schema associated in the properties window.

Some example warnings (2 out of 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

Why is this file suddenly in my editor, when it is not part of my project, and how to tell visual studio to ignore this framework file while building.

2 Answers 2

181

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

8
  • The same happened to me and also I got rid of warnings like you did. Thanks
    – Sheen
    Jun 15, 2015 at 20:46
  • Haha this is ridiculous... ty for posting the solution!
    – womp
    Oct 21, 2015 at 21:35
  • Just happened to me in VS 2013.
    – Palec
    Dec 9, 2015 at 16:58
  • 1
    And in Visual Studio 2022!
    – William
    Nov 18, 2021 at 14:17
  • 1
    And in visual studio 2019
    – user11328958
    Nov 30, 2021 at 14:20
2

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.