From 493cfd34368a6b2659c4c1bd565c141448b39b98 Mon Sep 17 00:00:00 2001 From: Toastie Date: Tue, 29 Oct 2024 22:25:03 +1300 Subject: [PATCH] Switched to modern resources, some refactor of project and jenkins files --- Config.cs | 4 +- Jenkinsfile | 4 +- Properties/Resources.Designer.cs | 55 -------------- Properties/Resources.resx | 124 ------------------------------- SupportChild.csproj | 39 +++------- Utilities.cs | 19 +++++ 6 files changed, 34 insertions(+), 211 deletions(-) delete mode 100644 Properties/Resources.Designer.cs delete mode 100644 Properties/Resources.resx diff --git a/Config.cs b/Config.cs index 5137998..010fa3e 100644 --- a/Config.cs +++ b/Config.cs @@ -1,10 +1,8 @@ using System; using System.IO; -using System.Text; using DSharpPlus; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; -using SupportChild.Properties; using YamlDotNet.Serialization; namespace SupportChild; @@ -39,7 +37,7 @@ internal static class Config // Writes default config to file if it does not already exist if (!File.Exists("./config.yml")) { - File.WriteAllText("./config.yml", Encoding.UTF8.GetString(Resources.default_config)); + File.WriteAllText("./config.yml", Utilities.ReadManifestData("default_config.yml")); } // Reads config contents into FileStream diff --git a/Jenkinsfile b/Jenkinsfile index 263f4a9..5dcf8ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,12 +10,12 @@ pipeline { parallel { stage('Linux') { steps { - sh 'dotnet publish -p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true -p:PublishTrimmed=true -r linux-x64 -c Release --self-contained true --no-restore --output Linux-x64/' + sh 'dotnet publish -r linux-x64 -c Release --self-contained true --no-restore --output Linux-x64/' } } stage('Windows') { steps { - sh 'dotnet publish -p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true -p:PublishTrimmed=true -r win-x64 -c Release --self-contained true --no-restore --output Windows-x64/' + sh 'dotnet publish -r win-x64 -c Release --self-contained true --no-restore --output Windows-x64/' } } } diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs deleted file mode 100644 index 8cdb657..0000000 --- a/Properties/Resources.Designer.cs +++ /dev/null @@ -1,55 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace SupportChild.Properties { - using System; - - - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SupportChild.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - internal static byte[] default_config { - get { - object obj = ResourceManager.GetObject("default_config", resourceCulture); - return ((byte[])(obj)); - } - } - } -} diff --git a/Properties/Resources.resx b/Properties/Resources.resx deleted file mode 100644 index 8edc7ae..0000000 --- a/Properties/Resources.resx +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - ..\default_config.yml;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SupportChild.csproj b/SupportChild.csproj index fcbb1f7..c5b55f2 100644 --- a/SupportChild.csproj +++ b/SupportChild.csproj @@ -2,24 +2,24 @@ Exe + 3.0.2.2 ellie_icon.ico net6.0 - win-x64;linux-x64 - SupportChild.SupportChild + win-x64;linux-x64 + true + partial + EmotionChild - - https://github.com/EmotionChild/SupportChild - https://github.com/EmotionChild/SupportChild - Git - LICENSE - https://cdn.discordapp.com/attachments/765441543100170271/914327948667011132/Ellie_Concept_2_transparent_ver.png A Discord support ticket bot built for the Ellie's home server en - 1.3.1 - 1.3.1 - 3.0.0.1 - 3.0.0.1 + Git + https://toastielab.dev/Emotions-stuff/SupportChild + + https://cdn.discordapp.com/attachments/765441543100170271/914327948667011132/Ellie_Concept_2_transparent_ver.png + LICENSE + https://toastielab.dev/Emotions-stuff/SupportChild + 3.0.2 @@ -41,13 +41,6 @@ - - - - ResXFileCodeGenerator - Resources.Designer.cs - - @@ -59,12 +52,4 @@ - - - True - True - Resources.resx - - - \ No newline at end of file diff --git a/Utilities.cs b/Utilities.cs index 64d6667..54686cc 100644 --- a/Utilities.cs +++ b/Utilities.cs @@ -1,5 +1,8 @@ using System; using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; using System.Threading.Tasks; using DSharpPlus.Entities; @@ -62,4 +65,20 @@ public static class Utilities } return verifiedCategories; } + + + public static string ReadManifestData(string embeddedFileName) + { + Assembly assembly = Assembly.GetExecutingAssembly(); + string resourceName = assembly.GetManifestResourceNames().First(s => s.EndsWith(embeddedFileName, StringComparison.CurrentCultureIgnoreCase)); + + using Stream stream = assembly.GetManifestResourceStream(resourceName); + if (stream == null) + { + throw new InvalidOperationException("Could not load manifest resource stream."); + } + + using StreamReader reader = new StreamReader(stream); + return reader.ReadToEnd(); + } } \ No newline at end of file