Skip to content

Commit 6c40167

Browse files
committed
Added option to skip updating a nuget package based on the name in config
1 parent 19db3c5 commit 6c40167

File tree

8 files changed

+22
-4
lines changed

8 files changed

+22
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ Below is a list of the required and optional propeties for the Update Options JS
114114
- Boolean. True to updates all referenced nugets to the latest version. These are the references in the csproj files.
115115
- UpdateTopLevelNugetsNotInCsProj
116116
- Boolean. True to updates all indirect nugets to the latest version. These are the nugets that are referenced automatically based on SDK chosen or something like that.
117+
- PackagesToSkip
118+
- Names of NuGet packages to skip when upgrading. They will not be upgraded.
117119
- NpmOptions
118120
- Optional
119121
- Options for updating Npm packages. If this is not set, NPM packages will not be updated

UpdateOptionsSchema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@
9595
"updateTopLevelNugetsNotInCsProj": {
9696
"description": "True to updates all indirect nugets to the latest version. These are the nugets that are referenced automatically based on SDK chosen or something like that.",
9797
"type": "boolean"
98+
},
99+
"packagesToSkip": {
100+
"description": "Names of NuGet packages to skip when upgrading. They will not be upgraded",
101+
"type": "array"
98102
}
99103
}
100104
}

code-update-runner-sample/code-updater-config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
},
3232
"updateOptions": {
3333
"updateTopLevelNugetsInCsProj": true,
34-
"updateTopLevelNugetsNotInCsProj": true
34+
"updateTopLevelNugetsNotInCsProj": true,
35+
"packagesToSkip": [ "Serilog" ]
3536
}
3637
}
3738
},

src/CodeUpdater/CodeUpdater/CodeUpdater.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
</PropertyGroup>
2727
<ItemGroup>
2828
<PackageReference Include="CommandLineParser" Version="2.9.1" />
29-
<PackageReference Include="ProgrammerAl.SourceGenerators.PublicInterfaceGenerator" Version="1.0.0.62" PrivateAssets="all" />
29+
<PackageReference Include="ProgrammerAl.SourceGenerators.PublicInterfaceGenerator" Version="1.5.2.121" PrivateAssets="all" />
3030
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
31-
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
31+
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
3232
</ItemGroup>
3333
<ItemGroup>
3434
<!--Include the ReadMe in the nuget package-->

src/CodeUpdater/CodeUpdater/Options/UpdateOptions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
using System.Collections.Immutable;
23
using System.ComponentModel.DataAnnotations;
34

45
namespace ProgrammerAL.Tools.CodeUpdater;
@@ -184,6 +185,12 @@ public class NuGetUpdateOptions
184185
/// </summary>
185186
[Required]
186187
public bool UpdateTopLevelNugetsNotInCsProj { get; set; }
188+
189+
/// <summary>
190+
/// Names of NuGet packages to skip when upgrading. They will not be upgraded
191+
/// </summary>
192+
[Required]
193+
public ImmutableArray<string> PackagesToSkip { get; set; } = [];
187194
}
188195

189196
public class LoggingOptions

src/CodeUpdater/CodeUpdater/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ await Parser.Default.ParseArguments<CommandOptions>(args)
2121

2222
static async ValueTask RunAsync(CommandOptions commandOptions)
2323
{
24+
var runDir = "D:\\GitHub\\Purple-Spike\\arcade-machine-local-services";
25+
Directory.SetCurrentDirectory(runDir);
26+
2427
var updateOptions = await LoadUpdateOptionsAsync(commandOptions.OptionsFile);
2528
var logger = SetupLogger(updateOptions);
2629

src/CodeUpdater/CodeUpdater/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"CodeUpdater": {
44
"commandName": "Project",
5-
"commandLineArgs": "--options \"../../../sampleUpdateOptions.json"
5+
"commandLineArgs": "--options D:\\GitHub\\Purple-Spike\\arcade-machine-local-services\\code-updater\\code-updater-config.json"
66
}
77
}
88
}

src/CodeUpdater/CodeUpdater/Updaters/NugetUpdater.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public async ValueTask<NugetUpdateResults> UpdateNugetPackagesAsync(string csPro
3333
?.SelectMany(x => x?.TopLevelPackages ?? [])
3434
.Where(x => x is object && !string.IsNullOrWhiteSpace(x.Id))
3535
.Select(x => new NugetPackageToUpdate(Id: x!.Id!))
36+
.Where(x => nuGetUpdates.PackagesToSkip.All(toSkip => !string.Equals(x.Id, toSkip, StringComparison.OrdinalIgnoreCase)))
3637
.ToImmutableArray() ?? [];
3738

3839
var topLevelPackagesInCsProj = packages.Where(x => csProjText.Contains($"Include=\"{x.Id}\"", StringComparison.OrdinalIgnoreCase))

0 commit comments

Comments
 (0)