dependabot-nuget 0.299.1 → 0.300.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 660e8ce19f7c5fe8fc23479b4d2bda8b68c18c2ef3b233c7ee7e1d0bb07c5ab7
4
- data.tar.gz: 6169f17f97aae5ef7188ce33482a6e22b25f1e827b5f1edfc724d6d46e0f40cb
3
+ metadata.gz: 332ca34b57d20f0c5690563f3aeb969fb638fb8a9a5e02e569dc1360ef5ad066
4
+ data.tar.gz: 7dba4cc1963936c3b0b32dfa845e1285cb3bee679429da04c7cdad13590fc9dc
5
5
  SHA512:
6
- metadata.gz: 89d65ebba5930c8fa88fde8d63614e187fc4e72f0cec66cbad9af08abafaf7b2601bede6d351e3ea73c1572a51a7c6245d488228a33b677204bc50982fbc41f5
7
- data.tar.gz: 76df476a5b3c605128e79343ed2fe6248033a5a3d63fe4a2b8be03bedab6332aeb4c01d0d96a87766316d13d769ab69c4c953189ff0eae15ed4370914abc17ef
6
+ metadata.gz: 7b7a1770111410a3a3c9c7281e8e275f485e977e8c57290f7ea1d5e86219588d640bb82bf5c5f6d0a65b8b8a275edb4aadd051c0cc953df3cb62edc8fdf25a8d
7
+ data.tar.gz: 1b2ed4ce448d6a239c28d3b448fa73096b211a03dbd8083bbc6168c6655c3cb5d3d76d07262c3e0aeb9f7ccd8a58d7372f6dd21dc2ce6dc428160313bb8b653f
@@ -1,8 +1,16 @@
1
1
  <Project>
2
2
  <!-- The following properties enable target framework and dependency discovery when OS-specific workloads are required -->
3
3
  <PropertyGroup>
4
+ <!--
5
+
6
+ $(TargetPlatformVersion) should default to '0.0' as per https://github.com/dotnet/sdk/blob/v9.0.100/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets#L69
7
+
8
+ HOWEVER, this will need to be set differently (e.g., '1.0') to do dependency discovery
9
+
10
+ -->
11
+ <_DefaultTargetPlatformVersion Condition="'$(_DefaultTargetPlatformVersion)' == ''">0.0</_DefaultTargetPlatformVersion>
4
12
  <DesignTimeBuild>true</DesignTimeBuild>
5
13
  <EnableWindowsTargeting Condition="$(TargetFramework.Contains('-windows'))">true</EnableWindowsTargeting>
6
- <TargetPlatformVersion Condition="$(TargetPlatformVersion) == '' AND $(TargetFramework.Contains('-'))">1.0</TargetPlatformVersion>
14
+ <TargetPlatformVersion Condition="$(TargetPlatformVersion) == '' AND $(TargetFramework.Contains('-'))">$(_DefaultTargetPlatformVersion)</TargetPlatformVersion>
7
15
  </PropertyGroup>
8
16
  </Project>
@@ -1,4 +1,9 @@
1
1
  <Project>
2
+ <PropertyGroup>
3
+ <!-- Dependency discovery requires a non-zero value for $(TargetPlatformVersion) -->
4
+ <_DefaultTargetPlatformVersion>1.0</_DefaultTargetPlatformVersion>
5
+ </PropertyGroup>
6
+
2
7
  <Import Project="DependencyDiscovery.props" />
3
8
 
4
9
  <Target Name="_DiscoverDependencies" DependsOnTargets="ResolveAssemblyReferences;GenerateBuildDependencyFile;ResolvePackageAssets">
@@ -101,7 +101,7 @@ internal static class SdkProjectDiscovery
101
101
  {
102
102
  // the built-in target `GenerateBuildDependencyFile` forces resolution of all NuGet packages, but doesn't invoke a full build
103
103
  var dependencyDiscoveryTargetsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "DependencyDiscovery.targets");
104
- var args = new string[]
104
+ var args = new List<string>()
105
105
  {
106
106
  "build",
107
107
  startingProjectPath,
@@ -112,6 +112,16 @@ internal static class SdkProjectDiscovery
112
112
  $"/bl:{binLogPath}"
113
113
  };
114
114
  var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(args, startingProjectDirectory, experimentsManager);
115
+ if (exitCode != 0 && stdOut.Contains("error : Object reference not set to an instance of an object."))
116
+ {
117
+ // https://github.com/NuGet/Home/issues/11761#issuecomment-1105218996
118
+ // Due to a bug in NuGet, there can be a null reference exception thrown and adding this command line argument will work around it,
119
+ // 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
120
+ // unless we have to.
121
+ args.Add("/RestoreProperty:__Unused__=__Unused__");
122
+ (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(args, startingProjectDirectory, experimentsManager);
123
+ }
124
+
115
125
  return (exitCode, stdOut, stdErr);
116
126
  }, logger, retainMSBuildSdks: true);
117
127
  MSBuildHelper.ThrowOnError(stdOut);
@@ -1381,4 +1381,57 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
1381
1381
  }
1382
1382
  );
1383
1383
  }
