I work on a Blazor Wasm PWA with AOT. I created a PowerShell script, that I want to execute before the publish build. So, I added
<Target Name="PrePublishScript" BeforeTargets="PrepareForPublish">
<Exec Command="powershell -ExecutionPolicy Bypass -File script.ps1" />
</Target>
in the project file. This code works, but my script is executed twice:
- Initialize build process.
- Run script.
- "Optimizing assemblies for size. This process might take a while."
- Run script again (not wanted).
- brotli some files
- AOTing
I created a log file via msbuild WRCT.csproj /t:Publish /p:Configuration=Release /v:diag > build.log. Its content contains PrepareForPublish twice. Could this be the reason for the doubled execution?
_CorePublishTargets =
PrepareForPublish;
ComputeAndCopyFilesToPublishDirectory;
;
PublishItemsOutputGroup;
and
_PublishNoBuildAlternativeDependsOn =
BuildOnlySettings;
_PreventProjectReferencesFromBuilding;
ResolveReferences;
PrepareResourceNames;
ComputeIntermediateSatelliteAssemblies;
ComputeEmbeddedApphostPaths;
;
PrepareForPublish;
ComputeAndCopyFilesToPublishDirectory;
;
PublishItemsOutputGroup;
Maybe, I could find a BeforeTargets="Whatever" in the log file, but its size is 315 Mb...
How can I avoid, executing the script twice?
Or is there is a other way for executing the script automatically before the publish build?