The common targets convention is to generate all source inputs to the compiler before BeforeCompile target. Targets that fail to do so break Source Link (see https://github.com/dotnet/sourcelink/issues/572).