dependabot-nuget 0.258.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
@@ -1,5 +1,3 @@
1
- using System.Threading.Tasks;
2
-
3
1
  using Xunit;
4
2
 
5
3
  namespace NuGetUpdater.Core.Test.Update;
@@ -12,36 +10,39 @@ public partial class UpdateWorkerTests
12
10
  public async Task NoChangeWhenGlobalJsonNotFound()
13
11
  {
14
12
  await TestNoChangeforProject("Microsoft.Build.Traversal", "3.2.0", "4.1.0",
13
+ packages: [],
15
14
  // initial
16
15
  projectContents: """
17
- <Project Sdk="Microsoft.NET.Sdk">
18
- <PropertyGroup>
19
- <TargetFramework>netstandard2.0</TargetFramework>
20
- </PropertyGroup>
16
+ <Project Sdk="Microsoft.NET.Sdk">
17
+ <PropertyGroup>
18
+ <TargetFramework>netstandard2.0</TargetFramework>
19
+ </PropertyGroup>
21
20
 
22
- <ItemGroup>
23
- <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
24
- </ItemGroup>
25
- </Project>
26
- """);
21
+ <ItemGroup>
22
+ <PackageReference Include="Some.Package" Version="13.0.3" />
23
+ </ItemGroup>
24
+ </Project>
25
+ """
26
+ );
27
27
  }
28
28
 
29
29
  [Fact]
30
30
  public async Task NoChangeWhenDependencyNotFound()
31
31
  {
32
32
  await TestNoChangeforProject("Microsoft.Build.Traversal", "3.2.0", "4.1.0",
33
+ packages: [],
33
34
  // initial
34
35
  projectContents: """
35
- <Project Sdk="Microsoft.NET.Sdk">
36
- <PropertyGroup>
37
- <TargetFramework>netstandard2.0</TargetFramework>
38
- </PropertyGroup>
36
+ <Project Sdk="Microsoft.NET.Sdk">
37
+ <PropertyGroup>
38
+ <TargetFramework>netstandard2.0</TargetFramework>
39
+ </PropertyGroup>
39
40
 
40
- <ItemGroup>
41
- <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
42
- </ItemGroup>
43
- </Project>
44
- """,
41
+ <ItemGroup>
42
+ <PackageReference Include="Some.Package" Version="13.0.3" />
43
+ </ItemGroup>
44
+ </Project>
45
+ """,
45
46
  additionalFiles:
46
47
  [
47
48
  ("global.json", """
@@ -52,26 +53,28 @@ public partial class UpdateWorkerTests
52
53
  }
53
54
  }
54
55
  """)
55
- ]);
56
+ ]
57
+ );
56
58
  }
57
59
 
58
60
  [Fact]
59
61
  public async Task NoChangeWhenGlobalJsonInUnexpectedLocation()
60
62
  {
61
63
  await TestNoChangeforProject("Microsoft.Build.Traversal", "3.2.0", "4.1.0",
64
+ packages: [],
62
65
  // initial
63
66
  projectFilePath: "src/project/project.csproj",
64
67
  projectContents: """
65
- <Project Sdk="Microsoft.NET.Sdk">
66
- <PropertyGroup>
67
- <TargetFramework>netstandard2.0</TargetFramework>
68
- </PropertyGroup>
68
+ <Project Sdk="Microsoft.NET.Sdk">
69
+ <PropertyGroup>
70
+ <TargetFramework>netstandard2.0</TargetFramework>
71
+ </PropertyGroup>
69
72
 
70
- <ItemGroup>
71
- <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
72
- </ItemGroup>>
73
- </Project>
74
- """,
73
+ <ItemGroup>
74
+ <PackageReference Include="Some.Package" Version="13.0.3" />
75
+ </ItemGroup>>
76
+ </Project>
77
+ """,
75
78
  additionalFiles:
76
79
  [
77
80
  ("eng/global.json", """
@@ -85,26 +88,33 @@ public partial class UpdateWorkerTests
85
88
  }
86
89
  }
87
90
  """)
88
- ]);
91
+ ]
92
+ );
89
93
  }
90
94
 
91
95
  [Fact]
92
96
  public async Task UpdateSingleDependency()
93
97
  {
94
- await TestUpdateForProject("Microsoft.Build.Traversal", "3.2.0", "4.1.0",
98
+ await TestUpdateForProject("Some.MSBuild.Sdk", "3.2.0", "4.1.0",
99
+ packages:
100
+ [
101
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.3", "net8.0"),
102
+ MockNuGetPackage.CreateMSBuildSdkPackage("Some.MSBuild.Sdk", "3.2.0"),
103
+ MockNuGetPackage.CreateMSBuildSdkPackage("Some.MSBuild.Sdk", "4.1.0"),
104
+ ],
95
105
  // initial
96
106
  projectFilePath: "src/project/project.csproj",
97
107
  projectContents: """
