There is an *.csproj example of how to run Powershell script in BeforePrebuild state:
<Project Sdk="Microsoft.NET.Sdk"> ... <Target Name="PreBuildCustomCommand" BeforeTargets="BeforeRebuild" Condition="'$(Configuration)'=='Debug'"> <Exec Command="powershell.exe -command "& {.\MyScript.ps1 '$(SolutionDir)'}"" /> </Target> ... </Project>
Target - targets are used to divide build process into smaller units (more about targets)
Name - the name of the defined target
BeforeTragets - before which target run this target. There are other possibilities for how order targets run (like AfterTargets and others).
AfterTragets - after which target run this target
Exec - Exec task is one of the predefined MSBuild Tasks to run a program or command. (How to write own MSBuild Task)
If you would like to know more about MSBuild you can read about MSBuild concepts.