Missing element according to the MSBuild XML schema?
-
Wednesday, December 12, 2007 5:14 PMI am trying to create a new .targets file that I want to share over mulitple projects as described in this blogpost:
Here is how my .targets looks:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
PropertyGroup><
CodeAnalysisRules>-Microsoft.Design#CA2210</CodeAnalysisRules><
<
RunCodeAnalysis>true</RunCodeAnalysis></
PropertyGroup></
Project>I get the following warning in Visual Studio 2008:
Warning 1 The element 'Project' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003' has incomplete content. List of possible elements expected: 'PropertyGroup, ItemGroup, ItemDefinitionGroup, Choose, UsingTask, ProjectExtensions, Target, Import' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003'. D:\Projects\ProjectX\CodeAnalysis\TeamA.CodeAnalysis.Rules.targets 6 3 Miscellaneous Files
So what exactly is missing here?
All Replies
-
Wednesday, December 12, 2007 5:41 PMModerator
You've got the correct format - the warning appears to be a bug in the MSBuild schema - I've filed a bug internally to track this.
Regards
David
-
Wednesday, December 12, 2007 5:56 PMSo as a workaround I could change the XML schema definition?
-
Wednesday, December 12, 2007 6:16 PMModerator
You could, but I wouldn't advise it due to servicing issues (ie when a future Service Pack is installed). There is no workaround needed as such, MSBuild will happily allow you to import the project from another project without complaining.
-
Thursday, December 13, 2007 9:20 AMSo how exactly can I work around this? Should I add specific empty elements to work around this?
-
Thursday, December 13, 2007 4:52 PMModeratorThe workaround is to simply ignore the warning for now. MSBuild should still be able to read your file just fine. Is something actually not working?
-
Thursday, December 13, 2007 5:24 PM
Well at first when I looked in the properties of the project in the code analysis tab the "rules enabled" did not reflect the .targets file and I thought that this was related but after recreating the .targets and changing the project files this appears to be solved. So you are right I could ignore the warning.
Maybe another question and I don't know if I should create a new thread for this but is it possible to make the Code Analysis tab read only?
-
Thursday, December 13, 2007 5:37 PMModerator
You can't make the tab read only however if you import your targets file at the bottom of your project, the settings you import from your targets file will override anything you already specified in your project. So while you can't make it read only you can make it so that changing stuff in the tab does nothing.
-Todd
-
Thursday, December 13, 2007 5:41 PMYou are right, it really does not matter what the devs select. Well it works like a charm now. The next step is
programmatically adding the <import> element pointing to the .targets file in our more than 100 projects for a large project. And after that creating a shared Code Analysis Dictionary.