98
- <Project Sdk="Microsoft.NET.Sdk">
99
- <PropertyGroup>
100
- <TargetFramework>netstandard2.0</TargetFramework>
101
- </PropertyGroup>
108
+ <Project Sdk="Microsoft.NET.Sdk">
109
+ <PropertyGroup>
110
+ <TargetFramework>net8.0</TargetFramework>
111
+ </PropertyGroup>
102
112
 
103
- <ItemGroup>
104
- <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
105
- </ItemGroup>
106
- </Project>
107
- """,
113
+ <ItemGroup>
114
+ <PackageReference Include="Some.Package" Version="13.0.3" />
115
+ </ItemGroup>
116
+ </Project>
117
+ """,
108
118
  additionalFiles:
109
119
  [
110
120
  ("src/global.json", """
@@ -114,23 +124,23 @@ public partial class UpdateWorkerTests
114
124
  "rollForward": "latestPatch"
115
125
  },
116
126
  "msbuild-sdks": {
117
- "Microsoft.Build.Traversal": "3.2.0"
127
+ "Some.MSBuild.Sdk": "3.2.0"
118
128
  }
119
129
  }
120
130
  """)
121
131
  ],
122
132
  // expected
123
133
  expectedProjectContents: """
124
- <Project Sdk="Microsoft.NET.Sdk">
125
- <PropertyGroup>
126
- <TargetFramework>netstandard2.0</TargetFramework>
127
- </PropertyGroup>
134
+ <Project Sdk="Microsoft.NET.Sdk">
135
+ <PropertyGroup>
136
+ <TargetFramework>net8.0</TargetFramework>
137
+ </PropertyGroup>
128
138
 
129
- <ItemGroup>
130
- <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
131
- </ItemGroup>
132
- </Project>
133
- """,
139
+ <ItemGroup>
140
+ <PackageReference Include="Some.Package" Version="13.0.3" />
141
+ </ItemGroup>
142
+ </Project>
143
+ """,
134
144
  additionalFilesExpected:
135
145
  [
136
146
  ("src/global.json", """
@@ -140,29 +150,36 @@ public partial class UpdateWorkerTests
140
150
  "rollForward": "latestPatch"
141
151
  },
142
152
  "msbuild-sdks": {
143
- "Microsoft.Build.Traversal": "4.1.0"
153
+ "Some.MSBuild.Sdk": "4.1.0"
144
154
  }
145
155
  }
146
156
  """)
147
- ]);
157
+ ]
158
+ );
148
159
  }
149
160
 
150
161
  [Fact]
151
162
  public async Task UpdateDependencyWithComments()
152
163
  {
153
- await TestUpdateForProject("Microsoft.Build.Traversal", "3.2.0", "4.1.0",
164
+ await TestUpdateForProject("Some.MSBuild.Sdk", "3.2.0", "4.1.0",
165
+ packages:
166
+ [
167
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.3", "net8.0"),
168
+ MockNuGetPackage.CreateMSBuildSdkPackage("Some.MSBuild.Sdk", "3.2.0"),
169
+ MockNuGetPackage.CreateMSBuildSdkPackage("Some.MSBuild.Sdk", "4.1.0"),
170
+ ],
154
171
  // initial
155
172
  projectContents: """
156
- <Project Sdk="Microsoft.NET.Sdk">
157
- <PropertyGroup>
158
- <TargetFramework>netstandard2.0</TargetFramework>
159
- </PropertyGroup>
173
+ <Project Sdk="Microsoft.NET.Sdk">
174
+ <PropertyGroup>
175
+ <TargetFramework>net8.0</TargetFramework>
176
+ </PropertyGroup>
160
177
 
161
- <ItemGroup>
162
- <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
163
- </ItemGroup>
164
- </Project>
165
- """,
178
+ <ItemGroup>
179
+ <PackageReference Include="Some.Package" Version="13.0.3" />
180
+ </ItemGroup>
181
+ </Project>
182
+ """,
166
183
  additionalFiles:
167
184
  [
168
185
  ("global.json", """
@@ -174,23 +191,23 @@ public partial class UpdateWorkerTests
174
191
  },
175
192
  "msbuild-sdks": {
176
193
  // this is a deep comment
177
- "Microsoft.Build.Traversal": "3.2.0"
194
+ "Some.MSBuild.Sdk": "3.2.0"
178
195
  }
179
196
  }
180
197
  """)
181
198
  ],
182
199
  // expected
183
200
  expectedProjectContents: """
184
- <Project Sdk="Microsoft.NET.Sdk">
185
- <PropertyGroup>
186
- <TargetFramework>netstandard2.0</TargetFramework>
187
- </PropertyGroup>
201
+ <Project Sdk="Microsoft.NET.Sdk">
202
+ <PropertyGroup>
203
+ <TargetFramework>net8.0</TargetFramework>
204
+ </PropertyGroup>
188
205
 
189
- <ItemGroup>
190
- <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
191
- </ItemGroup>
192
- </Project>
193
- """,
206
+ <ItemGroup>
207
+ <PackageReference Include="Some.Package" Version="13.0.3" />
208
+ </ItemGroup>
209
+ </Project>
210
+ """,
194
211
  additionalFilesExpected:
195
212
  [
196
213
  ("global.json", """
