diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index 041581b..51aca82 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -14,9 +14,9 @@ jobs: steps: - uses: actions/checkout@v2 - name: Setup .NET Core - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 3.1.301 + dotnet-version: 8.0.x - name: Build run: | cd src @@ -29,20 +29,20 @@ jobs: dotnet publish -c Release --no-restore -r linux-x64 -p:PublishTrimmed=true --self-contained -o linuxx64 dotnet publish -c Release --no-restore -r win-x64 -p:PublishTrimmed=true --self-contained -o winx64 dotnet pack -c Release --include-source --include-symbols -o toolpack - - uses: actions/upload-artifact@v2 - with: - name: winx64 - path: src/SideCarCLI/SideCarCLI/winx64/ + # - uses: actions/upload-artifact@v2 + # with: + # name: winx64 + # path: src/SideCarCLI/SideCarCLI/winx64/ - - uses: actions/upload-artifact@v2 - with: - name: linuxx64 - path: src/SideCarCLI/SideCarCLI/linuxx64/ + # - uses: actions/upload-artifact@v2 + # with: + # name: linuxx64 + # path: src/SideCarCLI/SideCarCLI/linuxx64/ - - uses: actions/upload-artifact@v2 - with: - name: dotnetTool - path: src/SideCarCLI/SideCarCLI/toolpack/ + # - uses: actions/upload-artifact@v2 + # with: + # name: dotnetTool + # path: src/SideCarCLI/SideCarCLI/toolpack/ #- name: Test # run: dotnet test --no-restore --verbosity normal diff --git a/src/SideCarCLI/SC_Interfaces/IRunWatcher.cs b/src/SideCarCLI/SC_Interfaces/IRunWatcher.cs new file mode 100644 index 0000000..d03f485 --- /dev/null +++ b/src/SideCarCLI/SC_Interfaces/IRunWatcher.cs @@ -0,0 +1,24 @@ +namespace SC_Interfaces; +public interface IRunWatcherDetect +{ + public string Folder { get; set; } + public IRunWatcher[] DetectVersions(); +} + +public interface IRunWatcher +{ + public int Version { get; } + public Task Run(string[] args); + +} + +public interface IRunWatcherV1: IRunWatcher +{ + public int DelaySeconds { get; set; } + +} + +public interface IRunWatcherFile +{ + public Version DetectFile(); +} \ No newline at end of file diff --git a/src/SideCarCLI/SC_Interfaces/SC_Interfaces.csproj b/src/SideCarCLI/SC_Interfaces/SC_Interfaces.csproj new file mode 100644 index 0000000..fa71b7a --- /dev/null +++ b/src/SideCarCLI/SC_Interfaces/SC_Interfaces.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/src/SideCarCLI/SC_Tool/Program.cs b/src/SideCarCLI/SC_Tool/Program.cs new file mode 100644 index 0000000..1d77762 --- /dev/null +++ b/src/SideCarCLI/SC_Tool/Program.cs @@ -0,0 +1,32 @@ +using Microsoft.Extensions.Logging.Abstractions; + +public class Program +{ + public static async Task Main(string[] args) + { + var services = CreateServices(); + var watcher = services.GetRequiredService(); + ArgumentNullException.ThrowIfNull(watcher, nameof(watcher)); + watcher.Folder = Environment.CurrentDirectory; + var logger= services.GetRequiredService>(); + var versions = await watcher.DetectVersions(); + if (versions.Length == 0) + { + logger.LogError("No versions detected"); + throw new InvalidOperationException("No versions detected"); + } + var lastVersion = versions.OrderByDescending(v => v.Version).First(); + logger.LogInformation($"Running version {lastVersion.Version}"); + return await lastVersion.Run(args); + + } + private static ServiceProvider CreateServices() + { + var serviceProvider = new ServiceCollection() + //.AddSingleton((IRunWatcher)null) + //.AddSingleton(new NullLogger()) + .BuildServiceProvider(); + + return serviceProvider; + } +} \ No newline at end of file diff --git a/src/SideCarCLI/SC_Tool/SC_Tool.csproj b/src/SideCarCLI/SC_Tool/SC_Tool.csproj new file mode 100644 index 0000000..18b3e81 --- /dev/null +++ b/src/SideCarCLI/SC_Tool/SC_Tool.csproj @@ -0,0 +1,21 @@ + + + + Exe + net8.0 + enable + enable + true + true + + + + + + + + + + + + diff --git a/src/SideCarCLI/SC_Tool/globals.cs b/src/SideCarCLI/SC_Tool/globals.cs new file mode 100644 index 0000000..337fb28 --- /dev/null +++ b/src/SideCarCLI/SC_Tool/globals.cs @@ -0,0 +1,4 @@ +global using SC_Interfaces; +global using Microsoft.Extensions.DependencyInjection; +global using System; +global using Microsoft.Extensions.Logging; \ No newline at end of file diff --git a/src/SideCarCLI/SideCarCLI.sln b/src/SideCarCLI/SideCarCLI.sln index bbc7f01..e6bfd52 100644 --- a/src/SideCarCLI/SideCarCLI.sln +++ b/src/SideCarCLI/SideCarCLI.sln @@ -1,9 +1,13 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30523.141 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35327.3 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SideCarCLI", "SideCarCLI\SideCarCLI.csproj", "{8D1D2CEC-3F82-4691-BDF1-981C999E2653}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SideCarCLI", "SideCarCLI\SideCarCLI.csproj", "{8D1D2CEC-3F82-4691-BDF1-981C999E2653}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SC_Interfaces", "SC_Interfaces\SC_Interfaces.csproj", "{12DDD1BC-9605-4384-9964-93410668CA98}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SC_Tool", "SC_Tool\SC_Tool.csproj", "{652096DC-5CF1-4263-A947-9A2A82B0C966}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +19,14 @@ Global {8D1D2CEC-3F82-4691-BDF1-981C999E2653}.Debug|Any CPU.Build.0 = Debug|Any CPU {8D1D2CEC-3F82-4691-BDF1-981C999E2653}.Release|Any CPU.ActiveCfg = Release|Any CPU {8D1D2CEC-3F82-4691-BDF1-981C999E2653}.Release|Any CPU.Build.0 = Release|Any CPU + {12DDD1BC-9605-4384-9964-93410668CA98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {12DDD1BC-9605-4384-9964-93410668CA98}.Debug|Any CPU.Build.0 = Debug|Any CPU + {12DDD1BC-9605-4384-9964-93410668CA98}.Release|Any CPU.ActiveCfg = Release|Any CPU + {12DDD1BC-9605-4384-9964-93410668CA98}.Release|Any CPU.Build.0 = Release|Any CPU + {652096DC-5CF1-4263-A947-9A2A82B0C966}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {652096DC-5CF1-4263-A947-9A2A82B0C966}.Debug|Any CPU.Build.0 = Debug|Any CPU + {652096DC-5CF1-4263-A947-9A2A82B0C966}.Release|Any CPU.ActiveCfg = Release|Any CPU + {652096DC-5CF1-4263-A947-9A2A82B0C966}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/SideCarCLI/SideCarCLI/SideCarCLI.csproj b/src/SideCarCLI/SideCarCLI/SideCarCLI.csproj index 7ed358b..f9444ed 100644 --- a/src/SideCarCLI/SideCarCLI/SideCarCLI.csproj +++ b/src/SideCarCLI/SideCarCLI/SideCarCLI.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net8.0 win-x64;linux-x64 true sidecarcli