In case execution of pre-build events for IdP and SP overlap, compilation may intermittently fail. Failure is caused by parallel execution of appcmd processes. Execution of appcmd in IdP races execution of appcmd in SP, leading to "file applicationhost.config locked by other process" compilation error.
In principle, I don't believe there's a need for pre-build events. appcmd setup is only needed once. I suppose the pre-build events were added in order to avoid additional manual steps about first opening the solution in Visual Studio (triggering .vs folder creation), then executing appcmd.
In case execution of pre-build events for IdP and SP overlap, compilation may intermittently fail. Failure is caused by parallel execution of appcmd processes. Execution of appcmd in IdP races execution of appcmd in SP, leading to "file applicationhost.config locked by other process" compilation error.
In principle, I don't believe there's a need for pre-build events. appcmd setup is only needed once. I suppose the pre-build events were added in order to avoid additional manual steps about first opening the solution in Visual Studio (triggering .vs folder creation), then executing appcmd.