Using VS2010, I created a Win32 C++ console application called "TfsBuildTestTarget". This is just the default console application created by the wizard. I made no code or project changes, and it builds ok in VS2010 as expected.
Then I created an MSBUILD project file as follows:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Build">
<MSBuild Projects="TfsBuildTestTarget.sln" Targets="TfsBuildTestTarget" Properties="Configuration=Release;Platform=Win32"/>
</Target>
</Project>
When I run MSBUILD on this project file, I get the following error:
"c:\dev\TfsBuildTestTarget\testBuild.proj" (default target) (1 ) -> "c:\dev\TfsBuildTestTarget\TfsBuildTestTarget.sln" (TfsBuildTe stTarget target) (2) -> (TfsBuildTestTarget target) ->
c:\dev\TfsBuildTestTarget\TfsBuildTestTarget\TfsBuildTestTarget.vcxproj(3,14): error MSB4066: The attribute "Label" in element is unrecognized.
The referenced line, in the (VS-generated) vcxproj file looks like this:
<ItemGroup Label="ProjectConfigurations">
The reference for the MSBuild item element does not include a Label attribute.
What is going on here? Why is VS2010 generating project files that do not appear to be compatible with MSBuild? Is there a way for me to build this solution as part of an MSBuild project without manually tweaking the XML?
Make sure you are using the .NET 4.0 version of MSBuild.
If you use the .NET 3.5 version of MSBuild against a VS2010 solution that includes a vcxproj file you will get this error.
I made a c++ console application like you specified and ran it using both .NET 3.5 and .NET 4.0 MSBuild versions. I got the error using 3.5 and it worked using 4.0.
The Label attribute is new in .NET 4.0. It can be added to ItemGroup, PropertyGroup, Target, and other elements. The label attribute is not mentioned in the online help for msbuild but is defined int he msbuild 4.0 schema files.
I was using the "Open Visual Studio Command Prompt (2008)" entry of Start Menu to build, and it gave me the same error, but when I switched to "Open Visual Studio Command Prompt (2010)", I had the problem miracolously solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With