I am trying to display a simple message in my build output window using the Message element and I am not seeing it in any verbosity setting. Please advise. I can see the echo statement.
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
<Deterministic>false</Deterministic>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="echo hello world" />
</Target>
<Target Name="AfterBuild">
<Message Text="Build completed successfully!" Importance="high" />
</Target>
Rebuild started at 11:49 AM...
1>------ Rebuild All started: Project: WpfApp1, Configuration: Debug Any CPU ------
Restored C:\Users\user1\source\repos\PRACTICE\WpfApp1\WpfApp1\WpfApp1.csproj (in 2 ms).
1>WpfApp1 -> C:\Users\user1\source\repos\PRACTICE\WpfApp1\WpfApp1\bin\Debug\net8.0-windows\WpfApp1.dll
1>hello world
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
========== Rebuild completed at 11:49 AM and took 01.408 seconds ==========
There is already an AfterBuild
task so your is getting overridden (only the last defined is used). Also define when you task should be called, so for example after the first one.
So the following should give you the output you want
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="echo hello world" />
</Target>
<Target Name="CustomAfterBuild" AfterTargets="PostBuild">
<Message Text="Build completed successfully!" Importance="high" />
</Target>
...
1>hello world
1>Build completed successfully!
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
========== Rebuild completed at 19:59 and took 00,463 seconds ==========