[release/6.0] [wasm] Require workloads if using `@(NativeFileReference)` (#58290)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Tue, 31 Aug 2021 16:17:55 +0000 (18:17 +0200)
committerGitHub <noreply@github.com>
Tue, 31 Aug 2021 16:17:55 +0000 (18:17 +0200)
commite8aab6ad482a814652bb240493fdb60d69f108f5
tree4155dc8b413291f9839b85257780862aee620d82
parent08b249b2037a62bf7ebc1e3a7b371f724538c298
[release/6.0] [wasm] Require workloads if using `@(NativeFileReference)` (#58290)

* [wasm] Require workloads, if a project is using native references

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`.

* Bump sdk for workload testing to 6.0.100-rc.2.21425.12

* Fix path to workload.stamp file

Co-authored-by: Ankit Jain <radical@gmail.com>
eng/Versions.props
src/libraries/Directory.Build.props
src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets.in
src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs
src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs
src/tests/BuildWasmApps/Wasm.Build.Tests/NativeLibraryTests.cs