diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6e235f6..194deb0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,7 +39,7 @@ jobs: run: | ls ./artifacts/*.nupkg version=$(unzip -p ./artifacts/*SDK*.nupkg '*.nuspec' | grep -oE "[^<]+" | sed 's///' | grep -oE "^[0-9]+\.[0-9]+\.[0-9]+-preview") - template_version=$(grep -oE "Version=\"[^\"]+" ./templates/content/wasi-cli/wasi-cli.csproj | sed 's/Version="//' | grep -oE "^[0-9]+\.[0-9]+\.[0-9]+-preview") + template_version=$(grep -oE 'Version="[^"]+' ./templates/content/wasi-cli/wasi-cli.csproj | sed 's/Version="//' | grep -oE "^[0-9]+\.[0-9]+\.[0-9]+-preview") echo "Package Version: $version | Template version: $template_version" if [ "$version" != "$template_version" ]; then echo "Version mismatch: Package version ($version) does not match template version ($template_version)"; diff --git a/.gitignore b/.gitignore index 0a06dc8..5b3c375 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ artifacts/ test/WasmComponentSdkTest/testapps/OciWit/wit/*.wasm *.binlog .DS_Store +templates/content/wasi-cli/wasi-cli.csproj +src/WasmComponent.Sdk/sdk/Version.props \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index 08ca89b..0c7a828 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -18,4 +18,40 @@ 30.0.2 + + + + + + + + + + + + + + \n\n" + + result + ); + } + ]]> + + + + diff --git a/Directory.Packages.props b/Directory.Packages.props index 8e653e8..dee35d9 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,10 +3,6 @@ true - - - - diff --git a/README.md b/README.md index 41b543c..c85a98d 100644 --- a/README.md +++ b/README.md @@ -256,41 +256,21 @@ If you get a build error along the lines of _failed to encode a component from m * `dotnet new console -o MyApp` * `cd MyApp` -Create a `nuget.config` file and add the `dotnet-experimental` package source for the `NativeAOT-LLVM` dependency: +Edit the `.csproj` file: -* `dotnet new nugetconfig` -* Add these keys to `nuget.config` after ``: +1. Add the following line under ``: -```xml - - -``` - -Add the `componentize-dotnet` package: - -`dotnet add package BytecodeAlliance.Componentize.DotNet.Wasm.SDK --prerelease` - -Add the platform specific LLVM package: - -``` -## On Linux -dotnet add package runtime.linux-x64.microsoft.dotnet.ilcompiler.llvm --prerelease + ```xml + + ``` +2. Add the following inside the ``: -## or - -## On Windows -dotnet add package runtime.win-x64.microsoft.dotnet.ilcompiler.llvm --prerelease -``` - -Edit the `.csproj` file, adding the following inside the ``: - -``` -wasi-wasm -false -true -true -true -``` + ```xml + wasi-wasm + true + true + true + ``` Now you can `dotnet build` to produce a `.wasm` file using NativeAOT compilation. @@ -314,6 +294,18 @@ Caused by: Some imports automatically imported since they are so common. In this case you should tell the runtime to implement those imports. For instance for the error above, in wasmtime you might add `-S cli` to the `wasmtime serve` command like `wasmtime serve -S cli` to include the `wasi:cli/environment@0.2.0` in wasmtime runtime host implementation. +## SDK configuration +You can configure the SDK by setting properties in your project file. The following are supported: + +| Property Name | Description | Default | +|---------------|-------------|---------| +| `WasiSdkVersion` | Version of the WASI SDK to use.
Be aware that not all versions of the WASI SDK are compatible with NativeAOT-LLVM. A warning will appear if you select an incompatible version for NativeAOT-LLVM.

⚠️ When changing this value, or the NativeAOT-LLVM version, check the build output for a warning! | `24.0` | +| `NativeAotLlvmVersion` | Version of the NativeAOT-LLVM package to use.
Find latest versions in the [dotnet-experimental feed](https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-experimental/NuGet/Microsoft.DotNet.ILCompiler.LLVM/versions). | `10.0.0-alpha.1.25162.1` | +| `WitBindgenVersion` | Version of the `BytecodeAlliance.Componentize.DotNet.WitBindgen` package to use. | Current SDK version | +| `RegisterExperimentalNuGetSource` | Whether to register the [dotnet-experimental feed](https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-experimental/NuGet) to find the NativeAOT-LLVM package. Set this to `false` if you have a NuGet.config that already includes this feed. | `true` | +| `WitBindgenAddtionalArgs` | Additional arguments to pass to `wit-bindgen` when generating C# bindings. Separate multiple arguments with spaces. For example: `--with-wit-results --features tls`. | (empty) | +| `WitGeneratedFilesRoot` | Folder (relative to the project root) where generated WIT files will be placed. | (empty) | + ## Credits This project was original developed and forked from https://github.com/SteveSandersonMS/wasm-component-sdk under the Apache 2.0 License with a LLVM exception. diff --git a/nuget.config b/nuget.config deleted file mode 100644 index d2578df..0000000 --- a/nuget.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/samples/calculator/Adder/Adder.csproj b/samples/calculator/Adder/Adder.csproj index 3909d08..dbf2a8c 100644 --- a/samples/calculator/Adder/Adder.csproj +++ b/samples/calculator/Adder/Adder.csproj @@ -17,7 +17,6 @@ - diff --git a/samples/calculator/CalculatorComposed/CalculatorComposed.csproj b/samples/calculator/CalculatorComposed/CalculatorComposed.csproj index 786cffc..683f376 100644 --- a/samples/calculator/CalculatorComposed/CalculatorComposed.csproj +++ b/samples/calculator/CalculatorComposed/CalculatorComposed.csproj @@ -13,7 +13,6 @@ - diff --git a/samples/calculator/CalculatorHost/CalculatorHost.csproj b/samples/calculator/CalculatorHost/CalculatorHost.csproj index ab2c1a8..730b3ae 100644 --- a/samples/calculator/CalculatorHost/CalculatorHost.csproj +++ b/samples/calculator/CalculatorHost/CalculatorHost.csproj @@ -14,7 +14,6 @@ - diff --git a/src/WasmComponent.Sdk/ImportInDev.proj b/src/WasmComponent.Sdk/ImportInDev.proj index b1d936b..066fcce 100644 --- a/src/WasmComponent.Sdk/ImportInDev.proj +++ b/src/WasmComponent.Sdk/ImportInDev.proj @@ -4,7 +4,4 @@ - - -
diff --git a/src/WasmComponent.Sdk/Version.xml b/src/WasmComponent.Sdk/Version.xml new file mode 100644 index 0000000..ab6d921 --- /dev/null +++ b/src/WasmComponent.Sdk/Version.xml @@ -0,0 +1,5 @@ + + + $version$ + + \ No newline at end of file diff --git a/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj b/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj index 6f4286f..1921457 100644 --- a/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj +++ b/src/WasmComponent.Sdk/WasmComponent.Sdk.csproj @@ -34,10 +34,6 @@ tar - - - - @@ -106,8 +102,15 @@ + + + - <_PackageFiles Include="build\**" BuildAction="Content" PackagePath="build" /> + <_PackageFiles Include="sdk\**" BuildAction="Content" PackagePath="Sdk" /> + <_PackageFiles Include="build\**" BuildAction="Content" PackagePath="Sdk" /> <_PackageFiles Include="tools\**" BuildAction="Content" PackagePath="tools" /> diff --git a/src/WasmComponent.Sdk/build/BytecodeAlliance.Componentize.DotNet.Wasm.SDK.props b/src/WasmComponent.Sdk/build/BytecodeAlliance.Componentize.DotNet.Wasm.SDK.props index a6f34e1..802b3b6 100644 --- a/src/WasmComponent.Sdk/build/BytecodeAlliance.Componentize.DotNet.Wasm.SDK.props +++ b/src/WasmComponent.Sdk/build/BytecodeAlliance.Componentize.DotNet.Wasm.SDK.props @@ -19,9 +19,11 @@ $(MSBuildThisFileDirectory)..\tools\$(ToolsTarget)\wac $(WacExe).exe + + + 10.0.0-alpha.1.25162.1 + true - - - + diff --git a/src/WasmComponent.Sdk/build/BytecodeAlliance.Componentize.DotNet.Wasm.SDK.targets b/src/WasmComponent.Sdk/build/BytecodeAlliance.Componentize.DotNet.Wasm.SDK.targets index 06648c7..51caa38 100644 --- a/src/WasmComponent.Sdk/build/BytecodeAlliance.Componentize.DotNet.Wasm.SDK.targets +++ b/src/WasmComponent.Sdk/build/BytecodeAlliance.Componentize.DotNet.Wasm.SDK.targets @@ -1,4 +1,13 @@ + + $(RestoreAdditionalProjectSources);https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json; + + + + + + + diff --git a/src/WasmComponent.Sdk/sdk/Sdk.props b/src/WasmComponent.Sdk/sdk/Sdk.props new file mode 100644 index 0000000..96aa50f --- /dev/null +++ b/src/WasmComponent.Sdk/sdk/Sdk.props @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/WasmComponent.Sdk/sdk/Sdk.targets b/src/WasmComponent.Sdk/sdk/Sdk.targets new file mode 100644 index 0000000..9498aed --- /dev/null +++ b/src/WasmComponent.Sdk/sdk/Sdk.targets @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/WitBindgen/build/BytecodeAlliance.Componentize.DotNet.WitBindgen.targets b/src/WitBindgen/build/BytecodeAlliance.Componentize.DotNet.WitBindgen.targets index e6c516e..065ec06 100644 --- a/src/WitBindgen/build/BytecodeAlliance.Componentize.DotNet.WitBindgen.targets +++ b/src/WitBindgen/build/BytecodeAlliance.Componentize.DotNet.WitBindgen.targets @@ -1,4 +1,5 @@  + native-aot @@ -8,7 +9,6 @@ https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion.Split(".")[0])/wasi-sdk-$(WasiSdkVersion)-x86_64-linux.tar.gz https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion.Split(".")[0])/wasi-sdk-$(WasiSdkVersion)-x86_64-macos.tar.gz $([System.IO.Path]::Combine("$([System.Environment]::GetFolderPath(SpecialFolder.UserProfile))", ".wasi-sdk", "wasi-sdk-$(WasiSdkVersion)")) - diff --git a/templates/BytecodeAlliance.Componentize.DotNet.Templates.csproj b/templates/BytecodeAlliance.Componentize.DotNet.Templates.csproj index fc4c3c0..e164564 100644 --- a/templates/BytecodeAlliance.Componentize.DotNet.Templates.csproj +++ b/templates/BytecodeAlliance.Componentize.DotNet.Templates.csproj @@ -42,4 +42,9 @@
+ + + + + diff --git a/templates/content/wasi-cli/.template.config/template.json b/templates/content/wasi-cli/.template.config/template.json index 18386a5..bdaa014 100644 --- a/templates/content/wasi-cli/.template.config/template.json +++ b/templates/content/wasi-cli/.template.config/template.json @@ -14,13 +14,6 @@ "language": "C#", "type": "project" }, - "symbols": { - "platform": { - "type": "bind", - "binding": "env:OS", - "defaultValue": "linux" - } - }, "postActions": [ { "description": "Welcome to Componetize dotnet", diff --git a/templates/content/wasi-cli/nuget.config b/templates/content/wasi-cli/nuget.config deleted file mode 100644 index caa4ee8..0000000 --- a/templates/content/wasi-cli/nuget.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/templates/content/wasi-cli/wasi-cli.csproj b/templates/content/wasi-cli/wasi-cli.csproj deleted file mode 100644 index 0e706fc..0000000 --- a/templates/content/wasi-cli/wasi-cli.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - Exe - net10.0 - wasi_cli - enable - enable - wasi-wasm - false - true - true - true - - - - - - - - diff --git a/templates/wasi-cli.xml b/templates/wasi-cli.xml new file mode 100644 index 0000000..685b1db --- /dev/null +++ b/templates/wasi-cli.xml @@ -0,0 +1,14 @@ + + + + + + Exe + net10.0 + wasi_cli + enable + enable + true + + + diff --git a/test/E2ETest/PackageTest/PackageTest.csproj b/test/E2ETest/PackageTest/PackageTest.csproj index 4e5e093..50bd58a 100644 --- a/test/E2ETest/PackageTest/PackageTest.csproj +++ b/test/E2ETest/PackageTest/PackageTest.csproj @@ -28,7 +28,6 @@ - diff --git a/test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj b/test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj index aca4445..f33f8d9 100644 --- a/test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj +++ b/test/E2ETest/testapps/E2EConsumer/E2EConsumer.csproj @@ -1,6 +1,7 @@  - + + Exe @@ -19,7 +20,6 @@ - diff --git a/test/E2ETest/testapps/E2EProducer/E2EProducer.csproj b/test/E2ETest/testapps/E2EProducer/E2EProducer.csproj index 425b924..09c8090 100644 --- a/test/E2ETest/testapps/E2EProducer/E2EProducer.csproj +++ b/test/E2ETest/testapps/E2EProducer/E2EProducer.csproj @@ -1,6 +1,7 @@  - + + net10.0 @@ -17,7 +18,6 @@ - diff --git a/test/WasmComponentSdkTest/WasmComponentSdkTest/WasmComponentSdkTest.csproj b/test/WasmComponentSdkTest/WasmComponentSdkTest/WasmComponentSdkTest.csproj index acd75a5..0672933 100644 --- a/test/WasmComponentSdkTest/WasmComponentSdkTest/WasmComponentSdkTest.csproj +++ b/test/WasmComponentSdkTest/WasmComponentSdkTest/WasmComponentSdkTest.csproj @@ -33,7 +33,6 @@ - diff --git a/test/WasmComponentSdkTest/testapps/AppWithWitFolder/AppWithWitFolder.csproj b/test/WasmComponentSdkTest/testapps/AppWithWitFolder/AppWithWitFolder.csproj index 938cdcb..f069945 100644 --- a/test/WasmComponentSdkTest/testapps/AppWithWitFolder/AppWithWitFolder.csproj +++ b/test/WasmComponentSdkTest/testapps/AppWithWitFolder/AppWithWitFolder.csproj @@ -15,7 +15,6 @@ - diff --git a/test/WasmComponentSdkTest/testapps/OciWit/OciWit.csproj b/test/WasmComponentSdkTest/testapps/OciWit/OciWit.csproj index 1e315b6..4757792 100644 --- a/test/WasmComponentSdkTest/testapps/OciWit/OciWit.csproj +++ b/test/WasmComponentSdkTest/testapps/OciWit/OciWit.csproj @@ -13,7 +13,6 @@ - diff --git a/test/WasmComponentSdkTest/testapps/SimpleConsumer/SimpleConsumer.csproj b/test/WasmComponentSdkTest/testapps/SimpleConsumer/SimpleConsumer.csproj index de0792a..e520bde 100644 --- a/test/WasmComponentSdkTest/testapps/SimpleConsumer/SimpleConsumer.csproj +++ b/test/WasmComponentSdkTest/testapps/SimpleConsumer/SimpleConsumer.csproj @@ -16,7 +16,6 @@ - diff --git a/test/WasmComponentSdkTest/testapps/SimpleProducer/SimpleProducer.csproj b/test/WasmComponentSdkTest/testapps/SimpleProducer/SimpleProducer.csproj index 89ba5c6..3263e63 100644 --- a/test/WasmComponentSdkTest/testapps/SimpleProducer/SimpleProducer.csproj +++ b/test/WasmComponentSdkTest/testapps/SimpleProducer/SimpleProducer.csproj @@ -16,7 +16,6 @@ - diff --git a/test/WitBindgenTest/testapps/LibraryUsingWit/LibraryUsingWit.csproj b/test/WitBindgenTest/testapps/LibraryUsingWit/LibraryUsingWit.csproj index 1341151..f20042f 100644 --- a/test/WitBindgenTest/testapps/LibraryUsingWit/LibraryUsingWit.csproj +++ b/test/WitBindgenTest/testapps/LibraryUsingWit/LibraryUsingWit.csproj @@ -10,7 +10,6 @@ - diff --git a/test/WitBindgenTest/testapps/LibraryWithCustomGeneratedFilesLocation/LibraryWithCustomGeneratedFilesLocation.csproj b/test/WitBindgenTest/testapps/LibraryWithCustomGeneratedFilesLocation/LibraryWithCustomGeneratedFilesLocation.csproj index 31cb00a..146f6c8 100644 --- a/test/WitBindgenTest/testapps/LibraryWithCustomGeneratedFilesLocation/LibraryWithCustomGeneratedFilesLocation.csproj +++ b/test/WitBindgenTest/testapps/LibraryWithCustomGeneratedFilesLocation/LibraryWithCustomGeneratedFilesLocation.csproj @@ -11,7 +11,6 @@ - diff --git a/test/WitBindgenTest/testapps/LibraryWithExceptions/LibraryWitExceptions.csproj b/test/WitBindgenTest/testapps/LibraryWithExceptions/LibraryWitExceptions.csproj index 2c35d8f..f255ad3 100644 --- a/test/WitBindgenTest/testapps/LibraryWithExceptions/LibraryWitExceptions.csproj +++ b/test/WitBindgenTest/testapps/LibraryWithExceptions/LibraryWitExceptions.csproj @@ -10,7 +10,6 @@ - diff --git a/test/WitBindgenTest/testapps/LibraryWithWitResultType/LibraryWithWitResultType.csproj b/test/WitBindgenTest/testapps/LibraryWithWitResultType/LibraryWithWitResultType.csproj index 9d2aab3..466b521 100644 --- a/test/WitBindgenTest/testapps/LibraryWithWitResultType/LibraryWithWitResultType.csproj +++ b/test/WitBindgenTest/testapps/LibraryWithWitResultType/LibraryWithWitResultType.csproj @@ -11,7 +11,6 @@ -