fix cleanup

This commit is contained in:
Cody Robibero 2024-02-22 12:22:04 -07:00
parent eca148f037
commit 6e766cc331
4 changed files with 39 additions and 2 deletions

4
.gitignore vendored
View File

@ -237,4 +237,6 @@ pip-log.txt
##########
# Rider
##########
.idea/
.idea/
artifacts/

View File

@ -72,6 +72,7 @@
"items": {
"type": "string",
"enum": [
"CleanGenerated",
"CopyConfig",
"RestoreTools",
"Run"
@ -88,6 +89,7 @@
"items": {
"type": "string",
"enum": [
"CleanGenerated",
"CopyConfig",
"RestoreTools",
"Run"

View File

@ -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<Generate>(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

View File

@ -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