After several hours of fighting, I think I came up with really simple and universal solution. None of solutions I found were working for me ('Publish' target is for ClickOnce only), so I came up with this:
Publish file (pubxml) is just project-like file. So add some value, for example:
<IsPublish>True</IsPublish>
and then in project file:
<Target Name="MessageBeforePublish" AfterTargets="Build" Condition="'$(IsPublish)' == 'True'">
<Message Text="Before publishing..." Importance="high" />
</Target>
So, to be clear, my pubxml file looks like that:
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<PublishDir>***my dir***</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>True</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
<IsPublish>True</IsPublish>
</PropertyGroup>
</Project>
Notice the last property (IsPublish) added by me.
That's it.