您可以使用消息任务
示例:在项目的顶部,将 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