diff --git a/.gitignore b/.gitignore index e50b430..fa923ea 100644 --- a/.gitignore +++ b/.gitignore @@ -237,4 +237,6 @@ pip-log.txt ########## # Rider ########## -.idea/ \ No newline at end of file +.idea/ + +artifacts/ diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index cd3664f..74d44fe 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -72,6 +72,7 @@ "items": { "type": "string", "enum": [ + "CleanGenerated", "CopyConfig", "RestoreTools", "Run" @@ -88,6 +89,7 @@ "items": { "type": "string", "enum": [ + "CleanGenerated", "CopyConfig", "RestoreTools", "Run" diff --git a/nuke/Generate.cs b/nuke/Generate.cs index 16bb80d..2d50100 100644 --- a/nuke/Generate.cs +++ b/nuke/Generate.cs @@ -1,4 +1,6 @@ +using System; using System.IO; +using System.Linq; using Nuke.Common; using Nuke.Common.ProjectModel; using Nuke.Common.Tools.DotNet; @@ -6,6 +8,15 @@ using Serilog; public class Generate : NukeBuild { + static string[] IgnoreFiles = + [ + ".editorconfig", + "kiota-lock.json", + "kiota-lock-stable.json", + "kiota-lock-unstable.json" + ]; + + public static int Main () => Execute(x => x.Run); [Parameter("Configuration to build - 'Stable' (default) or 'Unstable'")] @@ -15,9 +26,29 @@ public class Generate : NukeBuild readonly Solution Solution; Target RestoreTools => g => g.Executes(() => DotNetTasks.DotNetToolRestore()); + + Target CleanGenerated => g => g.Executes(() => + { + var generatedDirectory = new DirectoryInfo(Path.Combine(Solution.Jellyfin_Sdk.Directory, "Generated")); + + foreach (var file in generatedDirectory.GetFiles()) + { + if (IgnoreFiles.Contains(file.Name, StringComparer.OrdinalIgnoreCase)) + { + continue; + } + + file.Delete(); + } + + foreach (var directory in generatedDirectory.GetDirectories()) + { + directory.Delete(recursive: true); + } + }); Target CopyConfig => g => g - .DependsOn(RestoreTools) + .DependsOn(RestoreTools, CleanGenerated) .Executes(() => { var sourceFile = Configuration == Configuration.Stable diff --git a/src/Jellyfin.Sdk.sln b/src/Jellyfin.Sdk.sln index 289447a..3efc792 100644 --- a/src/Jellyfin.Sdk.sln +++ b/src/Jellyfin.Sdk.sln @@ -6,6 +6,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{78BA EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Simple", "..\samples\Simple\Simple.csproj", "{7BBC005F-06BE-4CDB-9E64-C4AA54CAE667}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_nuke", "..\nuke\_nuke.csproj", "{7CB9B852-FD55-4BD1-B7D6-C7C9300CB31E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU