使用VS2010生成的vcxproj文件作为目标的MSBuild-错误MSB4066(“无法识别元素中的属性标签") [英] using MSBuild with VS2010-generated vcxproj file as target -- error MSB4066 ("attribute Label in element is unrecognized")

查看:713
本文介绍了使用VS2010生成的vcxproj文件作为目标的MSBuild-错误MSB4066(“无法识别元素中的属性标签")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用VS2010,我创建了一个名为"TfsBuildTestTarget"的Win32 C ++控制台应用程序.这只是向导创建的默认控制台应用程序.我没有进行任何代码或项目更改,并且按预期在VS2010中可以正常构建.

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.

然后我创建了一个MSBUILD项目文件,如下所示:

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>

在此项目文件上运行MSBUILD时,出现以下错误:

When I run MSBUILD on this project file, I get the following error:

"c:\ dev \ TfsBuildTestTarget \ testBuild.proj" (默认目标)(1)-> "c:\ dev \ TfsBuildTestTarget \ TfsBuildTestTarget.sln" (TfsBuildTe stTarget目标)(2)-> (TfsBuildTestTarget目标)->
c:\ dev \ TfsBuildTestTarget \ TfsBuildTestTarget \ TfsBuildTestTarget.vcxproj(3,14): 错误MSB4066:无法识别元素中的属性标签".

"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.

(VS生成的)vcxproj文件中的引用行如下所示:

The referenced line, in the (VS-generated) vcxproj file looks like this:

  <ItemGroup Label="ProjectConfigurations">

MSBuild项目元素的引用不包含标签属性.

The reference for the MSBuild item element does not include a Label attribute.

这是怎么回事?为什么VS2010生成似乎与MSBuild不兼容的项目文件?我有没有办法在不手动调整XML的情况下将该解决方案作为MSBuild项目的一部分来构建?

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?

推荐答案

请确保您使用的是.NET 4.0版本的MSBuild.

Make sure you are using the .NET 4.0 version of MSBuild.

如果针对包含vcxproj文件的VS2010解决方案使用MSBuild的.NET 3.5版本,则会出现此错误.

If you use the .NET 3.5 version of MSBuild against a VS2010 solution that includes a vcxproj file you will get this error.

我制作了一个像您指定的c ++控制台应用程序,并使用.NET 3.5和.NET 4.0 MSBuild版本运行了该应用程序.使用3.5时出现错误,使用4.0时出现错误.

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.

.NET 4.0中的Label属性是新的.可以将其添加到ItemGroup,PropertyGroup,Target和其他元素. msbuild的联机帮助中未提及label属性,但在msbuild 4.0架构文件中定义了label属性.

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.

这篇关于使用VS2010生成的vcxproj文件作为目标的MSBuild-错误MSB4066(“无法识别元素中的属性标签")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