2013-03-29 35 views
1

问题:使用msbuild编辑.props文件失败。我想看看操作的中间结果是如何处理某些输出消息的。 “不被支持”是IDE告诉我的。用于C++的MSBuild消息

示例: 我想获取配置名称的最后四个字符以使用字符串的一部分。

<ImportGroup Label="PropertySheets"> 
     <Import project=".\prop_$(Configuration.Substring($([MSBuild]::Subtract($(Configuration.Length),4)))).props" />  
    </ImportGroup> 

我怎么能看到的部分,长度,减,则子的结果?我希望能够在处理过程中打印出这些值。

回答

2

可以使用Message Task

例如: 在项目组InitialTargets顶到目标

<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="DisplayText"> 

<Target Name="DisplayText"> 
    <Message Importance="high" Text="Configuration = $(Configuration)" /> 
    <Message Importance="high" Text="Configuration Length = $(Configuration.Length)" /> 
    <Message Importance="high" Text="Configuration Substring = $(Configuration.Substring($([MSBuild]::Subtract($(Configuration.Length),4))))" /> 
</Target> 

的应打印出你在生成过程中询问了一切名称。

1>------ Build started: Project: TemplateTest, Configuration: Debug Win32 ------ 
1> Configuration = Debug 
1> Configuration Length = 5 
1> Configuration Substring = ebug 
+0

这在IDE中不起作用,它似乎在C++版本中不起作用。在vcxproj中,哪里不会导致消息框弹出来说明它不被支持?输出显示在哪里? –

+0

@BenL请看看编辑后的答案,它为我工作假设'文本'根据您的配置正确设置 –

+0

真棒。那很完美。 –