1384
+
1385
+ // If the "Restore" target is invoked and $(RestoreUseStaticGraphEvaluation) is set to true, NuGet can throw
1386
+ // a NullReferenceException.
1387
+ // https://github.com/NuGet/Home/issues/11761#issuecomment-1105218996
1388
+ [Fact]
1389
+ public async Task NullReferenceExceptionFromNuGetRestoreIsWorkedAround()
1390
+ {
1391
+ await TestDiscoveryAsync(
1392
+ packages: [
1393
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.2.3", "net8.0"),
1394
+ ],
1395
+ experimentsManager: new ExperimentsManager() { UseDirectDiscovery = true },
1396
+ workspacePath: "",
1397
+ files: [
1398
+ ("project.csproj", """
1399
+ <Project Sdk="Microsoft.NET.Sdk">
1400
+ <PropertyGroup>
1401
+ <TargetFramework>net8.0</TargetFramework>
1402
+ <RestoreUseStaticGraphEvaluation>true</RestoreUseStaticGraphEvaluation>
1403
+ </PropertyGroup>
1404
+ <ItemGroup>
1405
+ <PackageReference Include="Some.Package" Version="1.2.3" />
1406
+ </ItemGroup>
1407
+ </Project>
1408
+ """),
1409
+ // a pattern seen in the wild; always run restore
1410
+ ("Directory.Build.rsp", """
1411
+ /Restore
1412
+ """)
1413
+ ],
1414
+ expectedResult: new()
1415
+ {
1416
+ Path = "",
1417
+ Projects = [
1418
+ new()
1419
+ {
1420
+ FilePath = "project.csproj",
1421
+ TargetFrameworks = ["net8.0"],
1422
+ Dependencies = [
1423
+ new("Some.Package", "1.2.3", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true)
1424
+ ],
1425
+ Properties = [
1426
+ new("RestoreUseStaticGraphEvaluation", "true", "project.csproj"),
1427
+ new("TargetFramework", "net8.0", "project.csproj"),
1428
+ ],
1429
+ ReferencedProjectPaths = [],
1430
+ ImportedFiles = [],
1431
+ AdditionalFiles = [],
1432
+ }
1433
+ ]
1434
+ }
1435
+ );
1436
+ }
1384
1437
  }
@@ -479,6 +479,51 @@ public class SdkProjectDiscoveryTests : DiscoveryWorkerTestBase
479
479
  );
480
480
  }
481
481
 
482
+ [Fact]
483
+ public async Task DependenciesCanBeDiscoveredWithWindowsSpecificTfm()
484
+ {
485
+ await TestDiscoverAsync(
486
+ packages:
487
+ [
488
+ MockNuGetPackage.CreateSimplePackage("Some.Dependency", "1.2.3", "netstandard2.0"),
489
+ ],
490
+ startingDirectory: "src",
491
+ projectPath: "src/library.csproj",
492
+ files:
493
+ [
494
+ ("src/library.csproj", """
495
+ <Project Sdk="Microsoft.NET.Sdk">
496
+ <PropertyGroup>
497
+ <TargetFramework>net9.0-windows</TargetFramework>
498
+ </PropertyGroup>
499
+ <ItemGroup>
500
+ <PackageReference Include="Some.Dependency" Version="1.2.3" />
501
+ </ItemGroup>
502
+ </Project>
503
+ """)
504
+ ],
505
+ expectedProjects:
506
+ [
507
+ new()
508
+ {
509
+ FilePath = "library.csproj",
510
+ Dependencies =
511
+ [
512
+ new("Some.Dependency", "1.2.3", DependencyType.PackageReference, TargetFrameworks: ["net9.0-windows"], IsDirect: true),
513
+ ],
514
+ ImportedFiles = [],
515
+ Properties =
516
+ [
517
+ new("TargetFramework", "net9.0-windows", "src/library.csproj"),
518
+ ],
519
+ TargetFrameworks = ["net9.0-windows"],
520
+ ReferencedProjectPaths = [],
521
+ AdditionalFiles = [],
522
+ },
523
+ ]
524
+ );
525
+ }
526
+
482
527
  private static async Task TestDiscoverAsync(string startingDirectory, string projectPath, TestFile[] files, ImmutableArray<ExpectedSdkProjectDiscoveryResult> expectedProjects, MockNuGetPackage[]? packages = null)
483
528
  {
484
529
  using var testDirectory = await TemporaryDirectory.CreateWithContentsAsync(files);
@@ -606,6 +606,18 @@ public class MSBuildHelperTests : TestBase
606
606
  new[] { "net8.0-windows7.0" }
607
607
  ];
608
608
 
609
+ yield return
610
+ [
611
+ """
612
+ <Project Sdk="Microsoft.NET.Sdk">
613
+ <PropertyGroup>
614
+ <TargetFramework>net9.0-windows</TargetFramework>
615
+ </PropertyGroup>
616
+ </Project>
617
+ """,
618
+ new[] { "net9.0-windows" }
619
+ ];
620
+
609
621
  // legacy projects
610
622
  yield return
611
623
  [
@@ -28,7 +28,7 @@ module Dependabot
28
28
 
29
29
  File.rename(user_nuget_config_path, temporary_nuget_config_path)
30
30
 
31
- package_sources = []
31
+ package_sources = [" <add key=\"nuget.org\" value=\"https://api.nuget.org/v3/index.json\" />"]
32
32
  package_source_credentials = []
33
33
  nuget_credentials.each_with_index do |c, i|
34
34
  source_name = "nuget_source_#{i + 1}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-nuget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.299.1
4
+ version: 0.300.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-28 00:00:00.000000000 Z
11
+ date: 2025-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.299.1
19
+ version: 0.300.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.299.1
26
+ version: 0.300.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubyzip
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -537,7 +537,7 @@ licenses:
537
537
  - MIT
538
538
  metadata:
539
539
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
540
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.299.1
540
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.300.0
541
541
  post_install_message:
542
542
  rdoc_options: []
543
543
  require_paths: