diff --git a/.gitignore b/.gitignore index bc6c934..4495b22 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +appsettings.json + + # ---> VisualStudioCode .vscode/* !.vscode/settings.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..ce279f1 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/deploy-test/bin/Debug/net8.0/deploy-test.dll", + "args": [], + "cwd": "${workspaceFolder}/deploy-test", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..05a2991 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/deploy-test/deploy-test.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/deploy-test/deploy-test.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/deploy-test/deploy-test.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Deployment/Configuration.cs b/Deployment/Configuration.cs new file mode 100644 index 0000000..a2a2a14 --- /dev/null +++ b/Deployment/Configuration.cs @@ -0,0 +1,23 @@ +using System; +using Newtonsoft.Json; + +namespace Deployment; + +public static class ConfigurationBootstrapper +{ + private const string confpath = "appsettings.json"; + + public static T Load() where T : new() + { + if(File.Exists("appsettings.json")) + { + return JsonConvert.DeserializeObject(File.ReadAllText(confpath)) ?? new T(); + } + else + { + var toReturn = new T(); + File.WriteAllText(confpath, JsonConvert.SerializeObject(toReturn)); + return toReturn; + } + } +} diff --git a/Deployment/Deployment.csproj b/Deployment/Deployment.csproj new file mode 100644 index 0000000..a9f8edf --- /dev/null +++ b/Deployment/Deployment.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/deploy-test/Config.cs b/deploy-test/Config.cs new file mode 100644 index 0000000..932f501 --- /dev/null +++ b/deploy-test/Config.cs @@ -0,0 +1,8 @@ +namespace deploy_test; +using Deployment; + +public class Config +{ + public string imavalue { get; set; } = "ask me anything"; + +} diff --git a/deploy-test/Program.cs b/deploy-test/Program.cs new file mode 100644 index 0000000..684320e --- /dev/null +++ b/deploy-test/Program.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Net; +using Deployment; + +namespace deploy_test; + +class Program +{ + static void Main(string[] args) + { + var c = ConfigurationBootstrapper.Load(); + Console.WriteLine(c.imavalue); + + } +} diff --git a/deploy-test/deploy-test.csproj b/deploy-test/deploy-test.csproj new file mode 100644 index 0000000..e000832 --- /dev/null +++ b/deploy-test/deploy-test.csproj @@ -0,0 +1,16 @@ + + + + + + + + + Exe + net8.0 + deploy_test + enable + enable + + +