-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wasm] No deterministic way to produce additional outputs for both building and publishing a WASM project #94576
Comments
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsIssue detailsI have a console WASM project set up, with my main file written in typescript. For a better user experience, I created a custom target that ran after WasmBuildApp, to run the TypeScript compiler and copy the built files to the AppBundle directory. <Target Name="_TypeScriptCompileAferBuild" AfterTargets="WasmBuildApp">
<Exec Command="tsc -p ./tsconfig.json -outDir $(WasmAppDir)"></Exec>
</Target> In the above case, However this poses a problem when publishing. When a WASM project is published, there is a step that copies a bunch of files to the AppBundle directory. This step removes files that currently exist in the AppBundle directory. So, the published output for the project is now missing the files compiled in an earlier target. And I can't just use the WasmNestedPublishApp target <Target Name="_TypeScriptCompileAferBuild" AfterTargets="WasmNestedPublishApp">
<Exec Command="tsc -p ./tsconfig.json -outDir $(WasmAppDir)"></Exec>
</Target> As this does not run during a normal build! Is there a target I can use that runs during build and after the bundle generation step, but does not run twice? Workarounds
<Target Name="_TypeScriptCompileAferBuild" AfterTargets="WasmBuildApp;WasmNestedPublishApp">
<Exec Command="tsc -p ./tsconfig.json -outDir $(WasmAppDir)"></Exec>
</Target>
|
What step is that? Can you share binlog of a build where this happens? I would have suggested using One solution would be to allow using these two |
I have a basic reproduction here: https://github.com/JakeYallop/WasmBuildRepro - this is just the WASM console template with some targets added. You can see the target set to run after Additionally, testfile.txt does not exist in the AppBundle directly after doing a publish, when the bundle is actually generated.
Its the binlogs are zipped to allow sharing to github - just unzip them to access them. binlog where testfile.txt does not exist in the AppBundle directory: binlog for the situation spoken about above, where the |
@JakeYallop, let me summarize @radical's answer into code:
Build:
Publish:
|
Its been a while since I last looked at this project, but I believe my original issue still stands. My real issue requires all the files that are created after the build or bundle generation steps to already exist in In the example code you've provided, I don't think the files created by bundle generation (or the build) will be present inside I might revisit this project to get it working on .NET 9 once the WASM console templates have moved to the SDK, but at least for now its not something I'm looking at revisiting any time soon. |
The |
Issue details
I have a console WASM project set up, with my main file written in typescript. For a better user experience, I created a custom target that ran after WasmBuildApp, to run the TypeScript compiler and copy the built files to the AppBundle directory.
In the above case,
$(WasmAppDir)
resolves to "bin/{Configuration}/net8.0/browser-wasm/AppBundle".However this poses a problem when publishing. When a WASM project is published, there is a step that copies a bunch of files to the AppBundle directory. This step removes files that currently exist in the AppBundle directory. So, the published output for the project is now missing the files compiled in an earlier target.
And I can't just use the WasmNestedPublishApp target
As this does not run during a normal build!
Is there a target I can use that runs during build and after the bundle generation step, but does not run twice?
Workarounds
$(_IsPublishing)
and do something with that to dynamically configure when the target runs (its not something I've tried, so not 100% sure if this is possible). Again not ideal, as apparently$(_IsPublishing)
is not set during a Visual Studio publish, and apparently detecting publish is not something we are meant to do - How to check if the current invocation is runningpublish
? sdk#26324_WasmGenerateAppBundle
is not run and files are preserved, meaning there is sometimes no need to rerun the target. This is still not ideal, as in most cases the target is still going to need to be executed twice.The text was updated successfully, but these errors were encountered: