Skip to content

Commit b2bacf2

Browse files
committed
Hook frontend build earlier in the publish chain
Per Copilot review on PR #740: BeforeTargets="Publish" runs after the Publish target's dependencies, so file enumeration and copy already saw a stale dist/ before our pnpm build ran. Switch to two earlier hooks: - Inject BuildFrontendForPublish into PublishDependsOn so it's the first dep of Publish (idiomatic .NET SDK pattern). - BeforeTargets="PrepareForPublish;ComputeFilesToPublish" as a backstop in case the JS SDK invokes those outside the PublishDependsOn flow. Both fire before any publish-time file collection, ensuring dist/ is fresh when the SDK packages the StaticHost.
1 parent ebab926 commit b2bacf2

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/frontend/frontend.esproj

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,20 @@
1212

1313
<!-- Ensure dist/ is freshly produced (and .twoslash-types/aspire.d.ts generated)
1414
whenever this project is published. The JS SDK's BuildCommand is gated off above,
15-
so without this target a `dotnet publish` would package a stale or missing dist. -->
16-
<Target Name="BuildFrontendForPublish" BeforeTargets="Publish">
15+
so without this hook a `dotnet publish` would package a stale or missing dist.
16+
17+
Hook BEFORE the publish dependency chain runs:
18+
- Inject into PublishDependsOn so we're the first dep of `Publish` itself.
19+
- Belt-and-suspenders BeforeTargets on the early standard publish-chain targets
20+
(PrepareForPublish / ComputeFilesToPublish), in case the JS SDK invokes those
21+
outside the PublishDependsOn flow.
22+
Hooking on `Publish` directly is too late — by then file enumeration and copy
23+
have already collected the stale `dist/`. -->
24+
<PropertyGroup>
25+
<PublishDependsOn>BuildFrontendForPublish;$(PublishDependsOn)</PublishDependsOn>
26+
</PropertyGroup>
27+
28+
<Target Name="BuildFrontendForPublish" BeforeTargets="PrepareForPublish;ComputeFilesToPublish">
1729
<Message Importance="high" Text="frontend.esproj: running 'pnpm install --frozen-lockfile' before publish" />
1830
<Exec Command="pnpm install --frozen-lockfile" WorkingDirectory="$(MSBuildProjectDirectory)" />
1931
<Message Importance="high" Text="frontend.esproj: running 'pnpm run build' before publish" />

0 commit comments

Comments
 (0)