dependabot-nuget 0.257.0 → 0.259.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/Directory.Packages.props +2 -0
  3. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +2 -2
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +255 -191
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +63 -35
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +107 -14
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +9 -5
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +18 -0
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +6 -1
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.DotNetToolsJson.cs +6 -2
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +6 -2
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +11 -21
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Proj.cs +95 -0
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +204 -62
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +64 -45
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/MockNuGetPackage.cs +419 -0
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/NuGetUpdater.Core.Test.csproj +1 -0
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs +7 -2
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +77 -19
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DirsProj.cs +120 -91
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +132 -97
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +93 -75
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +45 -42
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +1089 -956
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +1624 -1291
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +296 -293
  27. data/helpers/lib/NuGetUpdater/global.json +6 -0
  28. data/lib/dependabot/nuget/file_parser.rb +4 -5
  29. data/lib/dependabot/nuget/file_updater.rb +1 -1
  30. data/lib/dependabot/nuget/update_checker/dependency_finder.rb +7 -2
  31. data/lib/dependabot/nuget/update_checker/property_updater.rb +1 -0
  32. data/lib/dependabot/nuget/update_checker/version_finder.rb +2 -3
  33. data/lib/dependabot/nuget/update_checker.rb +1 -0
  34. metadata +8 -5
@@ -11,18 +11,22 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
11
11
  public async Task TestProjectFiles(string projectPath)
