File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -309,6 +309,56 @@ Like with Rust, you can then inspect the output binary:
309
309
wasm-tools component wit ./my-component.wasm
310
310
```
311
311
312
+ ### Guest C#
313
+
314
+ To generate the bindings:
315
+
316
+ ```
317
+ wit-bindgen c-sharp -w command -r native-aot --generate-stub wit/
318
+ ```
319
+
320
+ Now you create a c# project file:
321
+
322
+ ```
323
+ dotnet new console -o MyApp
324
+ cd MyApp
325
+ dotnet new nugetconfig
326
+ ```
327
+
328
+ In the ` nuget.config ` after ` <clear /> ` make sure you have:
329
+
330
+ ```
331
+ <add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
332
+ <add key="nuget" value="https://api.nuget.org/v3/index.json" />
333
+ ```
334
+
335
+ In the MyApp.csproj add the following to the property group:
336
+
337
+ ```
338
+ <RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
339
+ <UseAppHost>false</UseAppHost>
340
+ <PublishTrimmed>true</PublishTrimmed>
341
+ <InvariantGlobalization>true</InvariantGlobalization>
342
+ <SelfContained>true</SelfContained>
343
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
344
+ <WASI_SDK_PATH>path/to/wasi-sdk</WASI_SDK_PATH>
345
+ ```
346
+
347
+ Add the native-aot compiler (substitute ` win-x64 ` for ` linux-x64 ` on Linux):
348
+
349
+ ```
350
+ dotnet add package Microsoft.DotNet.ILCompiler.LLVM --prerelease
351
+ dotnet add package runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM --prerelease
352
+ ```
353
+
354
+ Now you can build with:
355
+
356
+ ```
357
+ dotnet publish
358
+ ```
359
+
360
+ Checkout out [ componentize-dotnet] ( https://github.com/bytecodealliance/componentize-dotnet ) for a simplified experience.
361
+
312
362
### Guest: Java
313
363
314
364
Java bytecode can be compiled to WebAssembly using
You can’t perform that action at this time.
0 commit comments