Skip to content

[wasi] Improve error message for missing WASI SDK #94671

@RReverser

Description

@RReverser

Description

Trying to build a project targeting wasi-wasm with latest preview results in:

C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk\8.0.0-rc.2.23479.6\Sdk\WasiApp.Native.targets(54,5): error : Could not fin
d wasi-sdk. Either set $(WASI_SDK_PATH), or use workloads to get the sdk. SDK is required for building native files.

Reproduction Steps

Build any project with <RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>, e.g. the default wasi console template while not having WASI SDK installed globally.

Expected behavior

It should provision WASI SDK automatically when installing the wasi-experimental workload. It seems there is some code for this in the repo

runtime/src/mono/mono.proj

Lines 174 to 186 in af0227f

<Target Name="ProvisionWasiSdk"
Condition="'$(ShouldProvisionWasiSdk)' == 'true' and '$(SkipMonoCrossJitConfigure)' != 'true'">
<ReadLinesFromFile File="$(MSBuildThisFileDirectory)/wasi/wasi-sdk-version.txt">
<Output TaskParameter="Lines" ItemName="_VersionLines" />
</ReadLinesFromFile>
<PropertyGroup>
<WasiLocalPath>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi'))</WasiLocalPath>
<WasiSdkVersion>%(_VersionLines.Identity)</WasiSdkVersion>
<WasiSdkUrl>https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-linux.tar.gz</WasiSdkUrl>
<WasiSdkUrl Condition="'$(HostOS)' == 'osx'" >https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-macos.tar.gz</WasiSdkUrl>
<WasiSdkUrl Condition="'$(HostOS)' == 'windows'" >https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0.m-mingw.tar.gz</WasiSdkUrl>
</PropertyGroup>
but I guess it's not hooked up all the way?

Alternatively, at least provide a clear error message on how to retrieve one manually for now.

Actual behavior

The error message says

or use workloads to get the sdk

even though that doesn't seem to be supported.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions