dependabot-nuget 0.373.0 → 0.374.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (18) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +1 -1
  3. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackageManagementKind.cs +23 -0
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +1 -1
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +12 -6
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/FileWriterWorker.cs +1 -2
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/IFileWriter.cs +3 -1
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/XmlFileWriter.cs +8 -1
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +1 -1
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +4 -8
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProcessExtensions.cs +15 -0
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +60 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +3 -3
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/MockNuGetPackage.cs +1 -1
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterTestsBase.cs +5 -6
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/TestFileWriterReturnsConstantResult.cs +2 -1
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/XmlFileWriterTests.cs +3 -2
  18. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed8631b7dbf0b7afe45ac609f37741c2baac7757d164bd02682de074a8dbf9a8
4
- data.tar.gz: 64b23850d13693a34fd1dbf990839e8aab0d71c4c05c5f100753d25740cd4cb3
3
+ metadata.gz: 44fba281ef6f7ae5edcc476e8c7776c0eb7f67f34c0fc88fd97a5b2bb0fd9ecd
4
+ data.tar.gz: 58769e2284c8cc3c71fa27ad89f5121985d5050afa2d8354359246507049025e
5
5
  SHA512:
6
- metadata.gz: 07e2ccca8cbfd5459b93cf3bde39eeed3e9d021fb99e184809a6b925d0699bda70dc5b41245bd32c2cac745aff8d45fc2868cf5989773c9f4dfb0344c6f2f4e5
7
- data.tar.gz: c983ddf3a66ab1d75ee33de6c4feefee4af2f3f34003e94b4546afa68979ac4c26668c72cf75fda1d2a66cb80365658b018cf14000b037c0ab32ad5124c77dd9
6
+ metadata.gz: 0343710df6bb80e64d5e19c48d02bbc78b930338516e5951e3909e622ea2bd692ece05dd89b884103ef86467d8cb29bd7dfdb5e4b17127c264040950e3ebf81e
7
+ data.tar.gz: de4e648b06eb7bd4a13a17fe544600bc7d4e5ea3477935e06941e378668fccdc60efceabe6b6c78e9c13da9fec8a69109eec00068a922559b92b8b5b1f9b472d
@@ -470,7 +470,7 @@ public partial class DiscoveryWorker : IDiscoveryWorker
470
470
  ReferencedProjectPaths = mergedReferencedProjects,
471
471
  ImportedFiles = mergedImportedFiles,
472
472
  AdditionalFiles = mergedAdditionalFiles,
473
- CentralPackageTransitivePinningEnabled = result1.CentralPackageTransitivePinningEnabled || result2.CentralPackageTransitivePinningEnabled,
473
+ PackageManagementKind = (PackageManagementKind)Math.Max((int)result1.PackageManagementKind, (int)result2.PackageManagementKind),
474
474
  };
475
475
  return mergedResult;
476
476
  }
@@ -0,0 +1,23 @@
1
+ namespace NuGetUpdater.Core.Discover;
2
+
3
+ public enum PackageManagementKind
4
+ {
5
+ /// <summary>
6
+ /// The default for SDK-style projects, e.g., <code>&lt;PackageReference Include="Some.Package" Version="1.0.0" /&gt;</code>
7
+ /// </summary>
8
+ Default,
9
+
10
+ /// <summary>
11
+ /// Separate <code>&lt;PackageReference&gt;</code> and <code>&lt;PackageVersion&gt;</code> elements. Set by the
12
+ /// user by adding the property <code>&lt;ManagePackageVersionsCentrally&gt;true&lt;/ManagePackageVersionsCentrally&gt;</code>
13
+ /// and commonly using the file <code>Directory.Packages.props</code>
14
+ /// </summary>
15
+ CentralPackageManagement,
16
+
17
+ /// <summary>
18
+ /// Similar to <see cref="CentralPackageManagement"/> but with the additional property
19
+ /// <code>&lt;CentralPackageTransitivePinningEnabled&gt;true&lt;/CentralPackageTransitivePinningEnabled&gt;</code> which applies
20
+ /// <code>&lt;PackageVersion&gt;</code> elements for all transitive dependencies as well.
21
+ /// </summary>
22
+ CentralPackageManagementWithTransitivePinning,
23
+ }
@@ -14,5 +14,5 @@ public record ProjectDiscoveryResult : IDiscoveryResultWithDependencies
14
14
  public ImmutableArray<string> ReferencedProjectPaths { get; init; } = [];
