Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Why is my pre-publish PowerShell script executed twice?

$
0
0

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:

  1. Initialize build process.
  2. Run script.
  3. "Optimizing assemblies for size. This process might take a while."
  4. Run script again (not wanted).
  5. brotli some files
  6. 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?

Edit

In my log file, I found the target `_GatherBlazorFilesToPublish` and used it as `BeforeTargets="_GatherBlazorFilesToPublish">`. This works and now my script is executed only once, but to be honest, I have no idea what I am doing. Is it okay to use this target?

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>