right, well its not foolproof, but you could do something like this
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Default" DependsOnTargets="SetVariables;SetPublishTargetInvokedFlag"/>
<Target Name="SetVariables">
<PropertyGroup>
<InFile>true</InFile>
</PropertyGroup>
</Target>
<Target Name="SetPublishTargetInvokedFlag" Condition="$(InFile) == 'true'">
<Message Text="Hello from SetPublishTargetInvokedFlag"/>
</Target>
</Project>
if you run msbuild YOURFILE.proj /t:SetPublishTargetInvokedFlag from the command line, the target will not execute. But you can easily change that to msbuild YOURFILE.proj /t:SetPublishTargetInvokedFlag /p:InFile=true and it will run!
Note i used DependsOnTargets rather than CallTarget as there is a
'Feature' in CallTarget