Skip to content
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

State of WASM/WASI support in Net 9 #113858

Open
jogibear9988 opened this issue Mar 24, 2025 · 4 comments
Open

State of WASM/WASI support in Net 9 #113858

jogibear9988 opened this issue Mar 24, 2025 · 4 comments
Assignees
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration os-browser Browser variant of arch-wasm question Answer questions and provide assistance, not an issue with source code or documentation.

Comments

@jogibear9988
Copy link

I've a C# Library I want to consume from a Javascript App (no Blazor).
I now tried to find, how to compile to WASM/WASI with Net 9, but I only find outdated Tutorials wich do not work.

Whats the state of support? Are the samples?

found:
https://devblogs.microsoft.com/dotnet/use-net-7-from-any-javascript-app-in-net-7/
https://github.com/dotnet/dotnet-wasi-sdk
https://devblogs.microsoft.com/dotnet/extending-web-assembly-to-the-cloud/

but everything is old and does not seem to work.

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Mar 24, 2025
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Mar 24, 2025
@jeffschwMSFT jeffschwMSFT added os-wasi Related to WASI variant of arch-wasm arch-wasm WebAssembly architecture area-VM-meta-mono labels Mar 25, 2025
@jkotas jkotas removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Mar 25, 2025
@maraf
Copy link
Member

maraf commented Mar 27, 2025

@jogibear9988 Thank you reaching out!

There is a tutorial https://learn.microsoft.com/en-us/aspnet/core/client-side/dotnet-interop?view=aspnetcore-9.0.
The key starting point is to install wasm-experimental workload and then you can use wasmbrowser template.

There is one app in the runtime repository then we use for testing https://github.com/dotnet/runtime/tree/main/src/mono/wasm/testassets/WasmBasicTestApp/App. You can try to find others on github then are the same template (SDK in fact) https://github.com/search?q=Sdk%3D%22Microsoft.NET.Sdk.WebAssembly%22&type=code.

Let us know if you more questions.

@maraf maraf added needs-author-action An issue or pull request that requires more info or actions from the author. os-browser Browser variant of arch-wasm and removed untriaged New issue has not been triaged by the area owner os-wasi Related to WASI variant of arch-wasm labels Mar 27, 2025
@maraf maraf self-assigned this Mar 27, 2025
@maraf maraf added the question Answer questions and provide assistance, not an issue with source code or documentation. label Mar 27, 2025
@jogibear9988
Copy link
Author

I try to compile my project:

        <Project Sdk="Microsoft.NET.Sdk">
        
          <PropertyGroup>
            <OutputType>Library</OutputType>
            <TargetFramework>net9.0</TargetFramework>
            <RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
            <ImplicitUsings>enable</ImplicitUsings>
            <Nullable>enable</Nullable>
            <RollForward>LatestMajor</RollForward>
            <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
          </PropertyGroup>
        
          <ItemGroup>
            <ProjectReference Include="..\TiaFileFormat\TiaFileFormat.csproj" />
          </ItemGroup>
        
        </Project>

I always get this error:

          2>C:\Program Files\dotnet\sdk\9.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: wasm-tools
          2>C:\Program Files\dotnet\sdk\9.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload restore

but the workload is installed:

Image

@dotnet-policy-service dotnet-policy-service bot added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed needs-author-action An issue or pull request that requires more info or actions from the author. labels Mar 27, 2025
@maraf
Copy link
Member

maraf commented Mar 27, 2025

What does dotnet workload list print for you?

Also I would encourage you to migrate to Microsoft.NET.Sdk.WebAssembly (see the wasmbrowser template in .NET9+)

@maraf maraf added the needs-author-action An issue or pull request that requires more info or actions from the author. label Mar 27, 2025
@jogibear9988
Copy link
Author

After changeing Sdk Type to Microsoft.NET.Sdk.WebAssembly it compiles...
Now I need to check WASM calls... I'll report back

@dotnet-policy-service dotnet-policy-service bot removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Mar 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration os-browser Browser variant of arch-wasm question Answer questions and provide assistance, not an issue with source code or documentation.
Projects
None yet
Development

No branches or pull requests

4 participants