15
15
  public required ImmutableArray<string> ImportedFiles { get; init; }
16
16
  public required ImmutableArray<string> AdditionalFiles { get; init; }
17
- public bool CentralPackageTransitivePinningEnabled { get; init; } = false;
17
+ public PackageManagementKind PackageManagementKind { get; init; } = PackageManagementKind.Default;
18
18
  }
@@ -144,7 +144,7 @@ internal static class SdkProjectDiscovery
144
144
  try
145
145
  {
146
146
  // when using single restore, we can directly invoke the relevant targets...
147
- var args = new List<string>() { "msbuild", startingProjectPath };
147
+ var args = new List<string>() { startingProjectPath };
148
148
 
149
149
  // ...but determining what the relevant targets are can be complicated
150
150
 
@@ -195,7 +195,7 @@ internal static class SdkProjectDiscovery
195
195
  args.Add("/p:MSBuildTreatWarningsAsErrors=false");
196
196
  args.Add($"/bl:{binLogPath}");
197
197
 
198
- var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(args, startingProjectDirectory);
198
+ var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetMSBuildSafelyAsync(args, startingProjectDirectory);
199
199
  if (exitCode != 0 && stdOut.Contains("error : Object reference not set to an instance of an object."))
200
200
  {
201
201
  // https://github.com/NuGet/Home/issues/11761#issuecomment-1105218996
@@ -203,7 +203,7 @@ internal static class SdkProjectDiscovery
203
203
  // but this argument can't always be added; it can cause problems in other instances, so we're taking the approach of not using it
204
204
  // unless we have to.
205
205
  args.Add("/RestoreProperty:__Unused__=__Unused__");
206
- (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(args, startingProjectDirectory);
206
+ (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetMSBuildSafelyAsync(args, startingProjectDirectory);
207
207
  }
208
208
 
209
209
  MSBuildHelper.ThrowOnError(stdOut);
@@ -643,13 +643,19 @@ internal static class SdkProjectDiscovery
643
643
  .Select(p => p.NormalizePathToUnix())
644
644
  .OrderBy(p => p)
645
645
  .ToImmutableArray();
646
- var useCpmTransitivePinning =
646
+ var projectLevelCpm =
647
647
  projectProperties.TryGetValue("ManagePackageVersionsCentrally", out var useCpmString) &&
648
648
  bool.TryParse(useCpmString, out var useCpm) &&
649
- useCpm &&
649
+ useCpm;
650
+ var projectLevelCpmWithPinning =
651
+ projectLevelCpm &&
650
652
  projectProperties.TryGetValue("CentralPackageTransitivePinningEnabled", out var useTransitivePinningString) &&
651
653
  bool.TryParse(useTransitivePinningString, out var useTransitivePinning) &&
652
654
  useTransitivePinning;
655
+ var packageManagementKind =
656
+ projectLevelCpmWithPinning ? PackageManagementKind.CentralPackageManagementWithTransitivePinning :
657
+ projectLevelCpm ? PackageManagementKind.CentralPackageManagement :
658
+ PackageManagementKind.Default;
653
659
 
654
660
  var projectDiscoveryResult = new ProjectDiscoveryResult()
655
661
  {
@@ -659,7 +665,7 @@ internal static class SdkProjectDiscovery
659
665
  ReferencedProjectPaths = referenced,
660
666
  ImportedFiles = imported,
661
667
  AdditionalFiles = additional,
662
- CentralPackageTransitivePinningEnabled = useCpmTransitivePinning,
668
+ PackageManagementKind = packageManagementKind,
663
669
  };
664
670
  projectDiscoveryResults.Add(projectDiscoveryResult);
665
671
  }
@@ -408,8 +408,7 @@ public class FileWriterWorker
408
408
  .ToImmutableArray();
409
409
 
410
410
  // try update
411
- var addPackageReferenceElementForPinnedPackages = !projectDiscovery.CentralPackageTransitivePinningEnabled;
412
- var success = await fileWriter.UpdatePackageVersionsAsync(repoContentsPath, relativeFilePaths, projectDiscovery.Dependencies, requiredPackageVersions, addPackageReferenceElementForPinnedPackages);
411
+ var success = await fileWriter.UpdatePackageVersionsAsync(repoContentsPath, relativeFilePaths, projectDiscovery.Dependencies, requiredPackageVersions, projectDiscovery.PackageManagementKind);
413
412
  var updatedFiles = new List<string>();
414
413
  foreach (var (filePath, originalContents) in originalFileContents)
415
414
  {
@@ -1,5 +1,7 @@
1
1
  using System.Collections.Immutable;
2
2
 
3
+ using NuGetUpdater.Core.Discover;
4
+
3
5
  namespace NuGetUpdater.Core.Updater.FileWriters;
4
6
 
5
7
  public interface IFileWriter
@@ -9,6 +11,6 @@ public interface IFileWriter
9
11
  ImmutableArray<string> relativeFilePaths,
10
12
  ImmutableArray<Dependency> originalDependencies,
11
13
  ImmutableArray<Dependency> requiredPackageVersions,
12
- bool addPackageReferenceElementForPinnedPackages
14
+ PackageManagementKind packageManagementKind
13
15
  );
14
16
  }
@@ -5,6 +5,7 @@ using Microsoft.Language.Xml;
5
5
 
6
6
  using NuGet.Versioning;
7
7
 
8
+ using NuGetUpdater.Core.Discover;
8
9
  using NuGetUpdater.Core.Utilities;
9
10
 
10
11
  namespace NuGetUpdater.Core.Updater.FileWriters;
@@ -51,7 +52,7 @@ public class XmlFileWriter : IFileWriter
51
52
  ImmutableArray<string> relativeFilePaths,
52
53
  ImmutableArray<Dependency> originalDependencies,
53
54
  ImmutableArray<Dependency> requiredPackageVersions,
54
- bool addPackageReferenceElementForPinnedPackages
55
+ PackageManagementKind packageManagementKind
55
56
  )