@@ -202,11 +219,12 @@ public partial class UpdateWorkerTests
202
219
  },
203
220
  "msbuild-sdks": {
204
221
  // this is a deep comment
205
- "Microsoft.Build.Traversal": "4.1.0"
222
+ "Some.MSBuild.Sdk": "4.1.0"
206
223
  }
207
224
  }
208
225
  """)
209
- ]);
226
+ ]
227
+ );
210
228
  }
211
229
  }
212
230
  }
@@ -1,5 +1,3 @@
1
- using System.Threading.Tasks;
2
-
3
1
  using Xunit;
4
2
 
5
3
  namespace NuGetUpdater.Core.Test.Update;
@@ -11,74 +9,79 @@ public partial class UpdateWorkerTests
11
9
  [Fact]
12
10
  public async Task ForPackagesProject_UpdatePackageReference_InBuildProps()
13
11
  {
14
- // update Newtonsoft.Json from 7.0.1 to 13.0.1
15
- await TestUpdateForProject("Newtonsoft.Json", "7.0.1", "13.0.1",
12
+ // update Some.Package from 7.0.1 to 13.0.1
13
+ await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1",
14
+ packages:
15
+ [
16
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net45"),
17
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net45"),
18
+ ],
16
19
  // existing
17
20
  projectContents: """
18
- <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
19
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
20
- <PropertyGroup>
21
- <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
22
- </PropertyGroup>
23
- <ItemGroup>
24
- <None Include="packages.config" />
25
- </ItemGroup>
26
- <ItemGroup>
27
- <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
28
- <HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
29
- <Private>True</Private>
30
- </Reference>
31
- </ItemGroup>
32
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
33
- </Project>
34
- """,
21
+ <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
23
+ <PropertyGroup>
24
+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
25
+ </PropertyGroup>
26
+ <ItemGroup>
27
+ <None Include="packages.config" />
28
+ </ItemGroup>
29
+ <ItemGroup>
30
+ <Reference Include="Some.Package">
31
+ <HintPath>packages\Some.Package.13.0.1\lib\net45\Some.Package.dll</HintPath>
32
+ <Private>True</Private>
33
+ </Reference>
34
+ </ItemGroup>
35
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
36
+ </Project>
37
+ """,
35
38
  additionalFiles:
36
39
  [
37
40
  ("packages.config", """
38
41
  <?xml version="1.0" encoding="utf-8"?>
39
42
  <packages>
40
- <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net45" />
43
+ <package id="Some.Package" version="13.0.1" targetFramework="net45" />
41
44
  </packages>
42
45
  """),
43
46
  ("Directory.Build.props", """
44
47
  <Project>
45
48
  <ItemGroup>
46
- <PackageReference Include="Newtonsoft.Json" Version="7.0.1" />
49
+ <PackageReference Include="Some.Package" Version="7.0.1" />
47
50
  </ItemGroup>
48
51
  </Project>
49
52
  """)
50
53
  ],
51
54
  // expected
52
55
  expectedProjectContents: """
53
- <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
54
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
55
- <PropertyGroup>
56
- <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
57
- </PropertyGroup>
58
- <ItemGroup>
59
- <None Include="packages.config" />
60
- </ItemGroup>
61
- <ItemGroup>
62
- <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
63
- <HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
64
- <Private>True</Private>
65
- </Reference>
66
- </ItemGroup>
67
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
68
- </Project>
69
- """,
56
+ <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
57
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
58
+ <PropertyGroup>
59
+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
60
+ </PropertyGroup>
61
+ <ItemGroup>
62
+ <None Include="packages.config" />
63
+ </ItemGroup>
64
+ <ItemGroup>
65
+ <Reference Include="Some.Package">
66
+ <HintPath>packages\Some.Package.13.0.1\lib\net45\Some.Package.dll</HintPath>
67
+ <Private>True</Private>
68
+ </Reference>
69
+ </ItemGroup>
70
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
71
+ </Project>
72
+ """,
70
73
  additionalFilesExpected:
71
74
  [
72
75
  ("packages.config", """
73
76
  <?xml version="1.0" encoding="utf-8"?>
74
77
  <packages>
75
- <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net45" />
78
+ <package id="Some.Package" version="13.0.1" targetFramework="net45" />
76
79
  </packages>
77
80
  """),
78
81
  ("Directory.Build.props", """
79
82
  <Project>
80
83
  <ItemGroup>
81
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
84
+ <PackageReference Include="Some.Package" Version="13.0.1" />
82
85
  </ItemGroup>
83
86
  </Project>
84
87
  """)