Skip to content

Update readme to support Linux #59

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

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: Build on ${{ matrix.os }} with Dotnet ${{ matrix.dotnet }}
strategy:
matrix:
dotnet: [ '8.x', '9.0.100-rc.1.24452.12']
dotnet: [ '9.x']
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
Expand All @@ -42,5 +42,5 @@ jobs:
name: nuget-packages
path: artifacts/*.nupkg
if-no-files-found: error
if: ${{ matrix.dotnet == '8.x' && matrix.os == 'windows-latest' }}
if: ${{ matrix.dotnet == '9.x' && matrix.os == 'windows-latest' }}

10 changes: 5 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
</PropertyGroup>
<ItemGroup>
<!-- find latest versions at https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-experimental by name of package -->
<PackageVersion Include="Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-alpha.1.24525.6" />
<PackageVersion Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-alpha.1.24525.6" />
<PackageVersion Include="Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-alpha.1.24573.1" />
<PackageVersion Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-alpha.1.24573.1" />

<!-- Tests -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup>
</Project>
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ With this package, you can add one NuGet reference. The build output is fully AO

### 1. Set up SDKs

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

### 2. Create a project and add BytecodeAlliance.Componentize.DotNet.Wasm.SDK package

Expand All @@ -43,21 +43,21 @@ Create a `nuget.config` file and add the `dotnet-experimental` package source fo

Add the `componentize-dotnet` package:

* `dotnet add package BytecodeAlliance.Componentize.DotNet.Wasm.SDK --prerelease`
`dotnet add package BytecodeAlliance.Componentize.DotNet.Wasm.SDK --prerelease`

### 3. Configure the compilation output
Add the platform specific LLVM package:

Edit the `.csproj` file, adding the following inside the `<PropertyGroup>`:
```
## On Linux
dotnet add package runtime.linux-x64.microsoft.dotnet.ilcompiler.llvm --version 10.0.0-alpha.1.24573.1 --prerelease

```xml
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
<UseAppHost>false</UseAppHost>
<PublishTrimmed>true</PublishTrimmed>
<InvariantGlobalization>true</InvariantGlobalization>
<SelfContained>true</SelfContained>
## or

## On Windows
dotnet add package runtime.windows-x64.microsoft.dotnet.ilcompiler.llvm --version 10.0.0-alpha.1.24573.1 --prerelease
```

Now you can `dotnet build` to produce a `.wasm` file using NativeAOT compilation.
Now you can `dotnet publish` to produce a `.wasm` file using NativeAOT compilation.

### 4. Run the WebAssembly binary

Expand Down
4 changes: 2 additions & 2 deletions samples/calculator/Adder/Adder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<InvariantGlobalization>true</InvariantGlobalization>
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>

<!-- Need kebab case -->
Expand All @@ -18,6 +17,7 @@

<ItemGroup>
<ProjectReference Include="..\..\..\src\WasmComponent.Sdk\WasmComponent.Sdk.csproj" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
<!-- and express a dependency on the two implementation components. -->

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Adder\Adder.csproj" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\CalculatorHost\CalculatorHost.csproj" ReferenceOutputAssembly="false" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM"/>
</ItemGroup>

<Target Name="ComposeWasmComponent" AfterTargets="AfterBuild">
Expand Down
5 changes: 2 additions & 3 deletions samples/calculator/CalculatorHost/CalculatorHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<InvariantGlobalization>true</InvariantGlobalization>
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
<IlcExportUnmanagedEntrypoints>true</IlcExportUnmanagedEntrypoints>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\WasmComponent.Sdk\WasmComponent.Sdk.csproj" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM"/>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/WasmComponent.Sdk/WasmComponent.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageTags>webassembly, .net, wasm</PackageTags>
<PackageReleaseNotes>https://github.com/bytecodealliance/componentize-dotnet/releases/tag/$(PackageVersion)</PackageReleaseNotes>

<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<Project>
<PropertyGroup>
<PublishTrimmed>true</PublishTrimmed>
<UseAppHost>false</UseAppHost>
<MSBuildEnableWorkloadResolver>false</MSBuildEnableWorkloadResolver>

<!-- Set these by default -->
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
<UseAppHost>false</UseAppHost>
<PublishTrimmed>true</PublishTrimmed>
<InvariantGlobalization>true</InvariantGlobalization>
<SelfContained>true</SelfContained>

<WasmToolsTarget Condition="$([MSBuild]::IsOSPlatform('Windows'))">win</WasmToolsTarget>
<WasmToolsTarget Condition="$([MSBuild]::IsOSPlatform('Linux'))">linux</WasmToolsTarget>
<WasmToolsTarget Condition="$([MSBuild]::IsOSPlatform('OSX'))">osx</WasmToolsTarget>
Expand All @@ -14,6 +19,5 @@

<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" PrivateAssets="None" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM" PrivateAssets="None" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/WitBindgen/WitBindgen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageTags>webassembly, .net, wasm</PackageTags>
<PackageReleaseNotes>https://github.com/bytecodealliance/componentize-dotnet/releases/tag/$(PackageVersion)</PackageReleaseNotes>

<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
Expand Down
3 changes: 2 additions & 1 deletion test/E2ETest/PackageTest/PackageTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\WasmtimeCliFetcher\FetchWasmtime.targets" />

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -28,6 +28,7 @@

<!-- To ensure we don't build this until we've built the underlying packages -->
<ProjectReference Include="..\..\..\src\WasmComponent.Sdk\WasmComponent.Sdk.csproj" ReferenceOutputAssembly="false" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM"/>
</ItemGroup>

<!-- The next targets (+ nuget.config in folder above) ensures we have the latest nuget packages for the e2e test since there is no great way to force a project to use a particular nuget pacakage -->
Expand Down
3 changes: 2 additions & 1 deletion test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
Expand All @@ -18,6 +18,7 @@

<ItemGroup>
<PackageReference Include="BytecodeAlliance.Componentize.DotNet.Wasm.SDK" Version="$(PackageVersion)" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-alpha.1.24573.1"/>

<!-- Just to ensure build order -->
<ProjectReference Include="..\E2EProducer\E2EProducer.csproj" ReferenceOutputAssembly="false" />
Expand Down
3 changes: 2 additions & 1 deletion test/E2ETest/testapps/E2EProducer/E2EProducer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- This project can't be included in the solution because its package reference can't be satisfied except when running under test -->

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
Expand All @@ -16,6 +16,7 @@

<ItemGroup>
<PackageReference Include="BytecodeAlliance.Componentize.DotNet.Wasm.SDK" Version="$(PackageVersion)" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-alpha.1.24573.1"/>
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions test/E2ETest/testapps/nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
<configuration>
<packageSources>
<add key="dev" value="../PackageTest/packages" />
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="dev">
<package pattern="BytecodeAlliance.Componentize.DotNet.WitBindgen" />
<package pattern="BytecodeAlliance.Componentize.DotNet.Wasm.SDK" />
</packageSource>
<packageSource key="dotnet-experimental">
<package pattern="runtime.*" />
</packageSource>
</packageSourceMapping>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
<Import Project="..\..\..\src\WasmComponent.Sdk\ImportInDev.proj" />

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- clear the defaulted values from sdk-->
<SelfContained>false</SelfContained>
<PublishTrimmed>false</PublishTrimmed>
<RuntimeIdentifier></RuntimeIdentifier>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
Expand All @@ -30,6 +33,7 @@
<ProjectReference Include="..\testapps\SimpleConsumer\SimpleConsumer.csproj" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\testapps\AppWithWitFolder\AppWithWitFolder.csproj" ReferenceOutputAssembly="false"/>
<ProjectReference Include="..\testapps\OciWit\OciWit.csproj" ReferenceOutputAssembly="false"/>
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<InvariantGlobalization>true</InvariantGlobalization>
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
<TargetName>appwithwitfolder</TargetName>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\src\WasmComponent.Sdk\WasmComponent.Sdk.csproj" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM"/>
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions test/WasmComponentSdkTest/testapps/OciWit/OciWit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
<Import Project="..\..\..\..\src\WasmComponent.Sdk\ImportInDev.proj" />

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<InvariantGlobalization>true</InvariantGlobalization>
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
<TargetName>ociwit</TargetName>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\src\WasmComponent.Sdk\WasmComponent.Sdk.csproj" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -16,6 +16,7 @@

<ItemGroup>
<ProjectReference Include="..\..\..\..\src\WasmComponent.Sdk\WasmComponent.Sdk.csproj" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM"/>

<!-- Just to ensure build order -->
<ProjectReference Include="..\SimpleProducer\SimpleProducer.csproj" ReferenceOutputAssembly="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Import Project="..\..\..\..\src\WasmComponent.Sdk\ImportInDev.proj" />

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -16,6 +16,7 @@

<ItemGroup>
<ProjectReference Include="..\..\..\..\src\WasmComponent.Sdk\WasmComponent.Sdk.csproj" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM"/>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/WitBindgenTest/WitBindgenTest/WitBindgenTest.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
<Import Project="..\..\..\..\src\WitBindgen\ImportInDev.proj" />

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\src\WitBindgen\WitBindgen.csproj" />
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM"/>
</ItemGroup>

<ItemGroup>
Expand Down