Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Aug 27, 2021

Backport of #58152 to release/6.0

/cc @lewing @radical

When a blazorwasm project has $(RunAOTCompilation)=true, then the wasm-tools workload is marked as required. But this is not done if the project wants to use native libraries, without AOT.

This PR makes the workload a requirement when such native libraries are being used (@(NativeFileReference)). This will cause the build to fail if the workload is not installed.

Fixes #56678 .

Customer Impact

Instead of the native library, silently, not getting linked, and failing at runtime, this fails the build.

Testing

CI. New tests added.

Risk

Low

Currently, if the `wasm-tools` workload is not installed, and a project
uses AOT, then the build fails with an error saying that the workload
is needed.

But if the project is using native references, but not AOT, then the
build does not fail. Instead, the `@(NativeFileReference)` just gets
ignored. Even though the wasm workload is needed to relink dotnet.wasm
with the native libraries.

Implementation:

- `$(RunAOTCompilation)` is a property, so it can be checked, and
  wasm workload imports can be enabled.
- But `@(NativeFileReference)` is an item, and that gets evaluated in
  the second phase, so we can't use that to affect the imports.
  - Instead, we emit a warning from a target run before Build, if the
    project has any native references, but the workload isn't enabled.

- Users can explicitly enable the workload by setting
  `$(WasmBuildNative)==true`.
@github-actions github-actions bot requested a review from marek-safar as a code owner August 27, 2021 20:42
@ghost
Copy link

ghost commented Aug 27, 2021

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@marek-safar marek-safar merged commit e8aab6a into release/6.0 Aug 31, 2021
@lewing lewing deleted the backport/pr-58152-to-release/6.0 branch August 31, 2021 18:06
@ghost ghost locked as resolved and limited conversation to collaborators Sep 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants