From 51a4fd16ea0b0f685bcae347a58c66e76d2174e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tero=20Kilpel=C3=A4inen?= Date: Fri, 20 Jun 2025 13:13:21 +0300 Subject: [PATCH 1/6] First attempt, not quite --- SharpSite.sln | 147 ++++++++++++++++++ src/SharpSite.PluginPacker/ArgumentParser.cs | 25 +++ src/SharpSite.PluginPacker/ManifestHandler.cs | 34 ++++ .../ManifestPrompter.cs | 57 +++++++ src/SharpSite.PluginPacker/PluginPackager.cs | 25 +++ src/SharpSite.PluginPacker/PluginValidator.cs | 39 +++++ src/SharpSite.PluginPacker/Program.cs | 43 +++++ .../SharpSite.PluginPacker.csproj | 14 ++ 8 files changed, 384 insertions(+) create mode 100644 src/SharpSite.PluginPacker/ArgumentParser.cs create mode 100644 src/SharpSite.PluginPacker/ManifestHandler.cs create mode 100644 src/SharpSite.PluginPacker/ManifestPrompter.cs create mode 100644 src/SharpSite.PluginPacker/PluginPackager.cs create mode 100644 src/SharpSite.PluginPacker/PluginValidator.cs create mode 100644 src/SharpSite.PluginPacker/Program.cs create mode 100644 src/SharpSite.PluginPacker/SharpSite.PluginPacker.csproj diff --git a/SharpSite.sln b/SharpSite.sln index 7ed7ff9..59c8c32 100644 --- a/SharpSite.sln +++ b/SharpSite.sln @@ -56,76 +56,222 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSite.E2E", "e2e\SharpS EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSite.Tests.Plugins", "tests\SharpSite.Tests.Plugins\SharpSite.Tests.Plugins.csproj", "{6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSite.PluginPacker", "src\SharpSite.PluginPacker\SharpSite.PluginPacker.csproj", "{677B59E7-C4BA-4024-84D7-78CE6985F3F5}" +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 {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Debug|x64.ActiveCfg = Debug|Any CPU + {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Debug|x64.Build.0 = Debug|Any CPU + {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Debug|x86.ActiveCfg = Debug|Any CPU + {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Debug|x86.Build.0 = Debug|Any CPU {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Release|Any CPU.ActiveCfg = Release|Any CPU {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Release|Any CPU.Build.0 = Release|Any CPU + {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Release|x64.ActiveCfg = Release|Any CPU + {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Release|x64.Build.0 = Release|Any CPU + {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Release|x86.ActiveCfg = Release|Any CPU + {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Release|x86.Build.0 = Release|Any CPU {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Debug|x64.ActiveCfg = Debug|Any CPU + {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Debug|x64.Build.0 = Debug|Any CPU + {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Debug|x86.ActiveCfg = Debug|Any CPU + {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Debug|x86.Build.0 = Debug|Any CPU {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Release|Any CPU.ActiveCfg = Release|Any CPU {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Release|Any CPU.Build.0 = Release|Any CPU + {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Release|x64.ActiveCfg = Release|Any CPU + {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Release|x64.Build.0 = Release|Any CPU + {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Release|x86.ActiveCfg = Release|Any CPU + {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Release|x86.Build.0 = Release|Any CPU {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Debug|x64.ActiveCfg = Debug|Any CPU + {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Debug|x64.Build.0 = Debug|Any CPU + {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Debug|x86.ActiveCfg = Debug|Any CPU + {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Debug|x86.Build.0 = Debug|Any CPU {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Release|Any CPU.ActiveCfg = Release|Any CPU {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Release|Any CPU.Build.0 = Release|Any CPU + {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Release|x64.ActiveCfg = Release|Any CPU + {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Release|x64.Build.0 = Release|Any CPU + {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Release|x86.ActiveCfg = Release|Any CPU + {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Release|x86.Build.0 = Release|Any CPU {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Debug|x64.ActiveCfg = Debug|Any CPU + {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Debug|x64.Build.0 = Debug|Any CPU + {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Debug|x86.ActiveCfg = Debug|Any CPU + {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Debug|x86.Build.0 = Debug|Any CPU {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Release|Any CPU.Build.0 = Release|Any CPU + {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Release|x64.ActiveCfg = Release|Any CPU + {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Release|x64.Build.0 = Release|Any CPU + {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Release|x86.ActiveCfg = Release|Any CPU + {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Release|x86.Build.0 = Release|Any CPU {6594608C-854F-436B-8B5B-4FF223A57C8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6594608C-854F-436B-8B5B-4FF223A57C8B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6594608C-854F-436B-8B5B-4FF223A57C8B}.Debug|x64.ActiveCfg = Debug|Any CPU + {6594608C-854F-436B-8B5B-4FF223A57C8B}.Debug|x64.Build.0 = Debug|Any CPU + {6594608C-854F-436B-8B5B-4FF223A57C8B}.Debug|x86.ActiveCfg = Debug|Any CPU + {6594608C-854F-436B-8B5B-4FF223A57C8B}.Debug|x86.Build.0 = Debug|Any CPU {6594608C-854F-436B-8B5B-4FF223A57C8B}.Release|Any CPU.ActiveCfg = Release|Any CPU {6594608C-854F-436B-8B5B-4FF223A57C8B}.Release|Any CPU.Build.0 = Release|Any CPU + {6594608C-854F-436B-8B5B-4FF223A57C8B}.Release|x64.ActiveCfg = Release|Any CPU + {6594608C-854F-436B-8B5B-4FF223A57C8B}.Release|x64.Build.0 = Release|Any CPU + {6594608C-854F-436B-8B5B-4FF223A57C8B}.Release|x86.ActiveCfg = Release|Any CPU + {6594608C-854F-436B-8B5B-4FF223A57C8B}.Release|x86.Build.0 = Release|Any CPU {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Debug|x64.ActiveCfg = Debug|Any CPU + {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Debug|x64.Build.0 = Debug|Any CPU + {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Debug|x86.ActiveCfg = Debug|Any CPU + {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Debug|x86.Build.0 = Debug|Any CPU {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Release|Any CPU.ActiveCfg = Release|Any CPU {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Release|Any CPU.Build.0 = Release|Any CPU + {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Release|x64.ActiveCfg = Release|Any CPU + {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Release|x64.Build.0 = Release|Any CPU + {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Release|x86.ActiveCfg = Release|Any CPU + {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Release|x86.Build.0 = Release|Any CPU {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Debug|Any CPU.Build.0 = Debug|Any CPU + {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Debug|x64.ActiveCfg = Debug|Any CPU + {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Debug|x64.Build.0 = Debug|Any CPU + {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Debug|x86.ActiveCfg = Debug|Any CPU + {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Debug|x86.Build.0 = Debug|Any CPU {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Release|Any CPU.ActiveCfg = Release|Any CPU {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Release|Any CPU.Build.0 = Release|Any CPU + {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Release|x64.ActiveCfg = Release|Any CPU + {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Release|x64.Build.0 = Release|Any CPU + {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Release|x86.ActiveCfg = Release|Any CPU + {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Release|x86.Build.0 = Release|Any CPU {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Debug|x64.ActiveCfg = Debug|Any CPU + {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Debug|x64.Build.0 = Debug|Any CPU + {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Debug|x86.ActiveCfg = Debug|Any CPU + {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Debug|x86.Build.0 = Debug|Any CPU {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Release|Any CPU.Build.0 = Release|Any CPU + {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Release|x64.ActiveCfg = Release|Any CPU + {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Release|x64.Build.0 = Release|Any CPU + {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Release|x86.ActiveCfg = Release|Any CPU + {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Release|x86.Build.0 = Release|Any CPU {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Debug|x64.ActiveCfg = Debug|Any CPU + {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Debug|x64.Build.0 = Debug|Any CPU + {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Debug|x86.ActiveCfg = Debug|Any CPU + {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Debug|x86.Build.0 = Debug|Any CPU {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Release|Any CPU.ActiveCfg = Release|Any CPU {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Release|Any CPU.Build.0 = Release|Any CPU + {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Release|x64.ActiveCfg = Release|Any CPU + {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Release|x64.Build.0 = Release|Any CPU + {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Release|x86.ActiveCfg = Release|Any CPU + {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Release|x86.Build.0 = Release|Any CPU {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Debug|x64.ActiveCfg = Debug|Any CPU + {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Debug|x64.Build.0 = Debug|Any CPU + {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Debug|x86.ActiveCfg = Debug|Any CPU + {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Debug|x86.Build.0 = Debug|Any CPU {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Release|Any CPU.Build.0 = Release|Any CPU + {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Release|x64.ActiveCfg = Release|Any CPU + {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Release|x64.Build.0 = Release|Any CPU + {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Release|x86.ActiveCfg = Release|Any CPU + {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Release|x86.Build.0 = Release|Any CPU {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Debug|x64.ActiveCfg = Debug|Any CPU + {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Debug|x64.Build.0 = Debug|Any CPU + {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Debug|x86.ActiveCfg = Debug|Any CPU + {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Debug|x86.Build.0 = Debug|Any CPU {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Release|Any CPU.ActiveCfg = Release|Any CPU {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Release|Any CPU.Build.0 = Release|Any CPU + {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Release|x64.ActiveCfg = Release|Any CPU + {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Release|x64.Build.0 = Release|Any CPU + {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Release|x86.ActiveCfg = Release|Any CPU + {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Release|x86.Build.0 = Release|Any CPU {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Debug|x64.ActiveCfg = Debug|Any CPU + {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Debug|x64.Build.0 = Debug|Any CPU + {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Debug|x86.ActiveCfg = Debug|Any CPU + {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Debug|x86.Build.0 = Debug|Any CPU {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Release|Any CPU.ActiveCfg = Release|Any CPU {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Release|Any CPU.Build.0 = Release|Any CPU + {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Release|x64.ActiveCfg = Release|Any CPU + {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Release|x64.Build.0 = Release|Any CPU + {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Release|x86.ActiveCfg = Release|Any CPU + {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Release|x86.Build.0 = Release|Any CPU {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Debug|x64.ActiveCfg = Debug|Any CPU + {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Debug|x64.Build.0 = Debug|Any CPU + {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Debug|x86.ActiveCfg = Debug|Any CPU + {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Debug|x86.Build.0 = Debug|Any CPU {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Release|Any CPU.ActiveCfg = Release|Any CPU {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Release|Any CPU.Build.0 = Release|Any CPU + {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Release|x64.ActiveCfg = Release|Any CPU + {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Release|x64.Build.0 = Release|Any CPU + {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Release|x86.ActiveCfg = Release|Any CPU + {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Release|x86.Build.0 = Release|Any CPU {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Debug|x64.ActiveCfg = Debug|Any CPU + {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Debug|x64.Build.0 = Debug|Any CPU + {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Debug|x86.ActiveCfg = Debug|Any CPU + {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Debug|x86.Build.0 = Debug|Any CPU {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Release|Any CPU.ActiveCfg = Release|Any CPU {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Release|Any CPU.Build.0 = Release|Any CPU + {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Release|x64.ActiveCfg = Release|Any CPU + {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Release|x64.Build.0 = Release|Any CPU + {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Release|x86.ActiveCfg = Release|Any CPU + {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Release|x86.Build.0 = Release|Any CPU {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Debug|x64.ActiveCfg = Debug|Any CPU + {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Debug|x64.Build.0 = Debug|Any CPU + {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Debug|x86.ActiveCfg = Debug|Any CPU + {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Debug|x86.Build.0 = Debug|Any CPU {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Release|Any CPU.ActiveCfg = Release|Any CPU {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Release|Any CPU.Build.0 = Release|Any CPU + {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Release|x64.ActiveCfg = Release|Any CPU + {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Release|x64.Build.0 = Release|Any CPU + {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Release|x86.ActiveCfg = Release|Any CPU + {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Release|x86.Build.0 = Release|Any CPU {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Debug|x64.ActiveCfg = Debug|Any CPU + {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Debug|x64.Build.0 = Debug|Any CPU + {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Debug|x86.ActiveCfg = Debug|Any CPU + {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Debug|x86.Build.0 = Debug|Any CPU {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Release|Any CPU.ActiveCfg = Release|Any CPU {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Release|Any CPU.Build.0 = Release|Any CPU + {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Release|x64.ActiveCfg = Release|Any CPU + {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Release|x64.Build.0 = Release|Any CPU + {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Release|x86.ActiveCfg = Release|Any CPU + {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Release|x86.Build.0 = Release|Any CPU + {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Debug|x64.ActiveCfg = Debug|Any CPU + {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Debug|x64.Build.0 = Debug|Any CPU + {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Debug|x86.ActiveCfg = Debug|Any CPU + {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Debug|x86.Build.0 = Debug|Any CPU + {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Release|Any CPU.Build.0 = Release|Any CPU + {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Release|x64.ActiveCfg = Release|Any CPU + {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Release|x64.Build.0 = Release|Any CPU + {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Release|x86.ActiveCfg = Release|Any CPU + {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -147,6 +293,7 @@ Global {BA24379C-40D5-5EDF-63BE-CE5BC727E45D} = {3266CA51-9816-4037-9715-701EB6C2928A} {EFCFB571-6B0C-35CD-6664-160CA5B39244} = {8779454A-1F9C-4705-8EE0-5980C6B9C2A5} {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C} = {3266CA51-9816-4037-9715-701EB6C2928A} + {677B59E7-C4BA-4024-84D7-78CE6985F3F5} = {ED943946-A640-4B85-83C9-0FF6BCE8BA5A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {62A15C13-360B-4791-89E9-1FDDFE483970} diff --git a/src/SharpSite.PluginPacker/ArgumentParser.cs b/src/SharpSite.PluginPacker/ArgumentParser.cs new file mode 100644 index 0000000..545f6c3 --- /dev/null +++ b/src/SharpSite.PluginPacker/ArgumentParser.cs @@ -0,0 +1,25 @@ +namespace SharpSite.PluginPacker; + +public static class ArgumentParser +{ + public static (string? inputPath, string? outputPath) ParseArguments(string[] args) + { + string? inputPath = null; + string? outputPath = null; + for (int i = 0; i < args.Length; i++) + { + switch (args[i]) + { + case "-i": + case "--input": + if (i + 1 < args.Length) inputPath = args[++i]; + break; + case "-o": + case "--output": + if (i + 1 < args.Length) outputPath = args[++i]; + break; + } + } + return (inputPath, outputPath); + } +} diff --git a/src/SharpSite.PluginPacker/ManifestHandler.cs b/src/SharpSite.PluginPacker/ManifestHandler.cs new file mode 100644 index 0000000..15296b9 --- /dev/null +++ b/src/SharpSite.PluginPacker/ManifestHandler.cs @@ -0,0 +1,34 @@ +using System.Text.Json; +using SharpSite.Plugins; + +namespace SharpSite.PluginPacker; + +public static class ManifestHandler +{ + private static readonly JsonSerializerOptions _Opts = new() { WriteIndented = true }; + public static PluginManifest? LoadOrCreateManifest(string inputPath) + { + string manifestPath = Path.Combine(inputPath, "manifest.json"); + PluginManifest? manifest = null; + if (!File.Exists(manifestPath)) + { + Console.WriteLine($"manifest.json not found in {inputPath}."); + Console.WriteLine("Let's create one interactively."); + manifest = ManifestPrompter.PromptForManifest(); + var json = JsonSerializer.Serialize(manifest, _Opts); + File.WriteAllText(manifestPath, json); + Console.WriteLine($"Created manifest.json at {manifestPath}"); + } + else + { + var json = File.ReadAllText(manifestPath); + manifest = JsonSerializer.Deserialize(json); + if (manifest == null) + { + Console.WriteLine("Failed to parse manifest.json"); + return null; + } + } + return manifest; + } +} diff --git a/src/SharpSite.PluginPacker/ManifestPrompter.cs b/src/SharpSite.PluginPacker/ManifestPrompter.cs new file mode 100644 index 0000000..b647af8 --- /dev/null +++ b/src/SharpSite.PluginPacker/ManifestPrompter.cs @@ -0,0 +1,57 @@ +using SharpSite.Plugins; + +namespace SharpSite.PluginPacker; + +public static class ManifestPrompter +{ + private static string PromptRequired(string label) + { + string? value; + do + { + Console.Write($"{label}: "); + value = Console.ReadLine()?.Trim(); + if (string.IsNullOrWhiteSpace(value)) + { + Console.WriteLine($"{label} is required."); + } + } while (string.IsNullOrWhiteSpace(value)); + return value; + } + + public static PluginManifest PromptForManifest() + { + var id = PromptRequired("Id"); + var displayName = PromptRequired("DisplayName"); + var description = PromptRequired("Description"); + var version = PromptRequired("Version"); + var published = PromptRequired("Published (yyyy-MM-dd)"); + var supportedVersions = PromptRequired("SupportedVersions"); + var author = PromptRequired("Author"); + // Optional fields + Console.Write("Contact: "); + var contact = (Console.ReadLine() ?? "").Trim(); + Console.Write("ContactEmail: "); + var contactEmail = (Console.ReadLine() ?? "").Trim(); + Console.Write("AuthorWebsite: "); + var authorWebsite = (Console.ReadLine() ?? "").Trim(); + Console.Write("Features (comma separated, e.g. Theme,FileStorage): "); + var featuresStr = (Console.ReadLine() ?? "").Trim(); + var features = featuresStr.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + var featureEnums = features.Length > 0 ? Array.ConvertAll(features, f => Enum.Parse(f, true)) : []; + return new PluginManifest + { + Id = id, + DisplayName = displayName, + Description = description, + Version = version, + Published = published, + SupportedVersions = supportedVersions, + Author = author, + Contact = contact, + ContactEmail = contactEmail, + AuthorWebsite = authorWebsite, + Features = featureEnums + }; + } +} diff --git a/src/SharpSite.PluginPacker/PluginPackager.cs b/src/SharpSite.PluginPacker/PluginPackager.cs new file mode 100644 index 0000000..b73b26e --- /dev/null +++ b/src/SharpSite.PluginPacker/PluginPackager.cs @@ -0,0 +1,25 @@ +using System.IO.Compression; + +namespace SharpSite.PluginPacker; + +public static class PluginPackager +{ + public static bool PackagePlugin(string inputPath, string outputPath) + { + try + { + string tempZip = Path.GetTempFileName(); + if (File.Exists(tempZip)) File.Delete(tempZip); + ZipFile.CreateFromDirectory(inputPath, tempZip); + string outFile = outputPath.EndsWith(".sspkg", StringComparison.OrdinalIgnoreCase) ? outputPath : outputPath + ".sspkg"; + File.Move(tempZip, outFile); + Console.WriteLine($"Plugin packaged successfully: {outFile}"); + return true; + } + catch (Exception ex) + { + Console.WriteLine($"Packaging failed: {ex.Message}"); + return false; + } + } +} diff --git a/src/SharpSite.PluginPacker/PluginValidator.cs b/src/SharpSite.PluginPacker/PluginValidator.cs new file mode 100644 index 0000000..38bdfef --- /dev/null +++ b/src/SharpSite.PluginPacker/PluginValidator.cs @@ -0,0 +1,39 @@ +using SharpSite.Plugins; + +namespace SharpSite.PluginPacker; + +public static class PluginValidator +{ + public static bool ValidatePlugin(string inputPath, PluginManifest manifest) + { + bool valid = true; + foreach (var feature in manifest.Features) + { + switch (feature) + { + case PluginFeatures.Theme: + if (!Directory.Exists(Path.Combine(inputPath, "web"))) + { + Console.WriteLine("Error: Theme plugin must contain a 'web' folder."); + valid = false; + } + break; + case PluginFeatures.FileStorage: + // Add FileStorage-specific validation if needed + break; + } + } + string dllName = manifest.Id.Split('.').Last() + ".dll"; + string libPath = Path.Combine(inputPath, "lib"); + if (!Directory.Exists(libPath) || !File.Exists(Path.Combine(libPath, dllName))) + { + Console.WriteLine($"Error: 'lib/{dllName}' is required."); + valid = false; + } + if (!File.Exists(Path.Combine(inputPath, "LICENSE"))) + { + Console.WriteLine("Warning: LICENSE file is missing."); + } + return valid; + } +} diff --git a/src/SharpSite.PluginPacker/Program.cs b/src/SharpSite.PluginPacker/Program.cs new file mode 100644 index 0000000..09403c8 --- /dev/null +++ b/src/SharpSite.PluginPacker/Program.cs @@ -0,0 +1,43 @@ +using SharpSite.PluginPacker; + +(string? inputPath, string? outputPath) = ArgumentParser.ParseArguments(args); + +if (string.IsNullOrWhiteSpace(inputPath) || string.IsNullOrWhiteSpace(outputPath)) +{ + Console.WriteLine("Usage: SharpSite.PluginPacker -i -o "); + return 1; +} + +if (!Directory.Exists(inputPath)) +{ + Console.WriteLine($"Input directory '{inputPath}' does not exist."); + return 1; +} + +if (File.Exists(outputPath)) +{ + Console.WriteLine($"Output file '{outputPath}' already exists. Please choose a different output path."); + return 1; +} + +var manifest = ManifestHandler.LoadOrCreateManifest(inputPath); +if (manifest == null) +{ + Console.WriteLine("Failed to load or create manifest."); + return 1; +} +Console.WriteLine($"Loaded manifest for {manifest.DisplayName} ({manifest.Id})"); + +if (!PluginValidator.ValidatePlugin(inputPath, manifest)) +{ + Console.WriteLine("Plugin structure validation failed. Aborting packaging."); + return 1; +} + +if (!PluginPackager.PackagePlugin(inputPath, outputPath)) +{ + Console.WriteLine("Packaging failed."); + return 1; +} + +return 0; diff --git a/src/SharpSite.PluginPacker/SharpSite.PluginPacker.csproj b/src/SharpSite.PluginPacker/SharpSite.PluginPacker.csproj new file mode 100644 index 0000000..6d9085a --- /dev/null +++ b/src/SharpSite.PluginPacker/SharpSite.PluginPacker.csproj @@ -0,0 +1,14 @@ + + + + + + + + Exe + net9.0 + enable + enable + + + From 606d9d8fabf358d6519c5332f705c45dcefec11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tero=20Kilpel=C3=A4inen?= Date: Mon, 23 Jun 2025 12:16:37 +0300 Subject: [PATCH 2/6] first working test --- src/SharpSite.PluginPacker/ManifestHandler.cs | 12 +- src/SharpSite.PluginPacker/PluginPackager.cs | 106 +++++++++++++++++- src/SharpSite.PluginPacker/PluginValidator.cs | 39 ------- src/SharpSite.PluginPacker/Program.cs | 6 - 4 files changed, 111 insertions(+), 52 deletions(-) delete mode 100644 src/SharpSite.PluginPacker/PluginValidator.cs diff --git a/src/SharpSite.PluginPacker/ManifestHandler.cs b/src/SharpSite.PluginPacker/ManifestHandler.cs index 15296b9..4462892 100644 --- a/src/SharpSite.PluginPacker/ManifestHandler.cs +++ b/src/SharpSite.PluginPacker/ManifestHandler.cs @@ -1,15 +1,21 @@ using System.Text.Json; +using System.Text.Json.Serialization; using SharpSite.Plugins; namespace SharpSite.PluginPacker; public static class ManifestHandler { - private static readonly JsonSerializerOptions _Opts = new() { WriteIndented = true }; + private static readonly JsonSerializerOptions _Opts = new() + { + WriteIndented = true, + Converters = { new JsonStringEnumConverter() } + }; + public static PluginManifest? LoadOrCreateManifest(string inputPath) { string manifestPath = Path.Combine(inputPath, "manifest.json"); - PluginManifest? manifest = null; + PluginManifest? manifest; if (!File.Exists(manifestPath)) { Console.WriteLine($"manifest.json not found in {inputPath}."); @@ -22,7 +28,7 @@ public static class ManifestHandler else { var json = File.ReadAllText(manifestPath); - manifest = JsonSerializer.Deserialize(json); + manifest = JsonSerializer.Deserialize(json, _Opts); if (manifest == null) { Console.WriteLine("Failed to parse manifest.json"); diff --git a/src/SharpSite.PluginPacker/PluginPackager.cs b/src/SharpSite.PluginPacker/PluginPackager.cs index b73b26e..111a788 100644 --- a/src/SharpSite.PluginPacker/PluginPackager.cs +++ b/src/SharpSite.PluginPacker/PluginPackager.cs @@ -1,4 +1,6 @@ +using System.Diagnostics; using System.IO.Compression; +using SharpSite.Plugins; namespace SharpSite.PluginPacker; @@ -6,13 +8,76 @@ public static class PluginPackager { public static bool PackagePlugin(string inputPath, string outputPath) { + // Load manifest + var manifest = ManifestHandler.LoadOrCreateManifest(inputPath); + if (manifest == null) + { + Console.WriteLine("Manifest not found or invalid."); + return false; + } + + // 1. Create temp build output folder + string tempBuildDir = Path.Combine(Path.GetTempPath(), "SharpSitePluginBuild_" + Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(tempBuildDir); + + // 2. Build the project in Release mode to temp build folder + if (!BuildProject(inputPath, tempBuildDir)) + { + Console.WriteLine("Build failed."); + try { if (Directory.Exists(tempBuildDir)) Directory.Delete(tempBuildDir, true); } catch { } + return false; + } + + // 3. Create temp folder for packaging + string tempDir = Path.Combine(Path.GetTempPath(), "SharpSitePluginPack_" + Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(tempDir); try { - string tempZip = Path.GetTempFileName(); - if (File.Exists(tempZip)) File.Delete(tempZip); - ZipFile.CreateFromDirectory(inputPath, tempZip); + // 4. Create lib/ and copy/rename DLL + string libDir = Path.Combine(tempDir, "lib"); + Directory.CreateDirectory(libDir); + + string projectName = new DirectoryInfo(inputPath).Name; + string dllSource = Path.Combine(tempBuildDir, projectName + ".dll"); + string dllTarget = Path.Combine(libDir, manifest.Id + ".dll"); + if (!File.Exists(dllSource)) + { + Console.WriteLine($"DLL not found: {dllSource}"); + return false; + } + File.Copy(dllSource, dllTarget, overwrite: true); + + // 4. If Theme, copy .css from wwwroot/ to web/ + if (manifest.Features.Contains(PluginFeatures.Theme)) + { + string webSrc = Path.Combine(inputPath, "wwwroot"); + string webDst = Path.Combine(tempDir, "web"); + if (Directory.Exists(webSrc)) + { + Directory.CreateDirectory(webDst); + foreach (var css in Directory.GetFiles(webSrc, "*.css", SearchOption.AllDirectories)) + { + string dest = Path.Combine(webDst, Path.GetFileName(css)); + File.Copy(css, dest, overwrite: true); + } + } + } + + // 5. Copy manifest.json and other required files + string[] requiredFiles = ["manifest.json", "LICENSE", "README.md", "Changelog.txt"]; + foreach (var file in requiredFiles) + { + string src = Path.Combine(inputPath, file); + if (File.Exists(src)) + { + File.Copy(src, Path.Combine(tempDir, file), overwrite: true); + } + } + + // 6. Zip tempDir to outputPath string outFile = outputPath.EndsWith(".sspkg", StringComparison.OrdinalIgnoreCase) ? outputPath : outputPath + ".sspkg"; - File.Move(tempZip, outFile); + if (File.Exists(outFile)) File.Delete(outFile); + ZipFile.CreateFromDirectory(tempDir, outFile); Console.WriteLine($"Plugin packaged successfully: {outFile}"); return true; } @@ -21,5 +86,38 @@ public static bool PackagePlugin(string inputPath, string outputPath) Console.WriteLine($"Packaging failed: {ex.Message}"); return false; } + finally + { + // 7. Clean up temp folder + try { if (Directory.Exists(tempDir)) Directory.Delete(tempDir, true); } catch { } + try { if (Directory.Exists(tempBuildDir)) Directory.Delete(tempBuildDir, true); } catch { } + } + } + + private static bool BuildProject(string inputPath, string outputPath) + { + var psi = new ProcessStartInfo + { + FileName = "dotnet", + Arguments = $"build --configuration Release --output \"{outputPath}\"", + WorkingDirectory = inputPath, + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true + }; + using var proc = Process.Start(psi); + if (proc == null) + { + Console.WriteLine("Failed to start build process."); + return false; + } + proc.WaitForExit(); + if (proc.ExitCode != 0) + { + Console.WriteLine(proc.StandardError.ReadToEnd()); + return false; + } + return true; } } diff --git a/src/SharpSite.PluginPacker/PluginValidator.cs b/src/SharpSite.PluginPacker/PluginValidator.cs deleted file mode 100644 index 38bdfef..0000000 --- a/src/SharpSite.PluginPacker/PluginValidator.cs +++ /dev/null @@ -1,39 +0,0 @@ -using SharpSite.Plugins; - -namespace SharpSite.PluginPacker; - -public static class PluginValidator -{ - public static bool ValidatePlugin(string inputPath, PluginManifest manifest) - { - bool valid = true; - foreach (var feature in manifest.Features) - { - switch (feature) - { - case PluginFeatures.Theme: - if (!Directory.Exists(Path.Combine(inputPath, "web"))) - { - Console.WriteLine("Error: Theme plugin must contain a 'web' folder."); - valid = false; - } - break; - case PluginFeatures.FileStorage: - // Add FileStorage-specific validation if needed - break; - } - } - string dllName = manifest.Id.Split('.').Last() + ".dll"; - string libPath = Path.Combine(inputPath, "lib"); - if (!Directory.Exists(libPath) || !File.Exists(Path.Combine(libPath, dllName))) - { - Console.WriteLine($"Error: 'lib/{dllName}' is required."); - valid = false; - } - if (!File.Exists(Path.Combine(inputPath, "LICENSE"))) - { - Console.WriteLine("Warning: LICENSE file is missing."); - } - return valid; - } -} diff --git a/src/SharpSite.PluginPacker/Program.cs b/src/SharpSite.PluginPacker/Program.cs index 09403c8..8a8ace9 100644 --- a/src/SharpSite.PluginPacker/Program.cs +++ b/src/SharpSite.PluginPacker/Program.cs @@ -28,12 +28,6 @@ } Console.WriteLine($"Loaded manifest for {manifest.DisplayName} ({manifest.Id})"); -if (!PluginValidator.ValidatePlugin(inputPath, manifest)) -{ - Console.WriteLine("Plugin structure validation failed. Aborting packaging."); - return 1; -} - if (!PluginPackager.PackagePlugin(inputPath, outputPath)) { Console.WriteLine("Packaging failed."); From 4355500d3ba8835a5d300a2303ccf2a58a6e2143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tero=20Kilpel=C3=A4inen?= Date: Mon, 23 Jun 2025 13:20:34 +0300 Subject: [PATCH 3/6] refactor packer steps --- SharpSite.sln | 4 +- src/SharpSite.PluginPacker/ManifestHandler.cs | 2 +- src/SharpSite.PluginPacker/PluginPackager.cs | 97 +++++++++++-------- src/SharpSite.PluginPacker/Program.cs | 2 +- 4 files changed, 60 insertions(+), 45 deletions(-) diff --git a/SharpSite.sln b/SharpSite.sln index 59c8c32..09be06e 100644 --- a/SharpSite.sln +++ b/SharpSite.sln @@ -58,6 +58,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSite.Tests.Plugins", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSite.PluginPacker", "src\SharpSite.PluginPacker\SharpSite.PluginPacker.csproj", "{677B59E7-C4BA-4024-84D7-78CE6985F3F5}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2. Tools", "2. Tools", "{78F974E0-8074-0543-93D5-DC2AAC8BF3DF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -293,7 +295,7 @@ Global {BA24379C-40D5-5EDF-63BE-CE5BC727E45D} = {3266CA51-9816-4037-9715-701EB6C2928A} {EFCFB571-6B0C-35CD-6664-160CA5B39244} = {8779454A-1F9C-4705-8EE0-5980C6B9C2A5} {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C} = {3266CA51-9816-4037-9715-701EB6C2928A} - {677B59E7-C4BA-4024-84D7-78CE6985F3F5} = {ED943946-A640-4B85-83C9-0FF6BCE8BA5A} + {677B59E7-C4BA-4024-84D7-78CE6985F3F5} = {78F974E0-8074-0543-93D5-DC2AAC8BF3DF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {62A15C13-360B-4791-89E9-1FDDFE483970} diff --git a/src/SharpSite.PluginPacker/ManifestHandler.cs b/src/SharpSite.PluginPacker/ManifestHandler.cs index 4462892..597dc8a 100644 --- a/src/SharpSite.PluginPacker/ManifestHandler.cs +++ b/src/SharpSite.PluginPacker/ManifestHandler.cs @@ -29,7 +29,7 @@ public static class ManifestHandler { var json = File.ReadAllText(manifestPath); manifest = JsonSerializer.Deserialize(json, _Opts); - if (manifest == null) + if (manifest is null) { Console.WriteLine("Failed to parse manifest.json"); return null; diff --git a/src/SharpSite.PluginPacker/PluginPackager.cs b/src/SharpSite.PluginPacker/PluginPackager.cs index 111a788..a76f08d 100644 --- a/src/SharpSite.PluginPacker/PluginPackager.cs +++ b/src/SharpSite.PluginPacker/PluginPackager.cs @@ -10,17 +10,17 @@ public static bool PackagePlugin(string inputPath, string outputPath) { // Load manifest var manifest = ManifestHandler.LoadOrCreateManifest(inputPath); - if (manifest == null) + if (manifest is null) { Console.WriteLine("Manifest not found or invalid."); return false; } - // 1. Create temp build output folder + // Create temp build output folder string tempBuildDir = Path.Combine(Path.GetTempPath(), "SharpSitePluginBuild_" + Guid.NewGuid().ToString("N")); Directory.CreateDirectory(tempBuildDir); - // 2. Build the project in Release mode to temp build folder + // Build the project in Release mode to temp build folder if (!BuildProject(inputPath, tempBuildDir)) { Console.WriteLine("Build failed."); @@ -28,53 +28,24 @@ public static bool PackagePlugin(string inputPath, string outputPath) return false; } - // 3. Create temp folder for packaging + // Create temp folder for packaging string tempDir = Path.Combine(Path.GetTempPath(), "SharpSitePluginPack_" + Guid.NewGuid().ToString("N")); Directory.CreateDirectory(tempDir); try { - // 4. Create lib/ and copy/rename DLL - string libDir = Path.Combine(tempDir, "lib"); - Directory.CreateDirectory(libDir); + // Copy DLL to lib/ and rename + CopyAndRenameDll(inputPath, tempBuildDir, tempDir, manifest); - string projectName = new DirectoryInfo(inputPath).Name; - string dllSource = Path.Combine(tempBuildDir, projectName + ".dll"); - string dllTarget = Path.Combine(libDir, manifest.Id + ".dll"); - if (!File.Exists(dllSource)) - { - Console.WriteLine($"DLL not found: {dllSource}"); - return false; - } - File.Copy(dllSource, dllTarget, overwrite: true); - - // 4. If Theme, copy .css from wwwroot/ to web/ + // If Theme, copy .css from wwwroot/ to web/ if (manifest.Features.Contains(PluginFeatures.Theme)) { - string webSrc = Path.Combine(inputPath, "wwwroot"); - string webDst = Path.Combine(tempDir, "web"); - if (Directory.Exists(webSrc)) - { - Directory.CreateDirectory(webDst); - foreach (var css in Directory.GetFiles(webSrc, "*.css", SearchOption.AllDirectories)) - { - string dest = Path.Combine(webDst, Path.GetFileName(css)); - File.Copy(css, dest, overwrite: true); - } - } + CopyThemeCssFiles(inputPath, tempDir); } - // 5. Copy manifest.json and other required files - string[] requiredFiles = ["manifest.json", "LICENSE", "README.md", "Changelog.txt"]; - foreach (var file in requiredFiles) - { - string src = Path.Combine(inputPath, file); - if (File.Exists(src)) - { - File.Copy(src, Path.Combine(tempDir, file), overwrite: true); - } - } + // Copy manifest.json and other required files + CopyRequiredFiles(inputPath, tempDir); - // 6. Zip tempDir to outputPath + // Zip tempDir to outputPath string outFile = outputPath.EndsWith(".sspkg", StringComparison.OrdinalIgnoreCase) ? outputPath : outputPath + ".sspkg"; if (File.Exists(outFile)) File.Delete(outFile); ZipFile.CreateFromDirectory(tempDir, outFile); @@ -88,12 +59,54 @@ public static bool PackagePlugin(string inputPath, string outputPath) } finally { - // 7. Clean up temp folder + // Clean up temp folder try { if (Directory.Exists(tempDir)) Directory.Delete(tempDir, true); } catch { } try { if (Directory.Exists(tempBuildDir)) Directory.Delete(tempBuildDir, true); } catch { } } } + private static void CopyAndRenameDll(string inputPath, string tempBuildDir, string tempDir, dynamic manifest) + { + string libDir = Path.Combine(tempDir, "lib"); + Directory.CreateDirectory(libDir); + string projectName = new DirectoryInfo(inputPath).Name; + string dllSource = Path.Combine(tempBuildDir, projectName + ".dll"); + string dllTarget = Path.Combine(libDir, manifest.Id + ".dll"); + if (!File.Exists(dllSource)) + { + throw new FileNotFoundException($"DLL not found: {dllSource}"); + } + File.Copy(dllSource, dllTarget, overwrite: true); + } + + private static void CopyThemeCssFiles(string inputPath, string tempDir) + { + string webSrc = Path.Combine(inputPath, "wwwroot"); + string webDst = Path.Combine(tempDir, "web"); + if (Directory.Exists(webSrc)) + { + Directory.CreateDirectory(webDst); + foreach (var css in Directory.GetFiles(webSrc, "*.css", SearchOption.AllDirectories)) + { + string dest = Path.Combine(webDst, Path.GetFileName(css)); + File.Copy(css, dest, overwrite: true); + } + } + } + + private static void CopyRequiredFiles(string inputPath, string tempDir) + { + string[] requiredFiles = ["manifest.json", "LICENSE", "README.md", "Changelog.txt"]; + foreach (var file in requiredFiles) + { + string src = Path.Combine(inputPath, file); + if (File.Exists(src)) + { + File.Copy(src, Path.Combine(tempDir, file), overwrite: true); + } + } + } + private static bool BuildProject(string inputPath, string outputPath) { var psi = new ProcessStartInfo @@ -107,7 +120,7 @@ private static bool BuildProject(string inputPath, string outputPath) CreateNoWindow = true }; using var proc = Process.Start(psi); - if (proc == null) + if (proc is null) { Console.WriteLine("Failed to start build process."); return false; diff --git a/src/SharpSite.PluginPacker/Program.cs b/src/SharpSite.PluginPacker/Program.cs index 8a8ace9..74081cd 100644 --- a/src/SharpSite.PluginPacker/Program.cs +++ b/src/SharpSite.PluginPacker/Program.cs @@ -21,7 +21,7 @@ } var manifest = ManifestHandler.LoadOrCreateManifest(inputPath); -if (manifest == null) +if (manifest is null) { Console.WriteLine("Failed to load or create manifest."); return 1; From ec56c5ec633f10c1c5844d4d1af2f571b805bc06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tero=20Kilpel=C3=A4inen?= Date: Tue, 24 Jun 2025 10:43:15 +0300 Subject: [PATCH 4/6] clean solution file --- SharpSite.sln | 140 -------------------------------------------------- 1 file changed, 140 deletions(-) diff --git a/SharpSite.sln b/SharpSite.sln index 09be06e..9782609 100644 --- a/SharpSite.sln +++ b/SharpSite.sln @@ -63,217 +63,77 @@ 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 {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Debug|x64.ActiveCfg = Debug|Any CPU - {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Debug|x64.Build.0 = Debug|Any CPU - {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Debug|x86.ActiveCfg = Debug|Any CPU - {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Debug|x86.Build.0 = Debug|Any CPU {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Release|Any CPU.ActiveCfg = Release|Any CPU {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Release|Any CPU.Build.0 = Release|Any CPU - {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Release|x64.ActiveCfg = Release|Any CPU - {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Release|x64.Build.0 = Release|Any CPU - {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Release|x86.ActiveCfg = Release|Any CPU - {B76F4DC7-073A-4521-AAA2-5920A92FB9C2}.Release|x86.Build.0 = Release|Any CPU {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Debug|x64.ActiveCfg = Debug|Any CPU - {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Debug|x64.Build.0 = Debug|Any CPU - {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Debug|x86.ActiveCfg = Debug|Any CPU - {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Debug|x86.Build.0 = Debug|Any CPU {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Release|Any CPU.ActiveCfg = Release|Any CPU {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Release|Any CPU.Build.0 = Release|Any CPU - {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Release|x64.ActiveCfg = Release|Any CPU - {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Release|x64.Build.0 = Release|Any CPU - {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Release|x86.ActiveCfg = Release|Any CPU - {69274D92-FC5E-4459-9874-ABE8E37CD34F}.Release|x86.Build.0 = Release|Any CPU {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Debug|x64.ActiveCfg = Debug|Any CPU - {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Debug|x64.Build.0 = Debug|Any CPU - {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Debug|x86.ActiveCfg = Debug|Any CPU - {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Debug|x86.Build.0 = Debug|Any CPU {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Release|Any CPU.ActiveCfg = Release|Any CPU {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Release|Any CPU.Build.0 = Release|Any CPU - {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Release|x64.ActiveCfg = Release|Any CPU - {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Release|x64.Build.0 = Release|Any CPU - {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Release|x86.ActiveCfg = Release|Any CPU - {DE034223-9D30-4F03-A63E-DE1A7611DB52}.Release|x86.Build.0 = Release|Any CPU {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Debug|x64.ActiveCfg = Debug|Any CPU - {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Debug|x64.Build.0 = Debug|Any CPU - {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Debug|x86.ActiveCfg = Debug|Any CPU - {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Debug|x86.Build.0 = Debug|Any CPU {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Release|Any CPU.Build.0 = Release|Any CPU - {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Release|x64.ActiveCfg = Release|Any CPU - {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Release|x64.Build.0 = Release|Any CPU - {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Release|x86.ActiveCfg = Release|Any CPU - {93BB1DA5-64F7-4803-8D9E-C5E0CF2EA3AE}.Release|x86.Build.0 = Release|Any CPU {6594608C-854F-436B-8B5B-4FF223A57C8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6594608C-854F-436B-8B5B-4FF223A57C8B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6594608C-854F-436B-8B5B-4FF223A57C8B}.Debug|x64.ActiveCfg = Debug|Any CPU - {6594608C-854F-436B-8B5B-4FF223A57C8B}.Debug|x64.Build.0 = Debug|Any CPU - {6594608C-854F-436B-8B5B-4FF223A57C8B}.Debug|x86.ActiveCfg = Debug|Any CPU - {6594608C-854F-436B-8B5B-4FF223A57C8B}.Debug|x86.Build.0 = Debug|Any CPU {6594608C-854F-436B-8B5B-4FF223A57C8B}.Release|Any CPU.ActiveCfg = Release|Any CPU {6594608C-854F-436B-8B5B-4FF223A57C8B}.Release|Any CPU.Build.0 = Release|Any CPU - {6594608C-854F-436B-8B5B-4FF223A57C8B}.Release|x64.ActiveCfg = Release|Any CPU - {6594608C-854F-436B-8B5B-4FF223A57C8B}.Release|x64.Build.0 = Release|Any CPU - {6594608C-854F-436B-8B5B-4FF223A57C8B}.Release|x86.ActiveCfg = Release|Any CPU - {6594608C-854F-436B-8B5B-4FF223A57C8B}.Release|x86.Build.0 = Release|Any CPU {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Debug|x64.ActiveCfg = Debug|Any CPU - {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Debug|x64.Build.0 = Debug|Any CPU - {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Debug|x86.ActiveCfg = Debug|Any CPU - {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Debug|x86.Build.0 = Debug|Any CPU {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Release|Any CPU.ActiveCfg = Release|Any CPU {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Release|Any CPU.Build.0 = Release|Any CPU - {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Release|x64.ActiveCfg = Release|Any CPU - {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Release|x64.Build.0 = Release|Any CPU - {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Release|x86.ActiveCfg = Release|Any CPU - {54A18D7C-1CCA-45E1-BA39-5DA88E4155DE}.Release|x86.Build.0 = Release|Any CPU {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Debug|Any CPU.Build.0 = Debug|Any CPU - {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Debug|x64.ActiveCfg = Debug|Any CPU - {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Debug|x64.Build.0 = Debug|Any CPU - {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Debug|x86.ActiveCfg = Debug|Any CPU - {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Debug|x86.Build.0 = Debug|Any CPU {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Release|Any CPU.ActiveCfg = Release|Any CPU {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Release|Any CPU.Build.0 = Release|Any CPU - {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Release|x64.ActiveCfg = Release|Any CPU - {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Release|x64.Build.0 = Release|Any CPU - {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Release|x86.ActiveCfg = Release|Any CPU - {284367AF-6D9E-4D65-BB33-3C9F53DFC216}.Release|x86.Build.0 = Release|Any CPU {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Debug|x64.ActiveCfg = Debug|Any CPU - {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Debug|x64.Build.0 = Debug|Any CPU - {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Debug|x86.ActiveCfg = Debug|Any CPU - {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Debug|x86.Build.0 = Debug|Any CPU {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Release|Any CPU.Build.0 = Release|Any CPU - {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Release|x64.ActiveCfg = Release|Any CPU - {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Release|x64.Build.0 = Release|Any CPU - {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Release|x86.ActiveCfg = Release|Any CPU - {A5402D97-54ED-DAA6-91F5-FD820D0C463C}.Release|x86.Build.0 = Release|Any CPU {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Debug|x64.ActiveCfg = Debug|Any CPU - {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Debug|x64.Build.0 = Debug|Any CPU - {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Debug|x86.ActiveCfg = Debug|Any CPU - {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Debug|x86.Build.0 = Debug|Any CPU {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Release|Any CPU.ActiveCfg = Release|Any CPU {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Release|Any CPU.Build.0 = Release|Any CPU - {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Release|x64.ActiveCfg = Release|Any CPU - {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Release|x64.Build.0 = Release|Any CPU - {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Release|x86.ActiveCfg = Release|Any CPU - {6641DEF6-5149-EC0E-1612-9CADB4E023D8}.Release|x86.Build.0 = Release|Any CPU {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Debug|x64.ActiveCfg = Debug|Any CPU - {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Debug|x64.Build.0 = Debug|Any CPU - {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Debug|x86.ActiveCfg = Debug|Any CPU - {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Debug|x86.Build.0 = Debug|Any CPU {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Release|Any CPU.Build.0 = Release|Any CPU - {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Release|x64.ActiveCfg = Release|Any CPU - {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Release|x64.Build.0 = Release|Any CPU - {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Release|x86.ActiveCfg = Release|Any CPU - {A0B5D0C3-B9FC-45C1-2AFA-7933EA9C80FC}.Release|x86.Build.0 = Release|Any CPU {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Debug|x64.ActiveCfg = Debug|Any CPU - {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Debug|x64.Build.0 = Debug|Any CPU - {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Debug|x86.ActiveCfg = Debug|Any CPU - {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Debug|x86.Build.0 = Debug|Any CPU {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Release|Any CPU.ActiveCfg = Release|Any CPU {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Release|Any CPU.Build.0 = Release|Any CPU - {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Release|x64.ActiveCfg = Release|Any CPU - {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Release|x64.Build.0 = Release|Any CPU - {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Release|x86.ActiveCfg = Release|Any CPU - {1E26DFCF-5E99-5AA2-DE85-0CE07D435DE4}.Release|x86.Build.0 = Release|Any CPU {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Debug|x64.ActiveCfg = Debug|Any CPU - {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Debug|x64.Build.0 = Debug|Any CPU - {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Debug|x86.ActiveCfg = Debug|Any CPU - {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Debug|x86.Build.0 = Debug|Any CPU {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Release|Any CPU.ActiveCfg = Release|Any CPU {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Release|Any CPU.Build.0 = Release|Any CPU - {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Release|x64.ActiveCfg = Release|Any CPU - {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Release|x64.Build.0 = Release|Any CPU - {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Release|x86.ActiveCfg = Release|Any CPU - {616A0E6E-1EF1-E084-7B5B-FB8550FC5D2B}.Release|x86.Build.0 = Release|Any CPU {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Debug|Any CPU.Build.0 = Debug|Any CPU - {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Debug|x64.ActiveCfg = Debug|Any CPU - {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Debug|x64.Build.0 = Debug|Any CPU - {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Debug|x86.ActiveCfg = Debug|Any CPU - {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Debug|x86.Build.0 = Debug|Any CPU {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Release|Any CPU.ActiveCfg = Release|Any CPU {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Release|Any CPU.Build.0 = Release|Any CPU - {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Release|x64.ActiveCfg = Release|Any CPU - {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Release|x64.Build.0 = Release|Any CPU - {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Release|x86.ActiveCfg = Release|Any CPU - {78190D3E-4EE1-4C41-72A9-E7A7FBFA5767}.Release|x86.Build.0 = Release|Any CPU {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Debug|x64.ActiveCfg = Debug|Any CPU - {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Debug|x64.Build.0 = Debug|Any CPU - {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Debug|x86.ActiveCfg = Debug|Any CPU - {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Debug|x86.Build.0 = Debug|Any CPU {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Release|Any CPU.ActiveCfg = Release|Any CPU {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Release|Any CPU.Build.0 = Release|Any CPU - {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Release|x64.ActiveCfg = Release|Any CPU - {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Release|x64.Build.0 = Release|Any CPU - {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Release|x86.ActiveCfg = Release|Any CPU - {BA24379C-40D5-5EDF-63BE-CE5BC727E45D}.Release|x86.Build.0 = Release|Any CPU {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Debug|x64.ActiveCfg = Debug|Any CPU - {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Debug|x64.Build.0 = Debug|Any CPU - {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Debug|x86.ActiveCfg = Debug|Any CPU - {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Debug|x86.Build.0 = Debug|Any CPU {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Release|Any CPU.ActiveCfg = Release|Any CPU {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Release|Any CPU.Build.0 = Release|Any CPU - {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Release|x64.ActiveCfg = Release|Any CPU - {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Release|x64.Build.0 = Release|Any CPU - {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Release|x86.ActiveCfg = Release|Any CPU - {EFCFB571-6B0C-35CD-6664-160CA5B39244}.Release|x86.Build.0 = Release|Any CPU {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Debug|x64.ActiveCfg = Debug|Any CPU - {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Debug|x64.Build.0 = Debug|Any CPU - {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Debug|x86.ActiveCfg = Debug|Any CPU - {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Debug|x86.Build.0 = Debug|Any CPU {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Release|Any CPU.ActiveCfg = Release|Any CPU {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Release|Any CPU.Build.0 = Release|Any CPU - {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Release|x64.ActiveCfg = Release|Any CPU - {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Release|x64.Build.0 = Release|Any CPU - {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Release|x86.ActiveCfg = Release|Any CPU - {6B629CEE-5AAC-4885-89C6-7BED9DA7CF2C}.Release|x86.Build.0 = Release|Any CPU {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Debug|x64.ActiveCfg = Debug|Any CPU - {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Debug|x64.Build.0 = Debug|Any CPU - {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Debug|x86.ActiveCfg = Debug|Any CPU - {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Debug|x86.Build.0 = Debug|Any CPU {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Release|Any CPU.ActiveCfg = Release|Any CPU {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Release|Any CPU.Build.0 = Release|Any CPU - {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Release|x64.ActiveCfg = Release|Any CPU - {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Release|x64.Build.0 = Release|Any CPU - {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Release|x86.ActiveCfg = Release|Any CPU - {677B59E7-C4BA-4024-84D7-78CE6985F3F5}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 440beec371f374a9c82bed1cf5ebb4b8e736b5af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tero=20Kilpel=C3=A4inen?= Date: Mon, 30 Jun 2025 14:58:55 +0300 Subject: [PATCH 5/6] Refactor ManifestPrompter to prompt for contact details and optional fields --- .../ManifestPrompter.cs | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/SharpSite.PluginPacker/ManifestPrompter.cs b/src/SharpSite.PluginPacker/ManifestPrompter.cs index b647af8..6ae49b4 100644 --- a/src/SharpSite.PluginPacker/ManifestPrompter.cs +++ b/src/SharpSite.PluginPacker/ManifestPrompter.cs @@ -28,13 +28,21 @@ public static PluginManifest PromptForManifest() var published = PromptRequired("Published (yyyy-MM-dd)"); var supportedVersions = PromptRequired("SupportedVersions"); var author = PromptRequired("Author"); + var contact = PromptRequired("Contact"); + var contactEmail = PromptRequired("ContactEmail"); + var authorWebsite = PromptRequired("AuthorWebsite"); + // Optional fields - Console.Write("Contact: "); - var contact = (Console.ReadLine() ?? "").Trim(); - Console.Write("ContactEmail: "); - var contactEmail = (Console.ReadLine() ?? "").Trim(); - Console.Write("AuthorWebsite: "); - var authorWebsite = (Console.ReadLine() ?? "").Trim(); + Console.Write("Icon (URL): "); + var icon = (Console.ReadLine() ?? "").Trim(); + Console.Write("Source (repository URL): "); + var source = (Console.ReadLine() ?? "").Trim(); + Console.Write("KnownLicense (e.g. MIT, Apache, LGPL): "); + var knownLicense = (Console.ReadLine() ?? "").Trim(); + Console.Write("Tags (comma separated): "); + var tagsStr = (Console.ReadLine() ?? "").Trim(); + var tags = tagsStr.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + Console.Write("Features (comma separated, e.g. Theme,FileStorage): "); var featuresStr = (Console.ReadLine() ?? "").Trim(); var features = featuresStr.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); @@ -45,12 +53,16 @@ public static PluginManifest PromptForManifest() DisplayName = displayName, Description = description, Version = version, + Icon = string.IsNullOrWhiteSpace(icon) ? null : icon, Published = published, SupportedVersions = supportedVersions, Author = author, Contact = contact, ContactEmail = contactEmail, AuthorWebsite = authorWebsite, + Source = string.IsNullOrWhiteSpace(source) ? null : source, + KnownLicense = string.IsNullOrWhiteSpace(knownLicense) ? null : knownLicense, + Tags = tags.Length > 0 ? tags : null, Features = featureEnums }; } From 9a90cc266d550063c5523836cc477cec89f0df60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tero=20Kilpel=C3=A4inen?= Date: Tue, 1 Jul 2025 10:11:30 +0300 Subject: [PATCH 6/6] Enhance output path handling and improve usage instructions in Program.cs --- src/SharpSite.PluginPacker/PluginPackager.cs | 14 ++++++++++---- src/SharpSite.PluginPacker/Program.cs | 14 +++++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/SharpSite.PluginPacker/PluginPackager.cs b/src/SharpSite.PluginPacker/PluginPackager.cs index a76f08d..b08ad36 100644 --- a/src/SharpSite.PluginPacker/PluginPackager.cs +++ b/src/SharpSite.PluginPacker/PluginPackager.cs @@ -41,12 +41,18 @@ public static bool PackagePlugin(string inputPath, string outputPath) { CopyThemeCssFiles(inputPath, tempDir); } - // Copy manifest.json and other required files CopyRequiredFiles(inputPath, tempDir); + // Zip tempDir to outputPath - use proper naming convention ID@VERSION.sspkg + // outputPath is always a directory, generate the filename from manifest + string outFile = Path.Combine(outputPath, $"{manifest.IdVersionToString()}.sspkg"); + + // Ensure the output directory exists + if (!Directory.Exists(outputPath)) + { + Directory.CreateDirectory(outputPath); + } - // Zip tempDir to outputPath - string outFile = outputPath.EndsWith(".sspkg", StringComparison.OrdinalIgnoreCase) ? outputPath : outputPath + ".sspkg"; if (File.Exists(outFile)) File.Delete(outFile); ZipFile.CreateFromDirectory(tempDir, outFile); Console.WriteLine($"Plugin packaged successfully: {outFile}"); @@ -65,7 +71,7 @@ public static bool PackagePlugin(string inputPath, string outputPath) } } - private static void CopyAndRenameDll(string inputPath, string tempBuildDir, string tempDir, dynamic manifest) + private static void CopyAndRenameDll(string inputPath, string tempBuildDir, string tempDir, PluginManifest manifest) { string libDir = Path.Combine(tempDir, "lib"); Directory.CreateDirectory(libDir); diff --git a/src/SharpSite.PluginPacker/Program.cs b/src/SharpSite.PluginPacker/Program.cs index 74081cd..6e6d78d 100644 --- a/src/SharpSite.PluginPacker/Program.cs +++ b/src/SharpSite.PluginPacker/Program.cs @@ -2,21 +2,29 @@ (string? inputPath, string? outputPath) = ArgumentParser.ParseArguments(args); -if (string.IsNullOrWhiteSpace(inputPath) || string.IsNullOrWhiteSpace(outputPath)) +if (string.IsNullOrWhiteSpace(inputPath)) { - Console.WriteLine("Usage: SharpSite.PluginPacker -i -o "); + Console.WriteLine("Usage: SharpSite.PluginPacker -i [-o ]"); + Console.WriteLine(" -i, --input Input folder containing the plugin project"); + Console.WriteLine(" -o, --output Output directory (optional, defaults to current directory)"); + Console.WriteLine(); + Console.WriteLine("The output filename will be automatically generated as: ID@VERSION.sspkg"); return 1; } +// Default to current directory if no output path specified +outputPath = string.IsNullOrWhiteSpace(outputPath) ? Directory.GetCurrentDirectory() : outputPath; + if (!Directory.Exists(inputPath)) { Console.WriteLine($"Input directory '{inputPath}' does not exist."); return 1; } +// Validate that output path is a directory, not a file if (File.Exists(outputPath)) { - Console.WriteLine($"Output file '{outputPath}' already exists. Please choose a different output path."); + Console.WriteLine($"Error: Output path '{outputPath}' points to a file. Please specify a directory."); return 1; }