Skip to content

Commit 820764e

Browse files
authored
Merge pull request #74 from jsturtevant/update-install-docs
Update docs to use the template to get started
2 parents f49b4e5 + e1207e0 commit 820764e

File tree

3 files changed

+54
-45
lines changed

3 files changed

+54
-45
lines changed

README.md

+52-43
Original file line numberDiff line numberDiff line change
@@ -26,58 +26,24 @@ With this package, you can add one NuGet reference. The build output is fully AO
2626

2727
If you don't already have it, install [.NET 9+ SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)
2828

29-
### 2. Create a project and add BytecodeAlliance.Componentize.DotNet.Wasm.SDK package
29+
### 2. Install template and build
3030

31-
* `dotnet new console -o MyApp`
32-
* `cd MyApp`
33-
34-
Create a `nuget.config` file and add the `dotnet-experimental` package source for the `NativeAOT-LLVM` dependency:
35-
36-
* `dotnet new nugetconfig`
37-
* Add these keys to `nuget.config` after `<clear />`:
38-
39-
```xml
40-
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
41-
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
42-
```
43-
44-
Add the `componentize-dotnet` package:
45-
46-
`dotnet add package BytecodeAlliance.Componentize.DotNet.Wasm.SDK --prerelease`
47-
48-
Add the platform specific LLVM package:
49-
50-
```
51-
## On Linux
52-
dotnet add package runtime.linux-x64.microsoft.dotnet.ilcompiler.llvm --prerelease
53-
54-
## or
55-
56-
## On Windows
57-
dotnet add package runtime.win-x64.microsoft.dotnet.ilcompiler.llvm --prerelease
58-
```
59-
60-
Edit the `.csproj` file, adding the following inside the `<PropertyGroup>`:
61-
62-
```
63-
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
64-
<UseAppHost>false</UseAppHost>
65-
<PublishTrimmed>true</PublishTrimmed>
66-
<InvariantGlobalization>true</InvariantGlobalization>
67-
<SelfContained>true</SelfContained>
31+
```bash
32+
dotnet new install BytecodeAlliance.Componentize.DotNet.Templates
33+
dotnet new componentize.wasi.cli -o MyApp
34+
dotnet build MyApp
6835
```
6936

70-
Now you can `dotnet build` to produce a `.wasm` file using NativeAOT compilation.
71-
72-
### 4. Run the WebAssembly binary
37+
### 3. Run the WebAssembly binary
7338

7439
If you have a recent version of [wasmtime](https://github.com/bytecodealliance/wasmtime/releases) on your path, you can now run
7540

7641
```bash
77-
wasmtime bin\Debug\net8.0\wasi-wasm\native\MyApp.wasm
42+
wasmtime ./MyApp/bin/Debug/net9.0/wasi-wasm/publish/MyApp.wasm
43+
Hello world from compontize-dotnet!
7844
```
7945

80-
(if needed, replace `MyApp.wasm` with the actual name of your project)
46+
(if needed, replace `MyApp` with the actual name of your project)
8147

8248
## Creating a WASI 0.2 component, including WIT support
8349
Lastest version of NativeAOT compiler package and the mono support in dotnet 9-preview 7 build native wasi 0.2 components with no additional tools.
@@ -285,6 +251,49 @@ The calculator example above works easily because it doesn't need to allocate me
285251

286252
If you get a build error along the lines of _failed to encode a component from module ... module does not export a function named `cabi_realloc`_ then check you have remembered to add this line.
287253

254+
### Create a project manually
255+
256+
* `dotnet new console -o MyApp`
257+
* `cd MyApp`
258+
259+
Create a `nuget.config` file and add the `dotnet-experimental` package source for the `NativeAOT-LLVM` dependency:
260+
261+
* `dotnet new nugetconfig`
262+
* Add these keys to `nuget.config` after `<clear />`:
263+
264+
```xml
265+
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
266+
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
267+
```
268+
269+
Add the `componentize-dotnet` package:
270+
271+
`dotnet add package BytecodeAlliance.Componentize.DotNet.Wasm.SDK --prerelease`
272+
273+
Add the platform specific LLVM package:
274+
275+
```
276+
## On Linux
277+
dotnet add package runtime.linux-x64.microsoft.dotnet.ilcompiler.llvm --prerelease
278+
279+
## or
280+
281+
## On Windows
282+
dotnet add package runtime.win-x64.microsoft.dotnet.ilcompiler.llvm --prerelease
283+
```
284+
285+
Edit the `.csproj` file, adding the following inside the `<PropertyGroup>`:
286+
287+
```
288+
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
289+
<UseAppHost>false</UseAppHost>
290+
<PublishTrimmed>true</PublishTrimmed>
291+
<InvariantGlobalization>true</InvariantGlobalization>
292+
<SelfContained>true</SelfContained>
293+
```
294+
295+
Now you can `dotnet build` to produce a `.wasm` file using NativeAOT compilation.
296+
288297
### Troubleshooting
289298

290299
#### Imports Wrong Type

templates/content/wasi-cli/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// See https://aka.ms/new-console-template for more information
2-
Console.WriteLine("Hello, world from compontize-dotnet!");
2+
Console.WriteLine("Hello world from compontize-dotnet!");

templates/content/wasi-cli/wasi-cli.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="BytecodeAlliance.Componentize.DotNet.Wasm.SDK" Version="0.5.0-preview00008" />
17+
<PackageReference Include="BytecodeAlliance.Componentize.DotNet.Wasm.SDK" Version="0.6.0-preview00009" />
1818
<PackageReference Condition="'$(platform)' == 'Windows_NT'" Include="runtime.win-x64.microsoft.dotnet.ilcompiler.llvm" Version="10.0.0-alpha.1.25118.1" />
1919
<PackageReference Condition="'$(platform)' == 'linux'" Include="runtime.linux-x64.microsoft.dotnet.ilcompiler.llvm" Version="10.0.0-alpha.1.25118.1" />
2020
</ItemGroup>

0 commit comments

Comments
 (0)