56
57
  {
57
58
  if (relativeFilePaths.IsDefaultOrEmpty)
@@ -185,6 +186,12 @@ public class XmlFileWriter : IFileWriter
185
186
  .WithAttribute(IncludeAttributeName, requiredPackageVersion.Name);
186
187
 
187
188
  // ...add the `<PackageReference>` element if and where appropriate...
189
+ var addPackageReferenceElementForPinnedPackages =
190
+ packageManagementKind switch
191
+ {
192
+ PackageManagementKind.CentralPackageManagementWithTransitivePinning => false,
193
+ _ => true,
194
+ };
188
195
  if (addPackageReferenceElementForPinnedPackages)
189
196
  {
190
197
  addItemGroup();
@@ -118,7 +118,7 @@ internal static class PackageReferenceUpdater
118
118
  // generate project.assets.json
119
119
  var parsedTargetFramework = NuGetFramework.Parse(targetFramework);
120
120
  var tempProject = await MSBuildHelper.CreateTempProjectAsync(tempDir, repoRoot, projectPath, targetFramework, topLevelDependencies, logger, importDependencyTargets: true);
121
- var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(["msbuild", tempProject, "/t:Restore,GenerateBuildDependencyFile"], tempDir.FullName);
121
+ var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetMSBuildSafelyAsync([tempProject, "/t:Restore,GenerateBuildDependencyFile"], tempDir.FullName);
122
122
  var assetsJsonPath = Path.Join(tempDir.FullName, "obj", "project.assets.json");
123
123
  var assetsJsonContent = await File.ReadAllTextAsync(assetsJsonPath);
124
124
 
@@ -406,9 +406,8 @@ internal static partial class MSBuildHelper
406
406
  var (exitCode, stdOut, stdErr) = await HandleGlobalJsonAsync(projectDirectory, repoRoot, async () =>
407
407
  {
408
408
  var targetsHelperPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "TargetFrameworkReporter.targets");
409
- var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(
409
+ var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetMSBuildSafelyAsync(
410
410
  [
411
- "msbuild",
412
411
  projectPath,
413
412
  "/t:ReportTargetFramework",
414
413
  $"/p:CustomAfterMicrosoftCommonCrossTargetingTargets={targetsHelperPath}",
@@ -524,11 +523,10 @@ internal static partial class MSBuildHelper
524
523
  var projectDirectory = Path.GetDirectoryName(projectPath)!;
525
524
  var args = new[]
526
525
  {
527
- "msbuild",
528
526
  projectPath,
529
527
  "-targets"
530
528
  };
531
- var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(args, projectDirectory);
529
+ var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetMSBuildSafelyAsync(args, projectDirectory);
532
530
  if (exitCode != 0)
533
531
  {
534
532
  logger.Warn($"Unable to determine targets for project [{projectPath}]:\nSTDOUT:\n{stdOut}\nSTDERR:\n{stdErr}\n");
@@ -555,12 +553,11 @@ internal static partial class MSBuildHelper
555
553
  var projectDirectory = Path.GetDirectoryName(projectPath)!;
556
554
  var args = new[]
557
555
  {
558
- "msbuild",
559
556
  projectPath,
560
557
  $"-getProperty:{propertyName}"
561
558
  };
562
559
 
563
- var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(args, projectDirectory);
560
+ var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetMSBuildSafelyAsync(args, projectDirectory);
564
561
  if (exitCode != 0)
565
562
  {
566
563
  if (stdOut.Contains("error MSB1001: Unknown switch."))
@@ -580,12 +577,11 @@ internal static partial class MSBuildHelper
580
577
 
581
578
  // do it
582
579
  args = [
583
- "msbuild",
584
580
  projectPath,
585
581
  $"/p:CustomAfterMicrosoftCommonTargets={tempTargetsPath}",
586
582
  "/t:_Dependabot_GetProperty",
587
583
  ];
588
- (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(args, projectDirectory);
584
+ (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetMSBuildSafelyAsync(args, projectDirectory);
589
585
  if (exitCode == 0)
590
586
  {
591
587
  var match = Regex.Match(stdOut, "__PROPERTY_VALUE:(?<PropertyValue>[^$]*)$", RegexOptions.Multiline);
@@ -5,6 +5,21 @@ namespace NuGetUpdater.Core;
5
5
 
6
6
  public static class ProcessEx
7
7
  {
8
+ /// <summary>
9
+ /// Run `dotnet msbuild` with the given additional arguments. The argument `-noAutoResponse` is always appended to
10
+ /// suppress `Directory.Build.rsp` inclusion. This new set of arguments is then passed to the function
11
+ /// `RunDotnetWithoutMSBuildEnvironmentVariablesAsync` to prevent MSBuild from inheriting certain environment
12
+ /// variables.
13
+ /// </summary>
14
+ public static Task<(int ExitCode, string Output, string Error)> RunDotnetMSBuildSafelyAsync(
15
+ IEnumerable<string> arguments,
16
+ string workingDirectory,
17
+ IEnumerable<(string Name, string? Value)>? extraEnvironmentVariables = null
18
+ )
19
+ {
20
+ return RunDotnetWithoutMSBuildEnvironmentVariablesAsync(["msbuild", .. arguments, "-noAutoResponse"], workingDirectory, extraEnvironmentVariables);
21
+ }
22
+
8
23
  /// <summary>
9
24
  /// Run the `dotnet` command with the given values. This will exclude all `MSBuild*` environment variables from the execution.
10
25
  /// </summary>
@@ -894,5 +894,65 @@ public partial class DiscoveryWorkerTests
894
894
  }
895
895
  );
896
896
  }
897
+
898
+ [Fact]
899
+ public async Task MSBuildResponseFileDoesNotCauseDiscoveryFailure()
900
+ {
901
+ await TestDiscoveryAsync(
902
+ packages:
903
+ [
904
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net9.0"),
905
+ ],
906
+ workspacePath: "",
907
+ files: [
908
+ ("myproj.csproj", """
909
+ <Project Sdk="Microsoft.NET.Sdk">
910
+ <PropertyGroup>
911
+ <TargetFramework>net9.0</TargetFramework>
912
+ </PropertyGroup>
913
+ <ItemGroup>
914
+ <PackageReference Include="Some.Package" />
915
+ </ItemGroup>
916
+ </Project>
917
+ """),
918
+ ("Directory.Build.props", "<Project />"),
919
+ ("Directory.Build.targets", "<Project />"),
920
+ ("Directory.Packages.props", """
921
+ <Project>
922
+ <PropertyGroup>
923
+ <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
924
+ </PropertyGroup>
925
+ <ItemGroup>
926
+ <PackageVersion Include="Some.Package" Version="1.0.0" />
927
+ </ItemGroup>
928
+ </Project>
929
+ """),
930
+ ("Directory.Build.rsp", """
931
+ /this-is-not-a-supported-switch-and-would-normally-cause-a-discovery-failure
932
+ """)
933
+ ],
934
+ expectedResult: new()
935
+ {
936
+ Path = "",
937
+ Projects = [
938
+ new()
939
+ {
940
+ FilePath = "myproj.csproj",
941
+ Dependencies = [
942
+ new("Some.Package", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net9.0"]),
943
+ ],
944
+ TargetFrameworks = ["net9.0"],
945
+ ReferencedProjectPaths = [],
946
+ ImportedFiles = [
947
+ "Directory.Build.props",
948
+ "Directory.Build.targets",
949
+ "Directory.Packages.props",
950
+ ],
951
+ AdditionalFiles = [],
952
+ },
953
+ ],
954
+ }
955
+ );
956
+ }
897
957
  }
898
958
  }
@@ -1694,7 +1694,7 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
1694
1694
  ReferencedProjectPaths = ["referenced/a.csproj"],
1695
1695
  ImportedFiles = ["imported/a.props"],
1696
1696
  AdditionalFiles = ["a/packages.config"],
1697
- CentralPackageTransitivePinningEnabled = false,
1697
+ PackageManagementKind = PackageManagementKind.Default,
1698
1698
  };
1699
1699
  var result2 = new ProjectDiscoveryResult()
1700
1700
  {
@@ -1709,7 +1709,7 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
1709
1709
  ReferencedProjectPaths = ["referenced/b.csproj"],
1710
1710
  ImportedFiles = ["imported/b.props"],
1711
1711
  AdditionalFiles = ["b/app.config"],
1712
- CentralPackageTransitivePinningEnabled = true,
1712
+ PackageManagementKind = PackageManagementKind.CentralPackageManagement,
1713
1713
  };
1714
1714
 
1715
1715
  // to make sure we're checking everything exactly, we'll explicitly check each item
@@ -1736,7 +1736,7 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
1736
1736
  AssertEx.Equal(["referenced/a.csproj", "referenced/b.csproj"], merged.ReferencedProjectPaths);
1737
1737
  AssertEx.Equal(["imported/a.props", "imported/b.props"], merged.ImportedFiles);
1738
1738
  AssertEx.Equal(["a/packages.config", "b/app.config"], merged.AdditionalFiles);
1739
- Assert.True(merged.CentralPackageTransitivePinningEnabled);
1739
+ Assert.Equal(PackageManagementKind.CentralPackageManagement, merged.PackageManagementKind);
1740
1740
  }
1741
1741
 
1742
1742
  [Fact]
@@ -318,7 +318,7 @@ namespace NuGetUpdater.Core.Test
318
318
  </Project>
319
319
  """
320
320
  );
321
- var (exitCode, stdout, stderr) = ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(["msbuild", projectPath, "/t:_ReportCurrentSdkVersion"], projectDir.FullName).Result;
321
+ var (exitCode, stdout, stderr) = ProcessEx.RunDotnetMSBuildSafelyAsync([projectPath, "/t:_ReportCurrentSdkVersion"], projectDir.FullName).Result;
322
322
  if (exitCode != 0)
323
323
  {
324
324
  throw new Exception($"Failed to report the current SDK version:\n{stdout}\n{stderr}");
@@ -1,5 +1,6 @@
1
1
  using System.Collections.Immutable;
2
2
 
3
+ using NuGetUpdater.Core.Discover;
3
4
  using NuGetUpdater.Core.Updater.FileWriters;
4
5
 
5
6
  using Xunit;
@@ -15,15 +16,14 @@ public abstract class FileWriterTestsBase
15
16
  ImmutableArray<string> initialProjectDependencyStrings,
16
17
  ImmutableArray<string> requiredDependencyStrings,
17
18
  (string path, string contents)[] expectedFiles,
18
- bool useCentralPackageTransitivePinning = false
19
+ PackageManagementKind packageManagementKind = PackageManagementKind.Default
19
20
  )
20
21
  {
21
22
  using var tempDir = await TemporaryDirectory.CreateWithContentsAsync(files);
22
23
  var repoContentsPath = new DirectoryInfo(tempDir.DirectoryPath);
23
24
  var initialProjectDependencies = initialProjectDependencyStrings.Select(s => new Dependency(s.Split('/')[0], s.Split('/')[1], DependencyType.Unknown)).ToImmutableArray();
24
25
  var requiredDependencies = requiredDependencyStrings.Select(s => new Dependency(s.Split('/')[0], s.Split('/')[1], DependencyType.Unknown)).ToImmutableArray();
25
- var addPackageReferenceElementForPinnedPackages = !useCentralPackageTransitivePinning;
26
- var success = await FileWriter.UpdatePackageVersionsAsync(repoContentsPath, [.. files.Select(f => f.path)], initialProjectDependencies, requiredDependencies, addPackageReferenceElementForPinnedPackages);
26
+ var success = await FileWriter.UpdatePackageVersionsAsync(repoContentsPath, [.. files.Select(f => f.path)], initialProjectDependencies, requiredDependencies, packageManagementKind);
27
27
  Assert.True(success, "Expected UpdatePackageVersionsAsync to succeed.");
28
28
 
29
29
  var expectedFileNames = expectedFiles.Select(f => f.path).ToHashSet();
@@ -39,15 +39,14 @@ public abstract class FileWriterTestsBase
39
39
  (string path, string contents)[] files,
40
40
  ImmutableArray<string> initialProjectDependencyStrings,
41
41
  ImmutableArray<string> requiredDependencyStrings,
42
- bool useCentralPackageTransitivePinning = false
42
+ PackageManagementKind packageManagementKind = PackageManagementKind.Default
43
43
  )
44
44
  {
45
45
  using var tempDir = await TemporaryDirectory.CreateWithContentsAsync(files);
46
46
  var repoContentsPath = new DirectoryInfo(tempDir.DirectoryPath);
47
47
  var initialProjectDependencies = initialProjectDependencyStrings.Select(s => new Dependency(s.Split('/')[0], s.Split('/')[1], DependencyType.Unknown)).ToImmutableArray();
48
48
  var requiredDependencies = requiredDependencyStrings.Select(s => new Dependency(s.Split('/')[0], s.Split('/')[1], DependencyType.Unknown)).ToImmutableArray();
49
- var addPackageReferenceElementForPinnedPackages = !useCentralPackageTransitivePinning;
50
- var success = await FileWriter.UpdatePackageVersionsAsync(repoContentsPath, [.. files.Select(f => f.path)], initialProjectDependencies, requiredDependencies, addPackageReferenceElementForPinnedPackages);
49
+ var success = await FileWriter.UpdatePackageVersionsAsync(repoContentsPath, [.. files.Select(f => f.path)], initialProjectDependencies, requiredDependencies, packageManagementKind);
51
50
  Assert.False(success);
52
51
 
53
52
  var expectedFileNames = files.Select(f => f.path).ToHashSet();
@@ -1,5 +1,6 @@
1
1
  using System.Collections.Immutable;
2
2
 
3
+ using NuGetUpdater.Core.Discover;
3
4
  using NuGetUpdater.Core.Updater.FileWriters;
4
5
 
5
6
  namespace NuGetUpdater.Core.Test.Update.FileWriters;
@@ -13,7 +14,7 @@ internal class TestFileWriterReturnsConstantResult : IFileWriter
13
14
  Result = result;
14
15
  }
15
16
 
16
- public Task<bool> UpdatePackageVersionsAsync(DirectoryInfo repoContentsPath, ImmutableArray<string> relativeFilePaths, ImmutableArray<Dependency> originalDependencies, ImmutableArray<Dependency> requiredPackageVersions, bool addPackageReferenceElementForPinnedPackages)
17
+ public Task<bool> UpdatePackageVersionsAsync(DirectoryInfo repoContentsPath, ImmutableArray<string> relativeFilePaths, ImmutableArray<Dependency> originalDependencies, ImmutableArray<Dependency> requiredPackageVersions, PackageManagementKind packageManagementKind)
17
18
  {
18
19
  return Task.FromResult(Result);
19
20
  }
@@ -1,3 +1,4 @@
1
+ using NuGetUpdater.Core.Discover;
1
2
  using NuGetUpdater.Core.Updater.FileWriters;
2
3
 
3
4
  using Xunit;
@@ -1558,7 +1559,7 @@ public class XmlFileWriterTests : FileWriterTestsBase
1558
1559
  public async Task SingleDependency_CentralPackageManagement_TransitiveIsPinned_NoExistingPackageVersionElement_TransitivePinningEnabled_OnlyPackagesPropsIsUpdated()
1559
1560
  {
1560
1561
  await TestAsync(
1561
- useCentralPackageTransitivePinning: true,
1562
+ packageManagementKind: PackageManagementKind.CentralPackageManagementWithTransitivePinning,
1562
1563
  files: [
1563
1564
  ("project.csproj", """
1564
1565
  <Project Sdk="Microsoft.NET.Sdk">
@@ -1954,7 +1955,7 @@ public class XmlFileWriterTests : FileWriterTestsBase
1954
1955
  public async Task UpdatingAPinnedCentrallyManagedPackageUpdatesJustTheVersionNumberWhenDeclarationIsPresent()
1955
1956
  {
1956
1957
  await TestAsync(
1957
- useCentralPackageTransitivePinning: true,
1958
+ packageManagementKind: PackageManagementKind.CentralPackageManagementWithTransitivePinning,
1958
1959
  files: [
1959
1960
  ("src/project.csproj", """
1960
1961
  <?xml version="1.0"?>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-nuget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.373.0
4
+ version: 0.374.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.373.0
18
+ version: 0.374.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.373.0
25
+ version: 0.374.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: debug
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -412,6 +412,7 @@ files:
412
412
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs
413
413
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscoveryResult.cs
414
414
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/IDiscoveryResult.cs
415
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackageManagementKind.cs
415
416
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs
416
417
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs
417
418
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs
@@ -555,7 +556,7 @@ licenses:
555
556
  - MIT
556
557
  metadata:
557
558
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
558
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.373.0
559
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.374.0
559
560
  rdoc_options: []
560
561
  require_paths:
561
562
  - lib