12
12
  {
13
13
  await TestDiscoveryAsync(
14
+ packages:
15
+ [
16
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
17
+ ],
14
18
  workspacePath: "src",
15
19
  files: new[]
16
20
  {
17
21
  (projectPath, """
18
22
  <Project Sdk="Microsoft.NET.Sdk">
19
23
  <PropertyGroup>
20
- <TargetFramework>netstandard2.0</TargetFramework>
21
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
24
+ <TargetFramework>net8.0</TargetFramework>
25
+ <SomePackageVersion>9.0.1</SomePackageVersion>
22
26
  </PropertyGroup>
23
27
 
24
28
  <ItemGroup>
25
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
29
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
26
30
  </ItemGroup>
27
31
  </Project>
28
32
  """)
@@ -34,16 +38,16 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
34
38
  new()
35
39
  {
36
40
  FilePath = Path.GetFileName(projectPath),
37
- TargetFrameworks = ["netstandard2.0"],
41
+ TargetFrameworks = ["net8.0"],
38
42
  ReferencedProjectPaths = [],
39
- ExpectedDependencyCount = 19,
43
+ ExpectedDependencyCount = 2,
40
44
  Dependencies = [
41
45
  new("Microsoft.NET.Sdk", null, DependencyType.MSBuildSdk),
42
- new("Newtonsoft.Json", "9.0.1", DependencyType.PackageReference, TargetFrameworks: ["netstandard2.0"], IsDirect: true)
46
+ new("Some.Package", "9.0.1", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true)
43
47
  ],
44
48
  Properties = [
45
- new("NewtonsoftJsonPackageVersion", "9.0.1", projectPath),
46
- new("TargetFramework", "netstandard2.0", projectPath),
49
+ new("SomePackageVersion", "9.0.1", projectPath),
50
+ new("TargetFramework", "net8.0", projectPath),
47
51
  ]
48
52
  }
49
53
  ]
@@ -54,12 +58,15 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
54
58
  [Fact]
55
59
  public async Task TestPackageConfig()
56
60
  {
57
- var projectPath = "src/project.csproj";
58
61
  await TestDiscoveryAsync(
59
- workspacePath: "",
62
+ packages:
63
+ [
64
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net45"),
65
+ ],
66
+ workspacePath: "src",
60
67
  files: new[]
61
68
  {
62
- (projectPath, """
69
+ ("src/project.csproj", """
63
70
  <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
64
71
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
65
72
  <PropertyGroup>
@@ -69,8 +76,8 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
69
76
  <None Include="packages.config" />
70
77
  </ItemGroup>
71
78
  <ItemGroup>
72
- <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
73
- <HintPath>packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
79
+ <Reference Include="Some.Package">
80
+ <HintPath>packages\Some.Package.7.0.1\lib\net45\Some.Package.dll</HintPath>
74
81
  <Private>True</Private>
75
82
  </Reference>
76
83
  </ItemGroup>
@@ -79,25 +86,26 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
79
86
  """),
80
87
  ("src/packages.config", """
81
88
  <packages>
82
- <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
89
+ <package id="Some.Package" version="7.0.1" targetFramework="net45" />
83
90
  </packages>
84
91
  """),
85
92
  },
86
93
  expectedResult: new()
87
94
  {
88
- FilePath = "",
95
+ FilePath = "src",
89
96
  Projects = [
90
97
  new()
91
98
  {
92
- FilePath = projectPath,
99
+ FilePath = "project.csproj",
93
100
  TargetFrameworks = ["net45"],
94
101
  ReferencedProjectPaths = [],
95
- ExpectedDependencyCount = 2, // Should we ignore Microsoft.NET.ReferenceAssemblies?
102
+ ExpectedDependencyCount = 2,
96
103
  Dependencies = [
97
- new("Newtonsoft.Json", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"])
104
+ new("Microsoft.NETFramework.ReferenceAssemblies", "1.0.3", DependencyType.Unknown, TargetFrameworks: ["net45"], IsTransitive: true),
105
+ new("Some.Package", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"]),
98
106
  ],
99
107
  Properties = [
100
- new("TargetFrameworkVersion", "v4.5", projectPath),
108
+ new("TargetFrameworkVersion", "v4.5", "src/project.csproj"),
101
109
  ]
102
110
  }
103
111
  ]
@@ -108,61 +116,66 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
108
116
  [Fact]
109
117
  public async Task TestProps()
110
118
  {
111
- var projectPath = "src/project.csproj";
112
119
  await TestDiscoveryAsync(
113
- workspacePath: "",
120
+ packages:
121
+ [
122
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
123
+ ],
124
+ workspacePath: "src",
114
125
  files: new[]
115
126
  {
116
- (projectPath, """
127
+ ("src/project.csproj", """
117
128
  <Project Sdk="Microsoft.NET.Sdk">
118
129
  <PropertyGroup>
119
- <TargetFramework>netstandard2.0</TargetFramework>
130
+ <TargetFramework>net8.0</TargetFramework>
120
131
  </PropertyGroup>
121
132
 
122
133
  <ItemGroup>
123
- <PackageReference Include="Newtonsoft.Json" />
134
+ <PackageReference Include="Some.Package" />
124
135
  </ItemGroup>
125
136
  </Project>
126
137
  """),
138
+ ("Directory.Build.props", "<Project />"),
127
139
  ("Directory.Packages.props", """
128
140
  <Project>
129
141
  <PropertyGroup>
130
142
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
131
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
143
+ <SomePackageVersion>9.0.1</SomePackageVersion>
132
144
  </PropertyGroup>
133
145
 
134
146
  <ItemGroup>
135
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
147
+ <PackageVersion Include="Some.Package" Version="$(SomePackageVersion)" />
136
148
  </ItemGroup>
137
149
  </Project>
138
150
  """)
139
151
  },
140
152
  expectedResult: new()
141
153
  {
142
- FilePath = "",
154
+ FilePath = "src",
155
+ ExpectedProjectCount = 2,
143
156
  Projects = [
144
157
  new()
145
158
  {
146
- FilePath = projectPath,
147
- TargetFrameworks = ["netstandard2.0"],
159
+ FilePath = "project.csproj",
160
+ TargetFrameworks = ["net8.0"],
148
161
  ReferencedProjectPaths = [],
149
- ExpectedDependencyCount = 19,
162
+ ExpectedDependencyCount = 2,
150
163
  Dependencies = [
151
164
  new("Microsoft.NET.Sdk", null, DependencyType.MSBuildSdk),
152
- new("Newtonsoft.Json", "9.0.1", DependencyType.PackageReference, TargetFrameworks: ["netstandard2.0"], IsDirect: true)
165
+ new("Some.Package", "9.0.1", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true)
153
166
  ],
154
167
  Properties = [
155
168
  new("ManagePackageVersionsCentrally", "true", "Directory.Packages.props"),
156
- new("NewtonsoftJsonPackageVersion", "9.0.1", "Directory.Packages.props"),
157
- new("TargetFramework", "netstandard2.0", projectPath),
169
+ new("SomePackageVersion", "9.0.1", "Directory.Packages.props"),
170
+ new("TargetFramework", "net8.0", "src/project.csproj"),
158
171
  ]
159
172
  }
160
173
  ],
161
174
  DirectoryPackagesProps = new()
162
175
  {
163
- FilePath = "Directory.Packages.props",
176
+ FilePath = "../Directory.Packages.props",
164
177
  Dependencies = [
165
- new("Newtonsoft.Json", "9.0.1", DependencyType.PackageVersion, IsDirect: true)
178
+ new("Some.Package", "9.0.1", DependencyType.PackageVersion, IsDirect: true)
166
179
  ],
167
180
  }
168
181
  }
@@ -174,29 +187,34 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
174
187
  {
175
188
  var solutionPath = "solution.sln";
176
189
  await TestDiscoveryAsync(
190
+ packages:
191
+ [
192
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
193
+ ],
177
194
  workspacePath: "",
178
195
  files: new[]
179
196
  {
180
197
  ("src/project.csproj", """
181
198
  <Project Sdk="Microsoft.NET.Sdk">
182
199
  <PropertyGroup>
183
- <TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
200
+ <TargetFrameworks>net7.0;net8.0</TargetFrameworks>
184
201
  </PropertyGroup>
185
202
 
186
203
  <ItemGroup>
187
- <PackageReference Include="Newtonsoft.Json" />
204
+ <PackageReference Include="Some.Package" />
188
205
  </ItemGroup>
189
206
  </Project>
190
207
  """),
208
+ ("Directory.Build.props", "<Project />"),
191
209
  ("Directory.Packages.props", """
192
210
  <Project>
193
211
  <PropertyGroup>
194
212
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
195
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
213
+ <SomePackageVersion>9.0.1</SomePackageVersion>
196
214
  </PropertyGroup>
197
215
 
198
216
  <ItemGroup>
199
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
217
+ <PackageVersion Include="Some.Package" Version="$(SomePackageVersion)" />
200
218
  </ItemGroup>
201
219
  </Project>
202
220
  """),
@@ -259,20 +277,21 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
259
277
  expectedResult: new()
260
278
  {
261
279
  FilePath = "",
280
+ ExpectedProjectCount = 2,
262
281
  Projects = [
263
282
  new()
264
283
  {
265
284
  FilePath = "src/project.csproj",
266
- TargetFrameworks = ["net6.0", "netstandard2.0"],
267
- ExpectedDependencyCount = 19,
285
+ TargetFrameworks = ["net7.0", "net8.0"],
286
+ ExpectedDependencyCount = 2,
268
287
  Dependencies = [
269
288
  new("Microsoft.NET.Sdk", null, DependencyType.MSBuildSdk),
270
- new("Newtonsoft.Json", "9.0.1", DependencyType.PackageReference, TargetFrameworks: ["net6.0", "netstandard2.0"], IsDirect: true)
289
+ new("Some.Package", "9.0.1", DependencyType.PackageReference, TargetFrameworks: ["net7.0", "net8.0"], IsDirect: true)
271
290
  ],
272
291
  Properties = [
273
292
  new("ManagePackageVersionsCentrally", "true", "Directory.Packages.props"),
274
- new("NewtonsoftJsonPackageVersion", "9.0.1", "Directory.Packages.props"),
275
- new("TargetFrameworks", "netstandard2.0;net6.0", "src/project.csproj"),
293
+ new("SomePackageVersion", "9.0.1", "Directory.Packages.props"),
294
+ new("TargetFrameworks", "net7.0;net8.0", "src/project.csproj"),
276
295
  ]
277
296
  }
278
297
  ],
@@ -280,7 +299,7 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
280
299
  {
281
300
  FilePath = "Directory.Packages.props",
282
301
  Dependencies = [
283
- new("Newtonsoft.Json", "9.0.1", DependencyType.PackageVersion, IsDirect: true)
302
+ new("Some.Package", "9.0.1", DependencyType.PackageVersion, IsDirect: true)
284
303
  ],
285
304
  },
286
305
  GlobalJson = new()