actual initial - library project, test project, Configuration

This commit is contained in:
adam 2024-10-16 17:12:38 -04:00
parent 997ca57962
commit f04df031cb
8 changed files with 146 additions and 0 deletions

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
appsettings.json
# ---> VisualStudioCode # ---> VisualStudioCode
.vscode/* .vscode/*
!.vscode/settings.json !.vscode/settings.json

26
.vscode/launch.json vendored Normal file
View File

@ -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"
}
]
}

41
.vscode/tasks.json vendored Normal file
View File

@ -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"
}
]
}

View File

@ -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<T>() where T : new()
{
if(File.Exists("appsettings.json"))
{
return JsonConvert.DeserializeObject<T>(File.ReadAllText(confpath)) ?? new T();
}
else
{
var toReturn = new T();
File.WriteAllText(confpath, JsonConvert.SerializeObject(toReturn));
return toReturn;
}
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="newtonsoft.json" Version="13.0.3" />
</ItemGroup>
</Project>

8
deploy-test/Config.cs Normal file
View File

@ -0,0 +1,8 @@
namespace deploy_test;
using Deployment;
public class Config
{
public string imavalue { get; set; } = "ask me anything";
}

16
deploy-test/Program.cs Normal file
View File

@ -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<Config>();
Console.WriteLine(c.imavalue);
}
}

View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\Deployment\Deployment.csproj" />
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>deploy_test</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>