Getting Rid of the Bogus Warnings in MSBuild Projects

Filed under MSBuild, Troubleshooting

If you’ve ever loaded up an MSBuild project in VS, you have likely seen some warning messages in the Error List window, essentially saying that either the first item in a custom ItemGroup is invalid or the first Property in a custom PropertyGroup is invalid.

The problem is that the MSBuild designers wanted to provide a schema to you’d get some nice intellisense functions when editing a proj file, but, they had to allow for custom properties and items because, well, that’s what MSBuild is all about, after all!

So, those custom elements by definition, can’t be included in the generic schema and, bingo, validation warnings.

The warnings don’t actually harm anything and MSBuild effectively ignores them, so one solution is to do just that. Ignore all those new warnings in your Errors window. That’s even what MS recommends <sigh>

For me, though, ANYTHING in that errors window is a red flag.

Getting that Nice, Clean Errors Window

After digging around, it turns out there’s essentially 2 options to get rid of those warnings.

  1. Edit the Microsoft.Build.xsd file and include ALL the custom Property and Item names you might be using
  2. Or tell VS to not validate the proj file against any schema.

I can’t imagine bothering to try to keep that xsd file up to date constantly as I change proj files, so that option was out.

Fortunately, telling VS not to validate the project file is relatively easy, and pretty easy to undo as well.

First, open the proj file in Visual Studio (if it’s an actual VBPROJ or CSPROJ file, you’ll need to unload the project first, then right click on it again and select Edit Project).

Click in the project editing window, then in the Properties box, Click on the Ellipse button to change the schemas property.

image

You should see this (though, the red Xs will be green checks):

image

When you get the dialog showing all the schemas against which the file is validated, select each one and choose “Do not use this schema”

image

Click ok and repeat for any other PROJ files you need to handle this way.

When done, you should no longer see any validation warnings in the error window.

Unfortunately, this also means that the proj file won’t be pre-validated at all anymore and you won’t get any intellisense anymore. But, really, once you’ve got your proj file setup, you shouldn’t be needing to edit it much.

And if you really need to, just reverse the above process to turn the schema validation back on.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*