From 5223035d6b148d8fc2fc1300472e701629b0ee51 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Tue, 4 Mar 2025 20:14:54 -0800 Subject: [PATCH 1/5] Start a template Signed-off-by: James Sturtevant --- .../wasi-cli/.template.config/template.json | 13 ++++++++++++ templates/wasi-cli/Program.cs | 2 ++ templates/wasi-cli/nuget.config | 9 ++++++++ templates/wasi-cli/wasi-cli.csproj | 21 +++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 templates/wasi-cli/.template.config/template.json create mode 100644 templates/wasi-cli/Program.cs create mode 100644 templates/wasi-cli/nuget.config create mode 100644 templates/wasi-cli/wasi-cli.csproj diff --git a/templates/wasi-cli/.template.config/template.json b/templates/wasi-cli/.template.config/template.json new file mode 100644 index 0000000..606616b --- /dev/null +++ b/templates/wasi-cli/.template.config/template.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json.schemastore.org/template", + "author": "Bytecode Alliance Developers", + "classifications": [ "wasi","wasm", "Console" ], + "identity": "BytecodeAlliance.Componentize.DotNet.Wasi.Template", + "name": "Componentize dotnet: wasi template", + "shortName": "wasi", + "sourceName":"wasi-cli", + "tags": { + "language": "C#", + "type": "project" + } + } \ No newline at end of file diff --git a/templates/wasi-cli/Program.cs b/templates/wasi-cli/Program.cs new file mode 100644 index 0000000..3751555 --- /dev/null +++ b/templates/wasi-cli/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/templates/wasi-cli/nuget.config b/templates/wasi-cli/nuget.config new file mode 100644 index 0000000..caa4ee8 --- /dev/null +++ b/templates/wasi-cli/nuget.config @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/templates/wasi-cli/wasi-cli.csproj b/templates/wasi-cli/wasi-cli.csproj new file mode 100644 index 0000000..59d9734 --- /dev/null +++ b/templates/wasi-cli/wasi-cli.csproj @@ -0,0 +1,21 @@ + + + + Exe + net9.0 + wasi_cli + enable + enable + wasi-wasm + false + true + true + true + + + + + + + + From 9a06abf87c6a44b72051219adadee0920b56c12b Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Wed, 5 Mar 2025 17:56:26 -0800 Subject: [PATCH 2/5] Conditionalized template and create pacakge Signed-off-by: James Sturtevant --- .github/workflows/build.yml | 6 + ...iance.Componentize.DotNet.Templates.csproj | 45 ++++++++ .../wasi-cli/.template.config/template.json | 54 +++++++++ templates/{ => content}/wasi-cli/Program.cs | 2 +- templates/{ => content}/wasi-cli/nuget.config | 0 .../{ => content}/wasi-cli/wasi-cli.csproj | 6 +- .../wasi-cli/.template.config/template.json | 13 --- wasm-component-sdk.sln | 109 ++++++++++++++++++ 8 files changed, 218 insertions(+), 17 deletions(-) create mode 100644 templates/BytecodeAlliance.Componentize.DotNet.Templates.csproj create mode 100644 templates/content/wasi-cli/.template.config/template.json rename templates/{ => content}/wasi-cli/Program.cs (65%) rename templates/{ => content}/wasi-cli/nuget.config (100%) rename templates/{ => content}/wasi-cli/wasi-cli.csproj (62%) delete mode 100644 templates/wasi-cli/.template.config/template.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4dda88..921cb01 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,6 +34,12 @@ jobs: run: dotnet test --no-build --verbosity normal - name: Pack run: dotnet pack -c Release /p:BuildNumber=${{ github.run_number }} + - name: Test Template + run: | + dotnet new install .\artifacts\BytecodeAlliance.Componentize.DotNet.Templates.*.nupkg + dotnet new componentize.wasi.cli -o test + cd test + dotnet build # must use windows to generate package https://github.com/bytecodealliance/componentize-dotnet/issues/41 # only need one package published https://github.com/actions/upload-artifact?tab=readme-ov-file#not-uploading-to-the-same-artifact - name: Upload artifacts diff --git a/templates/BytecodeAlliance.Componentize.DotNet.Templates.csproj b/templates/BytecodeAlliance.Componentize.DotNet.Templates.csproj new file mode 100644 index 0000000..72ad77f --- /dev/null +++ b/templates/BytecodeAlliance.Componentize.DotNet.Templates.csproj @@ -0,0 +1,45 @@ + + + + BytecodeAlliance.Componentize.DotNet.Templates + Templates for Componentize-dotnet + Bytecode Alliance Developers + Provides templates for Templates for Componentize-dotnet + Apache-2.0 WITH LLVM-exception + webassembly, .net, wasm + https://github.com/bytecodealliance/componentize-dotnet + https://github.com/bytecodealliance/componentize-dotnet + true + https://github.com/bytecodealliance/componentize-dotnet/releases/tag/$(PackageVersion) + + + + + Template + net9.0 + true + false + content + $(NoWarn);NU5128 + true + README.md + + + + false + + + + + + + + + + + + + + + + diff --git a/templates/content/wasi-cli/.template.config/template.json b/templates/content/wasi-cli/.template.config/template.json new file mode 100644 index 0000000..7bd1473 --- /dev/null +++ b/templates/content/wasi-cli/.template.config/template.json @@ -0,0 +1,54 @@ +{ + "$schema": "http://json.schemastore.org/template", + "author": "Bytecode Alliance Developers", + "classifications": [ + "wasi", + "wasm", + "Console" + ], + "identity": "BytecodeAlliance.Componentize.DotNet.Templates.Console", + "name": "Componentize-dotnet wasi console template", + "shortName": "componentize.wasi.cli", + "sourceName": "wasi-cli", + "tags": { + "language": "C#", + "type": "project" + }, + "symbols": { + "platform": { + "type": "generated", + "generator": "switch", + "datatype": "string", + "parameters": { + "evaluator": "C++", + "datatype": "string", + "cases": [ + { + "condition": "(OS == \"Windows_NT\")", + "value": "windows" + }, + { + "condition": "(OS == \"Linux\")", + "value": "lunux" + } + ] + } + } + }, + "postActions": [ + { + "description": "Welcome to Componetize dotnet", + "manualInstructions": [ + { + "text": "To get started run dotnet build. Learn more at https://github.com/bytecodealliance/componentize-dotnet." + } + ], + "args": { + "executable": "dotnet build", + "args": "" + }, + "actionId": "AC1156F7-BB77-4DB8-B28F-24EEBCCA1E5C", + "continueOnError": true + } + ] +} \ No newline at end of file diff --git a/templates/wasi-cli/Program.cs b/templates/content/wasi-cli/Program.cs similarity index 65% rename from templates/wasi-cli/Program.cs rename to templates/content/wasi-cli/Program.cs index 3751555..7023ea6 100644 --- a/templates/wasi-cli/Program.cs +++ b/templates/content/wasi-cli/Program.cs @@ -1,2 +1,2 @@ // See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +Console.WriteLine("Hello, world!"); diff --git a/templates/wasi-cli/nuget.config b/templates/content/wasi-cli/nuget.config similarity index 100% rename from templates/wasi-cli/nuget.config rename to templates/content/wasi-cli/nuget.config diff --git a/templates/wasi-cli/wasi-cli.csproj b/templates/content/wasi-cli/wasi-cli.csproj similarity index 62% rename from templates/wasi-cli/wasi-cli.csproj rename to templates/content/wasi-cli/wasi-cli.csproj index 59d9734..0977622 100644 --- a/templates/wasi-cli/wasi-cli.csproj +++ b/templates/content/wasi-cli/wasi-cli.csproj @@ -14,8 +14,8 @@ - - + + + - diff --git a/templates/wasi-cli/.template.config/template.json b/templates/wasi-cli/.template.config/template.json deleted file mode 100644 index 606616b..0000000 --- a/templates/wasi-cli/.template.config/template.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/template", - "author": "Bytecode Alliance Developers", - "classifications": [ "wasi","wasm", "Console" ], - "identity": "BytecodeAlliance.Componentize.DotNet.Wasi.Template", - "name": "Componentize dotnet: wasi template", - "shortName": "wasi", - "sourceName":"wasi-cli", - "tags": { - "language": "C#", - "type": "project" - } - } \ No newline at end of file diff --git a/wasm-component-sdk.sln b/wasm-component-sdk.sln index 0cc2361..ec68827 100644 --- a/wasm-component-sdk.sln +++ b/wasm-component-sdk.sln @@ -48,56 +48,164 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "E2ETest", "E2ETest", "{B3F6 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PackageTest", "test\E2ETest\PackageTest\PackageTest.csproj", "{777FE7FE-1B1A-4848-BE4A-7670A92DEBCC}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "templates", "templates", "{808186BE-9BD0-DD1D-D574-36EEAD1E7F8F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BytecodeAlliance.Componentize.DotNet.Templates", "templates\BytecodeAlliance.Componentize.DotNet.Templates.csproj", "{16F33B39-83C5-4E6C-89D3-CF2B9385AC28}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {FB68D5A1-89AA-47AB-B397-F93FF529995C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FB68D5A1-89AA-47AB-B397-F93FF529995C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FB68D5A1-89AA-47AB-B397-F93FF529995C}.Debug|x64.ActiveCfg = Debug|Any CPU + {FB68D5A1-89AA-47AB-B397-F93FF529995C}.Debug|x64.Build.0 = Debug|Any CPU + {FB68D5A1-89AA-47AB-B397-F93FF529995C}.Debug|x86.ActiveCfg = Debug|Any CPU + {FB68D5A1-89AA-47AB-B397-F93FF529995C}.Debug|x86.Build.0 = Debug|Any CPU {FB68D5A1-89AA-47AB-B397-F93FF529995C}.Release|Any CPU.ActiveCfg = Release|Any CPU {FB68D5A1-89AA-47AB-B397-F93FF529995C}.Release|Any CPU.Build.0 = Release|Any CPU + {FB68D5A1-89AA-47AB-B397-F93FF529995C}.Release|x64.ActiveCfg = Release|Any CPU + {FB68D5A1-89AA-47AB-B397-F93FF529995C}.Release|x64.Build.0 = Release|Any CPU + {FB68D5A1-89AA-47AB-B397-F93FF529995C}.Release|x86.ActiveCfg = Release|Any CPU + {FB68D5A1-89AA-47AB-B397-F93FF529995C}.Release|x86.Build.0 = Release|Any CPU {7D4CD1D4-4DD2-418F-9E46-FF4140293B63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7D4CD1D4-4DD2-418F-9E46-FF4140293B63}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D4CD1D4-4DD2-418F-9E46-FF4140293B63}.Debug|x64.ActiveCfg = Debug|Any CPU + {7D4CD1D4-4DD2-418F-9E46-FF4140293B63}.Debug|x64.Build.0 = Debug|Any CPU + {7D4CD1D4-4DD2-418F-9E46-FF4140293B63}.Debug|x86.ActiveCfg = Debug|Any CPU + {7D4CD1D4-4DD2-418F-9E46-FF4140293B63}.Debug|x86.Build.0 = Debug|Any CPU {7D4CD1D4-4DD2-418F-9E46-FF4140293B63}.Release|Any CPU.ActiveCfg = Release|Any CPU {7D4CD1D4-4DD2-418F-9E46-FF4140293B63}.Release|Any CPU.Build.0 = Release|Any CPU + {7D4CD1D4-4DD2-418F-9E46-FF4140293B63}.Release|x64.ActiveCfg = Release|Any CPU + {7D4CD1D4-4DD2-418F-9E46-FF4140293B63}.Release|x64.Build.0 = Release|Any CPU + {7D4CD1D4-4DD2-418F-9E46-FF4140293B63}.Release|x86.ActiveCfg = Release|Any CPU + {7D4CD1D4-4DD2-418F-9E46-FF4140293B63}.Release|x86.Build.0 = Release|Any CPU {5A906283-BA3B-4335-A5FA-0DFDEB771D84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5A906283-BA3B-4335-A5FA-0DFDEB771D84}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5A906283-BA3B-4335-A5FA-0DFDEB771D84}.Debug|x64.ActiveCfg = Debug|Any CPU + {5A906283-BA3B-4335-A5FA-0DFDEB771D84}.Debug|x64.Build.0 = Debug|Any CPU + {5A906283-BA3B-4335-A5FA-0DFDEB771D84}.Debug|x86.ActiveCfg = Debug|Any CPU + {5A906283-BA3B-4335-A5FA-0DFDEB771D84}.Debug|x86.Build.0 = Debug|Any CPU {5A906283-BA3B-4335-A5FA-0DFDEB771D84}.Release|Any CPU.ActiveCfg = Release|Any CPU {5A906283-BA3B-4335-A5FA-0DFDEB771D84}.Release|Any CPU.Build.0 = Release|Any CPU + {5A906283-BA3B-4335-A5FA-0DFDEB771D84}.Release|x64.ActiveCfg = Release|Any CPU + {5A906283-BA3B-4335-A5FA-0DFDEB771D84}.Release|x64.Build.0 = Release|Any CPU + {5A906283-BA3B-4335-A5FA-0DFDEB771D84}.Release|x86.ActiveCfg = Release|Any CPU + {5A906283-BA3B-4335-A5FA-0DFDEB771D84}.Release|x86.Build.0 = Release|Any CPU {09E495AF-959E-4B3C-90FC-7E6CD5869F27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {09E495AF-959E-4B3C-90FC-7E6CD5869F27}.Debug|Any CPU.Build.0 = Debug|Any CPU + {09E495AF-959E-4B3C-90FC-7E6CD5869F27}.Debug|x64.ActiveCfg = Debug|Any CPU + {09E495AF-959E-4B3C-90FC-7E6CD5869F27}.Debug|x64.Build.0 = Debug|Any CPU + {09E495AF-959E-4B3C-90FC-7E6CD5869F27}.Debug|x86.ActiveCfg = Debug|Any CPU + {09E495AF-959E-4B3C-90FC-7E6CD5869F27}.Debug|x86.Build.0 = Debug|Any CPU {09E495AF-959E-4B3C-90FC-7E6CD5869F27}.Release|Any CPU.ActiveCfg = Release|Any CPU {09E495AF-959E-4B3C-90FC-7E6CD5869F27}.Release|Any CPU.Build.0 = Release|Any CPU + {09E495AF-959E-4B3C-90FC-7E6CD5869F27}.Release|x64.ActiveCfg = Release|Any CPU + {09E495AF-959E-4B3C-90FC-7E6CD5869F27}.Release|x64.Build.0 = Release|Any CPU + {09E495AF-959E-4B3C-90FC-7E6CD5869F27}.Release|x86.ActiveCfg = Release|Any CPU + {09E495AF-959E-4B3C-90FC-7E6CD5869F27}.Release|x86.Build.0 = Release|Any CPU {D6691373-08CB-466F-A230-A038BD82D6CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D6691373-08CB-466F-A230-A038BD82D6CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6691373-08CB-466F-A230-A038BD82D6CD}.Debug|x64.ActiveCfg = Debug|Any CPU + {D6691373-08CB-466F-A230-A038BD82D6CD}.Debug|x64.Build.0 = Debug|Any CPU + {D6691373-08CB-466F-A230-A038BD82D6CD}.Debug|x86.ActiveCfg = Debug|Any CPU + {D6691373-08CB-466F-A230-A038BD82D6CD}.Debug|x86.Build.0 = Debug|Any CPU {D6691373-08CB-466F-A230-A038BD82D6CD}.Release|Any CPU.ActiveCfg = Release|Any CPU {D6691373-08CB-466F-A230-A038BD82D6CD}.Release|Any CPU.Build.0 = Release|Any CPU + {D6691373-08CB-466F-A230-A038BD82D6CD}.Release|x64.ActiveCfg = Release|Any CPU + {D6691373-08CB-466F-A230-A038BD82D6CD}.Release|x64.Build.0 = Release|Any CPU + {D6691373-08CB-466F-A230-A038BD82D6CD}.Release|x86.ActiveCfg = Release|Any CPU + {D6691373-08CB-466F-A230-A038BD82D6CD}.Release|x86.Build.0 = Release|Any CPU {20ED9DCE-3911-4382-BE1A-14BA3382A930}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {20ED9DCE-3911-4382-BE1A-14BA3382A930}.Debug|Any CPU.Build.0 = Debug|Any CPU + {20ED9DCE-3911-4382-BE1A-14BA3382A930}.Debug|x64.ActiveCfg = Debug|Any CPU + {20ED9DCE-3911-4382-BE1A-14BA3382A930}.Debug|x64.Build.0 = Debug|Any CPU + {20ED9DCE-3911-4382-BE1A-14BA3382A930}.Debug|x86.ActiveCfg = Debug|Any CPU + {20ED9DCE-3911-4382-BE1A-14BA3382A930}.Debug|x86.Build.0 = Debug|Any CPU {20ED9DCE-3911-4382-BE1A-14BA3382A930}.Release|Any CPU.ActiveCfg = Release|Any CPU {20ED9DCE-3911-4382-BE1A-14BA3382A930}.Release|Any CPU.Build.0 = Release|Any CPU + {20ED9DCE-3911-4382-BE1A-14BA3382A930}.Release|x64.ActiveCfg = Release|Any CPU + {20ED9DCE-3911-4382-BE1A-14BA3382A930}.Release|x64.Build.0 = Release|Any CPU + {20ED9DCE-3911-4382-BE1A-14BA3382A930}.Release|x86.ActiveCfg = Release|Any CPU + {20ED9DCE-3911-4382-BE1A-14BA3382A930}.Release|x86.Build.0 = Release|Any CPU {9B56CBAA-3E96-4ABD-A7E2-A986ADFD3408}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9B56CBAA-3E96-4ABD-A7E2-A986ADFD3408}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9B56CBAA-3E96-4ABD-A7E2-A986ADFD3408}.Debug|x64.ActiveCfg = Debug|Any CPU + {9B56CBAA-3E96-4ABD-A7E2-A986ADFD3408}.Debug|x64.Build.0 = Debug|Any CPU + {9B56CBAA-3E96-4ABD-A7E2-A986ADFD3408}.Debug|x86.ActiveCfg = Debug|Any CPU + {9B56CBAA-3E96-4ABD-A7E2-A986ADFD3408}.Debug|x86.Build.0 = Debug|Any CPU {9B56CBAA-3E96-4ABD-A7E2-A986ADFD3408}.Release|Any CPU.ActiveCfg = Release|Any CPU {9B56CBAA-3E96-4ABD-A7E2-A986ADFD3408}.Release|Any CPU.Build.0 = Release|Any CPU + {9B56CBAA-3E96-4ABD-A7E2-A986ADFD3408}.Release|x64.ActiveCfg = Release|Any CPU + {9B56CBAA-3E96-4ABD-A7E2-A986ADFD3408}.Release|x64.Build.0 = Release|Any CPU + {9B56CBAA-3E96-4ABD-A7E2-A986ADFD3408}.Release|x86.ActiveCfg = Release|Any CPU + {9B56CBAA-3E96-4ABD-A7E2-A986ADFD3408}.Release|x86.Build.0 = Release|Any CPU {9176AC70-039F-43B5-BA3D-CDF9FE1D3BFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9176AC70-039F-43B5-BA3D-CDF9FE1D3BFB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9176AC70-039F-43B5-BA3D-CDF9FE1D3BFB}.Debug|x64.ActiveCfg = Debug|Any CPU + {9176AC70-039F-43B5-BA3D-CDF9FE1D3BFB}.Debug|x64.Build.0 = Debug|Any CPU + {9176AC70-039F-43B5-BA3D-CDF9FE1D3BFB}.Debug|x86.ActiveCfg = Debug|Any CPU + {9176AC70-039F-43B5-BA3D-CDF9FE1D3BFB}.Debug|x86.Build.0 = Debug|Any CPU {9176AC70-039F-43B5-BA3D-CDF9FE1D3BFB}.Release|Any CPU.ActiveCfg = Release|Any CPU {9176AC70-039F-43B5-BA3D-CDF9FE1D3BFB}.Release|Any CPU.Build.0 = Release|Any CPU + {9176AC70-039F-43B5-BA3D-CDF9FE1D3BFB}.Release|x64.ActiveCfg = Release|Any CPU + {9176AC70-039F-43B5-BA3D-CDF9FE1D3BFB}.Release|x64.Build.0 = Release|Any CPU + {9176AC70-039F-43B5-BA3D-CDF9FE1D3BFB}.Release|x86.ActiveCfg = Release|Any CPU + {9176AC70-039F-43B5-BA3D-CDF9FE1D3BFB}.Release|x86.Build.0 = Release|Any CPU {BBF34708-0583-4708-AB93-CECADB446B8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BBF34708-0583-4708-AB93-CECADB446B8B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BBF34708-0583-4708-AB93-CECADB446B8B}.Debug|x64.ActiveCfg = Debug|Any CPU + {BBF34708-0583-4708-AB93-CECADB446B8B}.Debug|x64.Build.0 = Debug|Any CPU + {BBF34708-0583-4708-AB93-CECADB446B8B}.Debug|x86.ActiveCfg = Debug|Any CPU + {BBF34708-0583-4708-AB93-CECADB446B8B}.Debug|x86.Build.0 = Debug|Any CPU {BBF34708-0583-4708-AB93-CECADB446B8B}.Release|Any CPU.ActiveCfg = Release|Any CPU {BBF34708-0583-4708-AB93-CECADB446B8B}.Release|Any CPU.Build.0 = Release|Any CPU + {BBF34708-0583-4708-AB93-CECADB446B8B}.Release|x64.ActiveCfg = Release|Any CPU + {BBF34708-0583-4708-AB93-CECADB446B8B}.Release|x64.Build.0 = Release|Any CPU + {BBF34708-0583-4708-AB93-CECADB446B8B}.Release|x86.ActiveCfg = Release|Any CPU + {BBF34708-0583-4708-AB93-CECADB446B8B}.Release|x86.Build.0 = Release|Any CPU {2BAB8E09-C4EC-40D3-9378-5BFB6620B26B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2BAB8E09-C4EC-40D3-9378-5BFB6620B26B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2BAB8E09-C4EC-40D3-9378-5BFB6620B26B}.Debug|x64.ActiveCfg = Debug|Any CPU + {2BAB8E09-C4EC-40D3-9378-5BFB6620B26B}.Debug|x64.Build.0 = Debug|Any CPU + {2BAB8E09-C4EC-40D3-9378-5BFB6620B26B}.Debug|x86.ActiveCfg = Debug|Any CPU + {2BAB8E09-C4EC-40D3-9378-5BFB6620B26B}.Debug|x86.Build.0 = Debug|Any CPU {2BAB8E09-C4EC-40D3-9378-5BFB6620B26B}.Release|Any CPU.ActiveCfg = Release|Any CPU {2BAB8E09-C4EC-40D3-9378-5BFB6620B26B}.Release|Any CPU.Build.0 = Release|Any CPU + {2BAB8E09-C4EC-40D3-9378-5BFB6620B26B}.Release|x64.ActiveCfg = Release|Any CPU + {2BAB8E09-C4EC-40D3-9378-5BFB6620B26B}.Release|x64.Build.0 = Release|Any CPU + {2BAB8E09-C4EC-40D3-9378-5BFB6620B26B}.Release|x86.ActiveCfg = Release|Any CPU + {2BAB8E09-C4EC-40D3-9378-5BFB6620B26B}.Release|x86.Build.0 = Release|Any CPU {777FE7FE-1B1A-4848-BE4A-7670A92DEBCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {777FE7FE-1B1A-4848-BE4A-7670A92DEBCC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {777FE7FE-1B1A-4848-BE4A-7670A92DEBCC}.Debug|x64.ActiveCfg = Debug|Any CPU + {777FE7FE-1B1A-4848-BE4A-7670A92DEBCC}.Debug|x64.Build.0 = Debug|Any CPU + {777FE7FE-1B1A-4848-BE4A-7670A92DEBCC}.Debug|x86.ActiveCfg = Debug|Any CPU + {777FE7FE-1B1A-4848-BE4A-7670A92DEBCC}.Debug|x86.Build.0 = Debug|Any CPU {777FE7FE-1B1A-4848-BE4A-7670A92DEBCC}.Release|Any CPU.ActiveCfg = Release|Any CPU {777FE7FE-1B1A-4848-BE4A-7670A92DEBCC}.Release|Any CPU.Build.0 = Release|Any CPU + {777FE7FE-1B1A-4848-BE4A-7670A92DEBCC}.Release|x64.ActiveCfg = Release|Any CPU + {777FE7FE-1B1A-4848-BE4A-7670A92DEBCC}.Release|x64.Build.0 = Release|Any CPU + {777FE7FE-1B1A-4848-BE4A-7670A92DEBCC}.Release|x86.ActiveCfg = Release|Any CPU + {777FE7FE-1B1A-4848-BE4A-7670A92DEBCC}.Release|x86.Build.0 = Release|Any CPU + {16F33B39-83C5-4E6C-89D3-CF2B9385AC28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {16F33B39-83C5-4E6C-89D3-CF2B9385AC28}.Debug|Any CPU.Build.0 = Debug|Any CPU + {16F33B39-83C5-4E6C-89D3-CF2B9385AC28}.Debug|x64.ActiveCfg = Debug|Any CPU + {16F33B39-83C5-4E6C-89D3-CF2B9385AC28}.Debug|x64.Build.0 = Debug|Any CPU + {16F33B39-83C5-4E6C-89D3-CF2B9385AC28}.Debug|x86.ActiveCfg = Debug|Any CPU + {16F33B39-83C5-4E6C-89D3-CF2B9385AC28}.Debug|x86.Build.0 = Debug|Any CPU + {16F33B39-83C5-4E6C-89D3-CF2B9385AC28}.Release|Any CPU.ActiveCfg = Release|Any CPU + {16F33B39-83C5-4E6C-89D3-CF2B9385AC28}.Release|Any CPU.Build.0 = Release|Any CPU + {16F33B39-83C5-4E6C-89D3-CF2B9385AC28}.Release|x64.ActiveCfg = Release|Any CPU + {16F33B39-83C5-4E6C-89D3-CF2B9385AC28}.Release|x64.Build.0 = Release|Any CPU + {16F33B39-83C5-4E6C-89D3-CF2B9385AC28}.Release|x86.ActiveCfg = Release|Any CPU + {16F33B39-83C5-4E6C-89D3-CF2B9385AC28}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -121,6 +229,7 @@ Global {BAA8D48E-411B-4135-9E4F-5B01F5CF3C62} = {A1E6722B-B184-4AB8-9629-E6A5E76EE9CA} {B3F60B5E-F19A-4E69-91B5-51053E6BBF5A} = {A1E6722B-B184-4AB8-9629-E6A5E76EE9CA} {777FE7FE-1B1A-4848-BE4A-7670A92DEBCC} = {B3F60B5E-F19A-4E69-91B5-51053E6BBF5A} + {16F33B39-83C5-4E6C-89D3-CF2B9385AC28} = {808186BE-9BD0-DD1D-D574-36EEAD1E7F8F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1F033B40-BF0A-4D81-B1D6-84080B73D385} From 6a087dc76798fd95d852ca765aad10b37f7f7a97 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Thu, 6 Mar 2025 13:21:52 -0800 Subject: [PATCH 3/5] Make it work on linux Signed-off-by: James Sturtevant --- .github/workflows/build.yml | 2 +- .../content/wasi-cli/.template.config/template.json | 12 ++++-------- templates/content/wasi-cli/Program.cs | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 921cb01..292c132 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: run: dotnet pack -c Release /p:BuildNumber=${{ github.run_number }} - name: Test Template run: | - dotnet new install .\artifacts\BytecodeAlliance.Componentize.DotNet.Templates.*.nupkg + dotnet new install ./artifacts/BytecodeAlliance.Componentize.DotNet.Templates.*.nupkg dotnet new componentize.wasi.cli -o test cd test dotnet build diff --git a/templates/content/wasi-cli/.template.config/template.json b/templates/content/wasi-cli/.template.config/template.json index 7bd1473..49ab6f9 100644 --- a/templates/content/wasi-cli/.template.config/template.json +++ b/templates/content/wasi-cli/.template.config/template.json @@ -24,12 +24,12 @@ "datatype": "string", "cases": [ { - "condition": "(OS == \"Windows_NT\")", + "condition": "(env:OS == \"Windows_NT\")", "value": "windows" }, { - "condition": "(OS == \"Linux\")", - "value": "lunux" + "condition": "(env:OS != \"Windows_NT\")", + "value": "linux" } ] } @@ -40,13 +40,9 @@ "description": "Welcome to Componetize dotnet", "manualInstructions": [ { - "text": "To get started run dotnet build. Learn more at https://github.com/bytecodealliance/componentize-dotnet." + "text": "To get started run `dotnet build` inside your new project. Learn more at https://github.com/bytecodealliance/componentize-dotnet." } ], - "args": { - "executable": "dotnet build", - "args": "" - }, "actionId": "AC1156F7-BB77-4DB8-B28F-24EEBCCA1E5C", "continueOnError": true } diff --git a/templates/content/wasi-cli/Program.cs b/templates/content/wasi-cli/Program.cs index 7023ea6..408632e 100644 --- a/templates/content/wasi-cli/Program.cs +++ b/templates/content/wasi-cli/Program.cs @@ -1,2 +1,2 @@ // See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, world!"); +Console.WriteLine("Hello, world from compontize-dotnet!"); From 21330ca8a1d29dcfd6241c911080ab964c4e32bd Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Thu, 6 Mar 2025 13:36:53 -0800 Subject: [PATCH 4/5] conditions don't really work with os except on windows Signed-off-by: James Sturtevant --- .github/workflows/build.yml | 3 +++ templates/content/wasi-cli/.template.config/template.json | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 292c132..36e7ce7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,9 +37,12 @@ jobs: - name: Test Template run: | dotnet new install ./artifacts/BytecodeAlliance.Componentize.DotNet.Templates.*.nupkg + mkdir ${{ runner.temp }}/projects + pushd ${{ runner.temp }}/projects dotnet new componentize.wasi.cli -o test cd test dotnet build + popd # must use windows to generate package https://github.com/bytecodealliance/componentize-dotnet/issues/41 # only need one package published https://github.com/actions/upload-artifact?tab=readme-ov-file#not-uploading-to-the-same-artifact - name: Upload artifacts diff --git a/templates/content/wasi-cli/.template.config/template.json b/templates/content/wasi-cli/.template.config/template.json index 49ab6f9..2a0f101 100644 --- a/templates/content/wasi-cli/.template.config/template.json +++ b/templates/content/wasi-cli/.template.config/template.json @@ -24,11 +24,14 @@ "datatype": "string", "cases": [ { - "condition": "(env:OS == \"Windows_NT\")", + "condition": "(OS == \"Windows_NT\")", "value": "windows" }, { - "condition": "(env:OS != \"Windows_NT\")", + "condition": "(OS == \"Linux\")", + "value": "linux" + }, + { "value": "linux" } ] From be2043cf8257ab12460671354b0705ff1c7bb82c Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Thu, 6 Mar 2025 13:49:59 -0800 Subject: [PATCH 5/5] Simplify using a bind Signed-off-by: James Sturtevant --- .../wasi-cli/.template.config/template.json | 23 +++---------------- templates/content/wasi-cli/wasi-cli.csproj | 2 +- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/templates/content/wasi-cli/.template.config/template.json b/templates/content/wasi-cli/.template.config/template.json index 2a0f101..18386a5 100644 --- a/templates/content/wasi-cli/.template.config/template.json +++ b/templates/content/wasi-cli/.template.config/template.json @@ -16,26 +16,9 @@ }, "symbols": { "platform": { - "type": "generated", - "generator": "switch", - "datatype": "string", - "parameters": { - "evaluator": "C++", - "datatype": "string", - "cases": [ - { - "condition": "(OS == \"Windows_NT\")", - "value": "windows" - }, - { - "condition": "(OS == \"Linux\")", - "value": "linux" - }, - { - "value": "linux" - } - ] - } + "type": "bind", + "binding": "env:OS", + "defaultValue": "linux" } }, "postActions": [ diff --git a/templates/content/wasi-cli/wasi-cli.csproj b/templates/content/wasi-cli/wasi-cli.csproj index 0977622..51af1c4 100644 --- a/templates/content/wasi-cli/wasi-cli.csproj +++ b/templates/content/wasi-cli/wasi-cli.csproj @@ -15,7 +15,7 @@ - +