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,4 +1,5 @@
1
- using System.Threading.Tasks;
1
+ using System.Linq;
2
+ using System.Text;
2
3
 
3
4
  using Xunit;
4
5
 
@@ -10,160 +11,180 @@ public partial class UpdateWorkerTests
10
11
  {
11
12
  [Theory]
12
13
  [InlineData("net472")]
13
- [InlineData("netstandard2.0")]
14
- [InlineData("net5.0")]
15
- [InlineData("net6.0")]
16
14
  [InlineData("net7.0")]
17
15
  [InlineData("net8.0")]
18
16
  public async Task UpdateVersionAttribute_InProjectFile_ForPackageReferenceInclude(string tfm)
19
17
  {
20
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
21
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
18
+ // update Some.Package from 9.0.1 to 13.0.1
19
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
20
+ packages:
21
+ [
22
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", tfm),
23
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", tfm),
24
+ ],
22
25
  // initial
23
26
  projectContents: $"""
24
- <Project Sdk="Microsoft.NET.Sdk">
25
- <PropertyGroup>
26
- <TargetFramework>{tfm}</TargetFramework>
27
- </PropertyGroup>
27
+ <Project Sdk="Microsoft.NET.Sdk">
28
+ <PropertyGroup>
29
+ <TargetFramework>{tfm}</TargetFramework>
30
+ </PropertyGroup>
28
31
 
29
- <ItemGroup>
30
- <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
31
- </ItemGroup>
32
- </Project>
33
- """,
32
+ <ItemGroup>
33
+ <PackageReference Include="Some.Package" Version="9.0.1" />
34
+ </ItemGroup>
35
+ </Project>
36
+ """,
34
37
  // expected
35
38
  expectedProjectContents: $"""
36
- <Project Sdk="Microsoft.NET.Sdk">
37
- <PropertyGroup>
38
- <TargetFramework>{tfm}</TargetFramework>
39
- </PropertyGroup>
39
+ <Project Sdk="Microsoft.NET.Sdk">
40
+ <PropertyGroup>
41
+ <TargetFramework>{tfm}</TargetFramework>
42
+ </PropertyGroup>
40
43
 
41
- <ItemGroup>
42
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
43
- </ItemGroup>
44
- </Project>
45
- """);
44
+ <ItemGroup>
45
+ <PackageReference Include="Some.Package" Version="13.0.1" />
46
+ </ItemGroup>
47
+ </Project>
48
+ """
49
+ );
46
50
  }
47
51
 
48
52
  [Fact]
49
53
  public async Task UpdateVersionChildElement_InProjectFile_ForPackageReferenceInclude()
50
54
  {
51
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
52
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
55
+ // update Some.Package from 9.0.1 to 13.0.1
56
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
57
+ packages:
58
+ [
59
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
60
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
61
+ ],
53
62
  // initial
54
63
  projectContents: $"""
55
- <Project Sdk="Microsoft.NET.Sdk">
56
- <PropertyGroup>
57
- <TargetFramework>netstandard2.0</TargetFramework>
58
- </PropertyGroup>
59
- <ItemGroup>
60
- <PackageReference Include="Newtonsoft.Json">
61
- <Version>9.0.1</Version>
62
- </PackageReference>
63
- </ItemGroup>
64
- </Project>
65
- """,
64
+ <Project Sdk="Microsoft.NET.Sdk">
65
+ <PropertyGroup>
66
+ <TargetFramework>net8.0</TargetFramework>
67
+ </PropertyGroup>
68
+ <ItemGroup>
69
+ <PackageReference Include="Some.Package">
70
+ <Version>9.0.1</Version>
71
+ </PackageReference>
72
+ </ItemGroup>
73
+ </Project>
74
+ """,
66
75
  // expected
67
76
  expectedProjectContents: $"""
68
- <Project Sdk="Microsoft.NET.Sdk">
69
- <PropertyGroup>
70
- <TargetFramework>netstandard2.0</TargetFramework>
71
- </PropertyGroup>
72
- <ItemGroup>
73
- <PackageReference Include="Newtonsoft.Json">
74
- <Version>13.0.1</Version>
75
- </PackageReference>
76
- </ItemGroup>
77
- </Project>
78
- """);
77
+ <Project Sdk="Microsoft.NET.Sdk">
78
+ <PropertyGroup>
79
+ <TargetFramework>net8.0</TargetFramework>
80
+ </PropertyGroup>
81
+ <ItemGroup>
82
+ <PackageReference Include="Some.Package">
83
+ <Version>13.0.1</Version>
84
+ </PackageReference>
85
+ </ItemGroup>
86
+ </Project>
87
+ """
88
+ );
79
89
  }
80
90
 
81
91
  [Fact]
82
92
  public async Task UpdateVersions_InProjectFile_ForDuplicatePackageReferenceInclude()
83
93
  {
84
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
85
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
94
+ // update Some.Package from 9.0.1 to 13.0.1
95
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
96
+ packages:
97
+ [
98
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
99
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
100
+ ],
86
101
  // initial
87
102
  projectContents: $"""
88
- <Project Sdk="Microsoft.NET.Sdk">
89
- <PropertyGroup>
90
- <TargetFramework>netstandard2.0</TargetFramework>
91
- </PropertyGroup>
92
- <ItemGroup>
93
- <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
94
- <PackageReference Include="Newtonsoft.Json">
95
- <Version>9.0.1</Version>
96
- </PackageReference>
97
- </ItemGroup>
98
- </Project>
99
- """,
103
+ <Project Sdk="Microsoft.NET.Sdk">
104
+ <PropertyGroup>
105
+ <TargetFramework>net8.0</TargetFramework>
106
+ </PropertyGroup>
107
+ <ItemGroup>
108
+ <PackageReference Include="Some.Package" Version="9.0.1" />
109
+ <PackageReference Include="Some.Package">
110
+ <Version>9.0.1</Version>
111
+ </PackageReference>
112
+ </ItemGroup>
113
+ </Project>
114
+ """,
100
115
  // expected
101
116
  expectedProjectContents: $"""
102
- <Project Sdk="Microsoft.NET.Sdk">
103
- <PropertyGroup>
104
- <TargetFramework>netstandard2.0</TargetFramework>
105
- </PropertyGroup>
106
- <ItemGroup>
107
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
108
- <PackageReference Include="Newtonsoft.Json">
109
- <Version>13.0.1</Version>
110
- </PackageReference>
111
- </ItemGroup>
112
- </Project>
113
- """);
117
+ <Project Sdk="Microsoft.NET.Sdk">
118
+ <PropertyGroup>
119
+ <TargetFramework>net8.0</TargetFramework>
120
+ </PropertyGroup>
121
+ <ItemGroup>
122
+ <PackageReference Include="Some.Package" Version="13.0.1" />
123
+ <PackageReference Include="Some.Package">
124
+ <Version>13.0.1</Version>
125
+ </PackageReference>
126
+ </ItemGroup>
127
+ </Project>
128
+ """
129
+ );
114
130
  }
115
131
 
116
132
  [Fact]
117
133
  public async Task PartialUpdate_InMultipleProjectFiles_ForVersionConstraint()
118
134
  {
119
- // update Newtonsoft.Json from 12.0.1 to 13.0.1
120
- await TestUpdateForProject("Newtonsoft.Json", "12.0.1", "13.0.1",
135
+ // update Some.Package from 12.0.1 to 13.0.1
136
+ await TestUpdateForProject("Some.Package", "12.0.1", "13.0.1",
137
+ packages:
138
+ [
139
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "12.0.1", "net8.0"),
140
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
141
+ ],
121
142
  // initial
122
143
  projectContents: $"""
123
- <Project Sdk="Microsoft.NET.Sdk">
124
- <PropertyGroup>
125
- <TargetFramework>netstandard2.0</TargetFramework>
126
- </PropertyGroup>
127
- <ItemGroup>
128
- <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
129
- <ProjectReference Include="../Project/Project.csproj" />
130
- </ItemGroup>
131
- </Project>
132
- """,
144
+ <Project Sdk="Microsoft.NET.Sdk">
145
+ <PropertyGroup>
146
+ <TargetFramework>net8.0</TargetFramework>
147
+ </PropertyGroup>
148
+ <ItemGroup>
149
+ <PackageReference Include="Some.Package" Version="12.0.1" />
150
+ <ProjectReference Include="../Project/Project.csproj" />
151
+ </ItemGroup>
152
+ </Project>
153
+ """,
133
154
  additionalFiles:
134
155
  [
135
156
  (Path: "src/Project/Project.csproj", Content: """
136
157
  <Project Sdk="Microsoft.NET.Sdk">
137
158
  <PropertyGroup>
138
- <TargetFramework>netstandard2.0</TargetFramework>
159
+ <TargetFramework>net8.0</TargetFramework>
139
160
  </PropertyGroup>
140
161
  <ItemGroup>
141
- <PackageReference Include="Newtonsoft.Json" Version="[12.0.1, 13.0.0)" />
162
+ <PackageReference Include="Some.Package" Version="[12.0.1, 13.0.0)" />
142
163
  </ItemGroup>
143
164
  </Project>
144
165
  """),
145
166
  ],
146
167
  // expected
147
168
  expectedProjectContents: $"""
148
- <Project Sdk="Microsoft.NET.Sdk">
149
- <PropertyGroup>
150
- <TargetFramework>netstandard2.0</TargetFramework>
151
- </PropertyGroup>
152
- <ItemGroup>
153
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
154
- <ProjectReference Include="../Project/Project.csproj" />
155
- </ItemGroup>
156
- </Project>
157
- """,
169
+ <Project Sdk="Microsoft.NET.Sdk">
170
+ <PropertyGroup>
171
+ <TargetFramework>net8.0</TargetFramework>
172
+ </PropertyGroup>
173
+ <ItemGroup>
174
+ <PackageReference Include="Some.Package" Version="13.0.1" />
175
+ <ProjectReference Include="../Project/Project.csproj" />
176
+ </ItemGroup>
177
+ </Project>
178
+ """,
158
179
  additionalFilesExpected:
159
180
  [
160
181
  (Path: "src/Project/Project.csproj", Content: """
161
182
  <Project Sdk="Microsoft.NET.Sdk">
162
183
  <PropertyGroup>
163
- <TargetFramework>netstandard2.0</TargetFramework>
184
+ <TargetFramework>net8.0</TargetFramework>
164
185
  </PropertyGroup>
165
186
  <ItemGroup>
166
- <PackageReference Include="Newtonsoft.Json" Version="[12.0.1, 13.0.0)" />
187
+ <PackageReference Include="Some.Package" Version="[12.0.1, 13.0.0)" />
167
188
  </ItemGroup>
168
189
  </Project>
169
190
  """),
@@ -173,57 +194,82 @@ public partial class UpdateWorkerTests
173
194
  [Fact]
174
195
  public async Task UpdateVersionAttribute_InProjectFile_ForPackageReferenceInclude_Windows()
175
196
  {
176
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
177
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
197
+ // update Some.Package from 9.0.1 to 13.0.1
198
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
199
+ packages:
200
+ [
201
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
202
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
203
+ // necessary for the `net8.0-windows10.0.19041.0` TFM
204
+ new("Microsoft.Windows.SDK.NET.Ref", "10.0.19041.31", Files:
205
+ [
206
+ ("data/FrameworkList.xml", Encoding.UTF8.GetBytes("""
207
+ <FileList Name="Windows SDK .NET 6.0">
208
+ <!-- contents omitted -->
209
+ </FileList>
210
+ """)),
211
+ ("data/RuntimeList.xml", Encoding.UTF8.GetBytes("""
212
+ <FileList Name="Windows SDK .NET 6.0" TargetFrameworkIdentifier=".NETCoreApp" TargetFrameworkVersion="6.0" FrameworkName="Microsoft.Windows.SDK.NET.Ref">
213
+ <!-- contents omitted -->
214
+ </FileList>
215
+ """)),
216
+ ]),
217
+ ],
178
218
  // initial
179
219
  projectContents: $"""
180
- <Project Sdk="Microsoft.NET.Sdk">
181
- <PropertyGroup>
182
- <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
183
- <RuntimeIdentifier>win-x64</RuntimeIdentifier>
184
- </PropertyGroup>
220
+ <Project Sdk="Microsoft.NET.Sdk">
221
+ <PropertyGroup>
222
+ <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
223
+ <RuntimeIdentifier>win-x64</RuntimeIdentifier>
224
+ </PropertyGroup>
185
225
 
186
- <ItemGroup>
187
- <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
188
- </ItemGroup>
189
- </Project>
190
- """,
226
+ <ItemGroup>
227
+ <PackageReference Include="Some.Package" Version="9.0.1" />
228
+ </ItemGroup>
229
+ </Project>
230
+ """,
191
231
  // expected
192
232
  expectedProjectContents: $"""
193
- <Project Sdk="Microsoft.NET.Sdk">
194
- <PropertyGroup>
195
- <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
196
- <RuntimeIdentifier>win-x64</RuntimeIdentifier>
197
- </PropertyGroup>
233
+ <Project Sdk="Microsoft.NET.Sdk">
234
+ <PropertyGroup>
235
+ <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
236
+ <RuntimeIdentifier>win-x64</RuntimeIdentifier>
237
+ </PropertyGroup>
198
238
 
199
- <ItemGroup>
200
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
201
- </ItemGroup>
202
- </Project>
203
- """);
239
+ <ItemGroup>
240
+ <PackageReference Include="Some.Package" Version="13.0.1" />
241
+ </ItemGroup>
242
+ </Project>
243
+ """
244
+ );
204
245
  }
205
246
 
206
247
  [Fact]
207
248
  public async Task UpdateVersionAttribute_InMultipleProjectFiles_ForPackageReferenceInclude()
208
249
  {
209
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
210
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
250
+ // update Some.Package from 9.0.1 to 13.0.1
251
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
252
+ packages:
253
+ [
254
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
255
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
256
+ ],
211
257
  // initial
212
258
  projectContents: $"""
213
- <Project Sdk="Microsoft.NET.Sdk">
214
- <PropertyGroup>
215
- <TargetFramework>net8.0</TargetFramework>
216
- </PropertyGroup>
259
+ <Project Sdk="Microsoft.NET.Sdk">
260
+ <PropertyGroup>
261
+ <TargetFramework>net8.0</TargetFramework>
262
+ </PropertyGroup>
217
263
 
218
- <ItemGroup>
219
- <ProjectReference Include="lib\Library.csproj" />
220
- </ItemGroup>
264
+ <ItemGroup>
265
+ <ProjectReference Include="lib\Library.csproj" />
266
+ </ItemGroup>
221
267
 
222
- <ItemGroup>
223
- <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
224
- </ItemGroup>
225
- </Project>
226
- """,
268
+ <ItemGroup>
269
+ <PackageReference Include="Some.Package" Version="9.0.1" />
270
+ </ItemGroup>
271
+ </Project>
272
+ """,
227
273
  additionalFiles:
228
274
  [
229
275
  ("lib/Library.csproj", $"""
@@ -233,27 +279,27 @@ public partial class UpdateWorkerTests
233
279
  </PropertyGroup>
234
280
 
235
281
  <ItemGroup>
236
- <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
282
+ <PackageReference Include="Some.Package" Version="9.0.1" />
237
283
  </ItemGroup>
238
284
  </Project>
239
285
  """)
240
286
  ],
241
287
  // expected
242
288
  expectedProjectContents: $"""
243
- <Project Sdk="Microsoft.NET.Sdk">
244
- <PropertyGroup>
245
- <TargetFramework>net8.0</TargetFramework>
246
- </PropertyGroup>
289
+ <Project Sdk="Microsoft.NET.Sdk">
290
+ <PropertyGroup>
291
+ <TargetFramework>net8.0</TargetFramework>
292
+ </PropertyGroup>
247
293
 
248
- <ItemGroup>
249
- <ProjectReference Include="lib\Library.csproj" />
250
- </ItemGroup>
294
+ <ItemGroup>
295
+ <ProjectReference Include="lib\Library.csproj" />
296
+ </ItemGroup>
251
297
 
252
- <ItemGroup>
253
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
254
- </ItemGroup>
255
- </Project>
256
- """,
298
+ <ItemGroup>
299
+ <PackageReference Include="Some.Package" Version="13.0.1" />
300
+ </ItemGroup>
301
+ </Project>
302
+ """,
257
303
  additionalFilesExpected:
258
304
  [
259
305
  ("lib/Library.csproj", $"""
@@ -263,7 +309,7 @@ public partial class UpdateWorkerTests
263
309
  </PropertyGroup>
264
310
 
265
311
  <ItemGroup>
266
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
312
+ <PackageReference Include="Some.Package" Version="13.0.1" />
267
313
  </ItemGroup>
268
314
  </Project>
269
315
  """)
@@ -271,94 +317,120 @@ public partial class UpdateWorkerTests
271
317
  }
272
318
 
273
319
  [Theory]
274
- [InlineData("$(NewtonsoftJsonVersion")]
275
- [InlineData("$NewtonsoftJsonVersion)")]
276
- [InlineData("$NewtonsoftJsonVersion")]
277
- [InlineData("NewtonsoftJsonVersion)")]
320
+ [InlineData("$(SomePackageVersion")]
321
+ [InlineData("$SomePackageVersion)")]
322
+ [InlineData("$SomePackageVersion")]
323
+ [InlineData("SomePackageVersion)")]
278
324
  public async Task Update_InvalidFile_DoesNotThrow(string versionString)
279
325
  {
280
- await TestNoChangeforProject("Newtonsoft.Json", "9.0.1", "13.0.1",
281
- $"""
282
- <Project Sdk="Microsoft.NET.Sdk">">
283
- <PropertyGroup>
284
- <TargetFramework>netstandard2.0</TargetFramework>
285
- <NewtonsoftJsonVersion>9.0.1</NewtonsoftJsonVersion>
286
- </PropertyGroup>
287
- <ItemGroup>
288
- <PackageReference Include="Newtonsoft.Json" Version="{versionString}" />
289
- </ItemGroup>
290
- </Project>
291
- """);
326
+ await TestNoChangeforProject("Some.Package", "9.0.1", "13.0.1",
327
+ packages:
328
+ [
329
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
330
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
331
+ ],
332
+ projectContents: $"""
333
+ <Project Sdk="Microsoft.NET.Sdk">">
334
+ <PropertyGroup>
335
+ <TargetFramework>net8.0</TargetFramework>
336
+ <SomePackageVersion>9.0.1</SomePackageVersion>
337
+ </PropertyGroup>
338
+ <ItemGroup>
339
+ <PackageReference Include="Some.Package" Version="{versionString}" />
340
+ </ItemGroup>
341
+ </Project>
342
+ """
343
+ );
292
344
  }
293
345
 
294
346
  [Fact]
295
347
  public async Task UpdateFindsNearestNugetConfig_AndSucceeds()
296
348
  {
297
- // Clean the cache to ensure we don't find a cached version of packages.
298
- await ProcessEx.RunAsync("dotnet", "nuget locals -c all");
299
- // If the Top-Level NugetConfig was found we would have failed.
300
- var privateNugetContent = """
349
+ //
350
+ // this test needs a very specific setup to run, so we have to do it manually
351
+ //
352
+ using TemporaryDirectory tempDirectory = new();
353
+
354
+ // the top-level NuGet.Config has a package feed that doesn't exist
355
+ await File.WriteAllTextAsync(Path.Combine(tempDirectory.DirectoryPath, "NuGet.Config"), """
301
356
  <?xml version="1.0" encoding="utf-8"?>
302
357
  <configuration>
303
-
304
358
  <packageSources>
305
359
  <clear />
306
- <add key="nuget_PrivateFeed" value="https://api.nuget.org/v3/index.json" />
360
+ <add key="local-feed" value="/var/path/that/does/not/exist" />
307
361
  </packageSources>
308
362
  </configuration>
309
- """;
310
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
311
- projectFile: (Path: "Directory/Project.csproj", Content: """
312
- <Project Sdk="Microsoft.NET.Sdk">
313
- <PropertyGroup>
314
- <TargetFramework>netstandard2.0</TargetFramework>
315
- </PropertyGroup>
316
- <ItemGroup>
317
- <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
318
- </ItemGroup>
319
- </Project>
320
- """),
321
363
  """
364
+ );
365
+
366
+ // now place the "real" test files under `src/`
367
+ string srcDirectory = Path.Combine(tempDirectory.DirectoryPath, "src");
368
+ Directory.CreateDirectory(srcDirectory);
369
+
370
+ // the project file
371
+ string projectPath = Path.Combine(srcDirectory, "project.csproj");
372
+ await File.WriteAllTextAsync(projectPath, """
322
373
  <Project Sdk="Microsoft.NET.Sdk">
323
374
  <PropertyGroup>
324
- <TargetFramework>netstandard2.0</TargetFramework>
375
+ <TargetFramework>net8.0</TargetFramework>
325
376
  </PropertyGroup>
326
377
  <ItemGroup>
327
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
378
+ <PackageReference Include="Some.Package" Version="1.0.0" />
328
379
  </ItemGroup>
329
380
  </Project>
330
- """,
331
- additionalFiles:
381
+ """
382
+ );
383
+ // another NuGet.Config, but with a usable package feed
384
+ string packageFeedLocation = Path.Combine(tempDirectory.DirectoryPath, "test-package-feed");
385
+ Directory.CreateDirectory(packageFeedLocation);
386
+ await File.WriteAllTextAsync(Path.Combine(srcDirectory, "NuGet.Config"), $"""
387
+ <?xml version="1.0" encoding="utf-8"?>
388
+ <configuration>
389
+ <packageSources>
390
+ <clear />
391
+ <add key="local-feed" value="{packageFeedLocation}" />
392
+ </packageSources>
393
+ </configuration>
394
+ """
395
+ );
396
+ // populate some packages
397
+ foreach (MockNuGetPackage package in MockNuGetPackage.CommonPackages.Concat(
332
398
  [
333
- (Path: "NuGet.config", Content: $"""
334
- <?xml version="1.0" encoding="utf-8"?>
335
- <configuration>
336
- <packageSources>
337
- <clear />
338
- <add key="nuget_PublicFeed" value="https://api.nuget.org/v3/BROKEN.json" />
339
- </packageSources>
340
- </configuration>
341
- """),
342
- (Path: "Directory/NuGet.config", Content: privateNugetContent)
343
- ]);
399
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0"),
400
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.1.0", "net8.0")
401
+ ]))
402
+ {
403
+ package.WriteToDirectory(packageFeedLocation);
404
+ }
405
+
406
+ //
407
+ // do the update
408
+ //
409
+ UpdaterWorker worker = new(new(verbose: true));
410
+ await worker.RunAsync(tempDirectory.DirectoryPath, projectPath, "Some.Package", "1.0.0", "1.1.0", isTransitive: false);
411
+
412
+ //
413
+ // verify the update occurred
414
+ //
415
+ string actualProjectContents = await File.ReadAllTextAsync(projectPath);
416
+ Assert.Contains("Version=\"1.1.0\"", actualProjectContents);
344
417
  }
345
418
 
346
419
  [Fact]
347
420
  public async Task UpdateReturnsEmptyArray_WhenBuildFails()
348
421
  {
349
- // Clean the cache to ensure we don't find a cached version of packages.
350
- await ProcessEx.RunAsync("dotnet", $"nuget locals -c all");
351
- await TestNoChangeforProject("Newtonsoft.Json", "9.0.1", "13.0.1",
352
- """
353
- <Project Sdk="Microsoft.NET.Sdk">
354
- <PropertyGroup>
355
- <TargetFramework>netstandard2.0</TargetFramework>
356
- </PropertyGroup>
357
- <ItemGroup>
358
- <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
359
- </ItemGroup>
360
- </Project>
361
- """,
422
+ await TestNoChangeforProject("Some.Package", "9.0.1", "13.0.1",
423
+ packages: [], // nothing specified, update will fail
424
+ projectContents: """
425
+ <Project Sdk="Microsoft.NET.Sdk">
426
+ <PropertyGroup>
427
+ <TargetFramework>netstandard2.0</TargetFramework>
428
+ </PropertyGroup>
429
+ <ItemGroup>
430
+ <PackageReference Include="Some.Package" Version="9.0.1" />
431
+ </ItemGroup>
432
+ </Project>
433
+ """,
362
434
  additionalFiles:
363
435
  [
364
436
  (Path: "NuGet.config", Content: """
@@ -373,198 +445,236 @@ public partial class UpdateWorkerTests
373
445
  </packageSources>
374
446
  </configuration>
375
447
  """)
376
- ]);
448
+ ]
449
+ );
377
450
  }
378
451
 
379
452
  [Fact]
380
453
  public async Task UpdateExactMatchVersionAttribute_InProjectFile_ForPackageReferenceInclude()
381
454
  {
382
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
383
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
455
+ // update Some.Package from 9.0.1 to 13.0.1
456
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
457
+ packages:
458
+ [
459
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
460
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
461
+ ],
384
462
  // initial
385
463
  projectContents: """
386
- <Project Sdk="Microsoft.NET.Sdk">
387
- <PropertyGroup>
388
- <TargetFramework>net6.0</TargetFramework>
389
- </PropertyGroup>
464
+ <Project Sdk="Microsoft.NET.Sdk">
465
+ <PropertyGroup>
466
+ <TargetFramework>net8.0</TargetFramework>
467
+ </PropertyGroup>
390
468
 
391
- <ItemGroup>
392
- <PackageReference Include="Newtonsoft.Json" Version="[9.0.1]" />
393
- </ItemGroup>
394
- </Project>
395
- """,
469
+ <ItemGroup>
470
+ <PackageReference Include="Some.Package" Version="[9.0.1]" />
471
+ </ItemGroup>
472
+ </Project>
473
+ """,
396
474
  // expected
397
475
  expectedProjectContents: """
398
- <Project Sdk="Microsoft.NET.Sdk">
399
- <PropertyGroup>
400
- <TargetFramework>net6.0</TargetFramework>
401
- </PropertyGroup>
476
+ <Project Sdk="Microsoft.NET.Sdk">
477
+ <PropertyGroup>
478
+ <TargetFramework>net8.0</TargetFramework>
479
+ </PropertyGroup>
402
480
 
403
- <ItemGroup>
404
- <PackageReference Include="Newtonsoft.Json" Version="[13.0.1]" />
405
- </ItemGroup>
406
- </Project>
407
- """);
481
+ <ItemGroup>
482
+ <PackageReference Include="Some.Package" Version="[13.0.1]" />
483
+ </ItemGroup>
484
+ </Project>
485
+ """
486
+ );
408
487
  }
409
488
 
410
489
  [Fact]
411
490
  public async Task AddPackageReference_InProjectFile_ForTransientDependency()
412
491
  {
413
- // add transient System.Text.Json from 5.0.1 to 5.0.2
414
- await TestUpdateForProject("System.Text.Json", "5.0.1", "5.0.2", isTransitive: true,
492
+ // add transient package Some.Transient.Dependency from 5.0.1 to 5.0.2
493
+ await TestUpdateForProject("Some.Transient.Dependency", "5.0.1", "5.0.2", isTransitive: true,
494
+ packages:
495
+ [
496
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "3.1.3", "net8.0", [(null, [("Some.Transient.Dependency", "5.0.1")])]),
497
+ MockNuGetPackage.CreateSimplePackage("Some.Transient.Dependency", "5.0.1", "net8.0"),
498
+ MockNuGetPackage.CreateSimplePackage("Some.Transient.Dependency", "5.0.2", "net8.0"),
499
+ ],
415
500
  // initial
416
501
  projectContents: """
417
- <Project Sdk="Microsoft.NET.Sdk">
502
+ <Project Sdk="Microsoft.NET.Sdk">
418
503
 
419
- <PropertyGroup>
420
- <TargetFramework>netcoreapp3.1</TargetFramework>
421
- </PropertyGroup>
504
+ <PropertyGroup>
505
+ <TargetFramework>net8.0</TargetFramework>
506
+ </PropertyGroup>
422
507
 
423
- <ItemGroup>
424
- <PackageReference Include="Mongo2Go" Version="3.1.3" />
425
- </ItemGroup>
508
+ <ItemGroup>
509
+ <PackageReference Include="Some.Package" Version="3.1.3" />
510
+ </ItemGroup>
426
511
 
427
- </Project>
428
- """,
512
+ </Project>
513
+ """,
429
514
  // expected
430
515
  expectedProjectContents: """
431
- <Project Sdk="Microsoft.NET.Sdk">
516
+ <Project Sdk="Microsoft.NET.Sdk">
432
517
 
433
- <PropertyGroup>
434
- <TargetFramework>netcoreapp3.1</TargetFramework>
435
- </PropertyGroup>
518
+ <PropertyGroup>
519
+ <TargetFramework>net8.0</TargetFramework>
520
+ </PropertyGroup>
436
521
 
437
- <ItemGroup>
438
- <PackageReference Include="Mongo2Go" Version="3.1.3" />
439
- <PackageReference Include="System.Text.Json" Version="5.0.2" />
440
- </ItemGroup>
522
+ <ItemGroup>
523
+ <PackageReference Include="Some.Package" Version="3.1.3" />
524
+ <PackageReference Include="Some.Transient.Dependency" Version="5.0.2" />
525
+ </ItemGroup>
441
526
 
442
- </Project>
443
- """);
527
+ </Project>
528
+ """
529
+ );
444
530
  }
445
531
 
446
532
  [Fact]
447
533
  public async Task UpdateVersionAttribute_InProjectFile_ForAnalyzerPackageReferenceInclude()
448
534
  {
449
- // update Microsoft.CodeAnalysis.Analyzers from 3.3.0 to 3.3.4
450
- await TestUpdateForProject("Microsoft.CodeAnalysis.Analyzers", "3.3.0", "3.3.4",
535
+ // update Some.Analyzer from 3.3.0 to 3.3.4
536
+ await TestUpdateForProject("Some.Analyzer", "3.3.0", "3.3.4",
537
+ packages:
538
+ [
539
+ MockNuGetPackage.CreateAnalyzerPackage("Some.Analyzer", "3.3.0"),
540
+ MockNuGetPackage.CreateAnalyzerPackage("Some.Analyzer", "3.3.4"),
541
+ ],
451
542
  // initial
452
543
  projectContents: """
453
- <Project Sdk="Microsoft.NET.Sdk">
454
- <PropertyGroup>
455
- <TargetFramework>netstandard2.0</TargetFramework>
456
- </PropertyGroup>
544
+ <Project Sdk="Microsoft.NET.Sdk">
545
+ <PropertyGroup>
546
+ <TargetFramework>net8.0</TargetFramework>
547
+ </PropertyGroup>
457
548
 
458
- <ItemGroup>
459
- <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.0">
460
- <PrivateAssets>all</PrivateAssets>
461
- <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
462
- </PackageReference>
463
- </ItemGroup>
464
- </Project>
465
- """,
549
+ <ItemGroup>
550
+ <PackageReference Include="Some.Analyzer" Version="3.3.0">
551
+ <PrivateAssets>all</PrivateAssets>
552
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
553
+ </PackageReference>
554
+ </ItemGroup>
555
+ </Project>
556
+ """,
466
557
  // expected
467
558
  expectedProjectContents: """
468
- <Project Sdk="Microsoft.NET.Sdk">
469
- <PropertyGroup>
470
- <TargetFramework>netstandard2.0</TargetFramework>
471
- </PropertyGroup>
559
+ <Project Sdk="Microsoft.NET.Sdk">
560
+ <PropertyGroup>
561
+ <TargetFramework>net8.0</TargetFramework>
562
+ </PropertyGroup>
472
563
 
473
- <ItemGroup>
474
- <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4">
475
- <PrivateAssets>all</PrivateAssets>
476
- <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
477
- </PackageReference>
478
- </ItemGroup>
479
- </Project>
480
- """);
564
+ <ItemGroup>
565
+ <PackageReference Include="Some.Analyzer" Version="3.3.4">
566
+ <PrivateAssets>all</PrivateAssets>
567
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
568
+ </PackageReference>
569
+ </ItemGroup>
570
+ </Project>
571
+ """
572
+ );
481
573
  }
482
574
 
483
575
  [Fact]
484
576
  public async Task UpdateVersionAttribute_InProjectFile_ForMultiplePackageReferences()
485
577
  {
486
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
487
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
578
+ // update Some.Package from 9.0.1 to 13.0.1
579
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
580
+ packages:
581
+ [
582
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
583
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
584
+ ],
488
585
  // initial
489
586
  projectContents: """
490
- <Project Sdk="Microsoft.NET.Sdk">
491
- <PropertyGroup>
492
- <TargetFramework>netstandard2.0</TargetFramework>
493
- </PropertyGroup>
587
+ <Project Sdk="Microsoft.NET.Sdk">
588
+ <PropertyGroup>
589
+ <TargetFramework>net8.0</TargetFramework>
590
+ </PropertyGroup>
494
591
 
495
- <ItemGroup>
496
- <PackageReference Include="Newtonsoft.JSON" Version="9.0.1" />
497
- <PackageReference Update="Newtonsoft.Json" Version="9.0.1" />
498
- </ItemGroup>
499
- </Project>
500
- """,
592
+ <ItemGroup>
593
+ <PackageReference Include="Some.PACKAGE" Version="9.0.1" />
594
+ <PackageReference Update="Some.Package" Version="9.0.1" />
595
+ </ItemGroup>
596
+ </Project>
597
+ """,
501
598
  // expected
502
599
  expectedProjectContents: """
503
- <Project Sdk="Microsoft.NET.Sdk">
504
- <PropertyGroup>
505
- <TargetFramework>netstandard2.0</TargetFramework>
506
- </PropertyGroup>
600
+ <Project Sdk="Microsoft.NET.Sdk">
601
+ <PropertyGroup>
602
+ <TargetFramework>net8.0</TargetFramework>
603
+ </PropertyGroup>
507
604
 
508
- <ItemGroup>
509
- <PackageReference Include="Newtonsoft.JSON" Version="13.0.1" />
510
- <PackageReference Update="Newtonsoft.Json" Version="13.0.1" />
511
- </ItemGroup>
512
- </Project>
513
- """);
605
+ <ItemGroup>
606
+ <PackageReference Include="Some.PACKAGE" Version="13.0.1" />
607
+ <PackageReference Update="Some.Package" Version="13.0.1" />
608
+ </ItemGroup>
609
+ </Project>
610
+ """
611
+ );
514
612
  }
515
613
 
516
614
  [Fact]
517
615
  public async Task UpdateVersionAttribute_InProjectFile_ForPackageReferenceUpdate()
518
616
  {
519
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
520
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
617
+ // update Some.Package from 9.0.1 to 13.0.1
618
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
619
+ packages:
620
+ [
621
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
622
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
623
+ ],
521
624
  // initial
522
625
  projectContents: """
523
- <Project Sdk="Microsoft.NET.Sdk">
524
- <PropertyGroup>
525
- <TargetFramework>netstandard2.0</TargetFramework>
526
- </PropertyGroup>
626
+ <Project Sdk="Microsoft.NET.Sdk">
627
+ <PropertyGroup>
628
+ <TargetFramework>net8.0</TargetFramework>
629
+ </PropertyGroup>
527
630
 
528
- <ItemGroup>
529
- <PackageReference Include="Newtonsoft.Json" />
530
- <PackageReference Update="Newtonsoft.Json" Version="9.0.1" />
531
- </ItemGroup>
532
- </Project>
533
- """,
631
+ <ItemGroup>
632
+ <PackageReference Include="Some.Package" />
633
+ <PackageReference Update="Some.Package" Version="9.0.1" />
634
+ </ItemGroup>
635
+ </Project>
636
+ """,
534
637
  // expected
535
638
  expectedProjectContents: """
536
- <Project Sdk="Microsoft.NET.Sdk">
537
- <PropertyGroup>
538
- <TargetFramework>netstandard2.0</TargetFramework>
539
- </PropertyGroup>
639
+ <Project Sdk="Microsoft.NET.Sdk">
640
+ <PropertyGroup>
641
+ <TargetFramework>net8.0</TargetFramework>
642
+ </PropertyGroup>
540
643
 
541
- <ItemGroup>
542
- <PackageReference Include="Newtonsoft.Json" />
543
- <PackageReference Update="Newtonsoft.Json" Version="13.0.1" />
544
- </ItemGroup>
545
- </Project>
546
- """);
644
+ <ItemGroup>
645
+ <PackageReference Include="Some.Package" />
646
+ <PackageReference Update="Some.Package" Version="13.0.1" />
647
+ </ItemGroup>
648
+ </Project>
649
+ """
650
+ );
547
651
  }
548
652
 
549
653
  [Fact]
550
654
  public async Task UpdateVersionAttribute_InDirectoryPackages_ForPackageVersion()
551
655
  {
552
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
553
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
656
+ // update Some.Package from 9.0.1 to 13.0.1
657
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
658
+ packages:
659
+ [
660
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
661
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
662
+ ],
554
663
  // initial
555
664
  projectContents: """
556
- <Project Sdk="Microsoft.NET.Sdk">
557
- <PropertyGroup>
558
- <TargetFramework>netstandard2.0</TargetFramework>
559
- </PropertyGroup>
665
+ <Project Sdk="Microsoft.NET.Sdk">
666
+ <PropertyGroup>
667
+ <TargetFramework>net8.0</TargetFramework>
668
+ </PropertyGroup>
560
669
 
561
- <ItemGroup>
562
- <PackageReference Include="Newtonsoft.Json" />
563
- </ItemGroup>
564
- </Project>
565
- """,
670
+ <ItemGroup>
671
+ <PackageReference Include="Some.Package" />
672
+ </ItemGroup>
673
+ </Project>
674
+ """,
566
675
  additionalFiles:
567
676
  [
677
+ ("Directory.Build.props", "<Project />"),
568
678
  ("Directory.Packages.props", """
569
679
  <Project>
570
680
  <PropertyGroup>
@@ -572,23 +682,23 @@ public partial class UpdateWorkerTests
572
682
  </PropertyGroup>
573
683
 
574
684
  <ItemGroup>
575
- <PackageVersion Include="Newtonsoft.Json" Version="9.0.1" />
685
+ <PackageVersion Include="Some.Package" Version="9.0.1" />
576
686
  </ItemGroup>
577
687
  </Project>
578
688
  """)
579
689
  ],
580
690
  // expected
581
691
  expectedProjectContents: """
582
- <Project Sdk="Microsoft.NET.Sdk">
583
- <PropertyGroup>
584
- <TargetFramework>netstandard2.0</TargetFramework>
585
- </PropertyGroup>
692
+ <Project Sdk="Microsoft.NET.Sdk">
693
+ <PropertyGroup>
694
+ <TargetFramework>net8.0</TargetFramework>
695
+ </PropertyGroup>
586
696
 
587
- <ItemGroup>
588
- <PackageReference Include="Newtonsoft.Json" />
589
- </ItemGroup>
590
- </Project>
591
- """,
697
+ <ItemGroup>
698
+ <PackageReference Include="Some.Package" />
699
+ </ItemGroup>
700
+ </Project>
701
+ """,
592
702
  additionalFilesExpected:
593
703
  [
594
704
  ("Directory.Packages.props", """
@@ -598,32 +708,39 @@ public partial class UpdateWorkerTests
598
708
  </PropertyGroup>
599
709
 
600
710
  <ItemGroup>
601
- <PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
711
+ <PackageVersion Include="Some.Package" Version="13.0.1" />
602
712
  </ItemGroup>
603
713
  </Project>
604
714
  """)
605
- ]);
715
+ ]
716
+ );
606
717
  }
607
718
 
608
719
  [Fact]
609
720
  public async Task UpdateExactMatchVersionAttribute_InDirectoryPackages_ForPackageVersion()
610
721
  {
611
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
612
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
722
+ // update Some.Package from 9.0.1 to 13.0.1
723
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
724
+ packages:
725
+ [
726
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
727
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
728
+ ],
613
729
  // initial
614
730
  projectContents: """
615
- <Project Sdk="Microsoft.NET.Sdk">
616
- <PropertyGroup>
617
- <TargetFramework>netstandard2.0</TargetFramework>
618
- </PropertyGroup>
731
+ <Project Sdk="Microsoft.NET.Sdk">
732
+ <PropertyGroup>
733
+ <TargetFramework>net8.0</TargetFramework>
734
+ </PropertyGroup>
619
735
 
620
- <ItemGroup>
621
- <PackageReference Include="Newtonsoft.Json" />
622
- </ItemGroup>
623
- </Project>
624
- """,
736
+ <ItemGroup>
737
+ <PackageReference Include="Some.Package" />
738
+ </ItemGroup>
739
+ </Project>
740
+ """,
625
741
  additionalFiles:
626
742
  [
743
+ ("Directory.Build.props", "<Project />"),
627
744
  ("Directory.Packages.props", """
628
745
  <Project>
629
746
  <PropertyGroup>
@@ -631,23 +748,23 @@ public partial class UpdateWorkerTests
631
748
  </PropertyGroup>
632
749
 
633
750
  <ItemGroup>
634
- <PackageVersion Include="Newtonsoft.Json" Version="[9.0.1]" />
751
+ <PackageVersion Include="Some.Package" Version="[9.0.1]" />
635
752
  </ItemGroup>
636
753
  </Project>
637
754
  """)
638
755
  ],
639
756
  // expected
640
757
  expectedProjectContents: """
641
- <Project Sdk="Microsoft.NET.Sdk">
642
- <PropertyGroup>
643
- <TargetFramework>netstandard2.0</TargetFramework>
644
- </PropertyGroup>
758
+ <Project Sdk="Microsoft.NET.Sdk">
759
+ <PropertyGroup>
760
+ <TargetFramework>net8.0</TargetFramework>
761
+ </PropertyGroup>
645
762
 
646
- <ItemGroup>
647
- <PackageReference Include="Newtonsoft.Json" />
648
- </ItemGroup>
649
- </Project>
650
- """,
763
+ <ItemGroup>
764
+ <PackageReference Include="Some.Package" />
765
+ </ItemGroup>
766
+ </Project>
767
+ """,
651
768
  additionalFilesExpected:
652
769
  [
653
770
  ("Directory.Packages.props", """
@@ -657,407 +774,471 @@ public partial class UpdateWorkerTests
657
774
  </PropertyGroup>
658
775
 
659
776
  <ItemGroup>
660
- <PackageVersion Include="Newtonsoft.Json" Version="[13.0.1]" />
777
+ <PackageVersion Include="Some.Package" Version="[13.0.1]" />
661
778
  </ItemGroup>
662
779
  </Project>
663
780
  """)
664
- ]);
781
+ ]
782
+ );
665
783
  }
666
784
 
667
785
  [Fact]
668
786
  public async Task UpdatePropertyValue_InProjectFile_ForPackageReferenceIncludeWithExactVersion()
669
787
  {
670
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
788
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
789
+ packages:
790
+ [
791
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
792
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
793
+ ],
671
794
  // initial
672
795
  projectContents: """
673
- <Project Sdk="Microsoft.NET.Sdk">
674
- <PropertyGroup>
675
- <TargetFramework>netstandard2.0</TargetFramework>
676
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
677
- </PropertyGroup>
796
+ <Project Sdk="Microsoft.NET.Sdk">
797
+ <PropertyGroup>
798
+ <TargetFramework>net8.0</TargetFramework>
799
+ <SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
800
+ </PropertyGroup>
678
801
 
679
- <ItemGroup>
680
- <PackageReference Include="Newtonsoft.Json" Version="[$(NewtonsoftJsonPackageVersion)]" />
681
- </ItemGroup>
682
- </Project>
683
- """,
802
+ <ItemGroup>
803
+ <PackageReference Include="Some.Package" Version="[$(SomePackagePackageVersion)]" />
804
+ </ItemGroup>
805
+ </Project>
806
+ """,
684
807
  // expected
685
808
  expectedProjectContents: """
686
- <Project Sdk="Microsoft.NET.Sdk">
687
- <PropertyGroup>
688
- <TargetFramework>netstandard2.0</TargetFramework>
689
- <NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
690
- </PropertyGroup>
809
+ <Project Sdk="Microsoft.NET.Sdk">
810
+ <PropertyGroup>
811
+ <TargetFramework>net8.0</TargetFramework>
812
+ <SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
813
+ </PropertyGroup>
691
814
 
692
- <ItemGroup>
693
- <PackageReference Include="Newtonsoft.Json" Version="[$(NewtonsoftJsonPackageVersion)]" />
694
- </ItemGroup>
695
- </Project>
696
- """);
815
+ <ItemGroup>
816
+ <PackageReference Include="Some.Package" Version="[$(SomePackagePackageVersion)]" />
817
+ </ItemGroup>
818
+ </Project>
819
+ """
820
+ );
697
821
  }
698
822
 
699
823
  [Fact]
700
824
  public async Task UpdateDifferentCasedPropertyValue_InProjectFile_ForPackageReferenceInclude()
701
825
  {
702
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
826
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
827
+ packages:
828
+ [
829
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
830
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
831
+ ],
703
832
  // initial
704
833
  projectContents: """
705
- <Project Sdk="Microsoft.NET.Sdk">
706
- <PropertyGroup>
707
- <TargetFramework>netstandard2.0</TargetFramework>
708
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
709
- </PropertyGroup>
834
+ <Project Sdk="Microsoft.NET.Sdk">
835
+ <PropertyGroup>
836
+ <TargetFramework>net8.0</TargetFramework>
837
+ <SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
838
+ </PropertyGroup>
710
839
 
711
- <ItemGroup>
712
- <PackageReference Include="Newtonsoft.Json" Version="$(newtonsoftjsonpackageversion)" />
713
- </ItemGroup>
714
- </Project>
715
- """,
840
+ <ItemGroup>
841
+ <PackageReference Include="Some.Package" Version="$(somepackagepackageversion)" />
842
+ </ItemGroup>
843
+ </Project>
844
+ """,
716
845
  // expected
717
846
  expectedProjectContents: """
718
- <Project Sdk="Microsoft.NET.Sdk">
719
- <PropertyGroup>
720
- <TargetFramework>netstandard2.0</TargetFramework>
721
- <NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
722
- </PropertyGroup>
847
+ <Project Sdk="Microsoft.NET.Sdk">
848
+ <PropertyGroup>
849
+ <TargetFramework>net8.0</TargetFramework>
850
+ <SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
851
+ </PropertyGroup>
723
852
 
724
- <ItemGroup>
725
- <PackageReference Include="Newtonsoft.Json" Version="$(newtonsoftjsonpackageversion)" />
726
- </ItemGroup>
727
- </Project>
728
- """);
853
+ <ItemGroup>
854
+ <PackageReference Include="Some.Package" Version="$(somepackagepackageversion)" />
855
+ </ItemGroup>
856
+ </Project>
857
+ """
858
+ );
729
859
  }
730
860
 
731
861
  [Fact]
732
862
  public async Task UpdatePropertyValue_InProjectFile_ForPackageReferenceInclude()
733
863
  {
734
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
864
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
865
+ packages:
866
+ [
867
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
868
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
869
+ ],
735
870
  // initial
736
871
  projectContents: """
737
- <Project Sdk="Microsoft.NET.Sdk">
738
- <PropertyGroup>
739
- <TargetFramework>netstandard2.0</TargetFramework>
740
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
741
- </PropertyGroup>
872
+ <Project Sdk="Microsoft.NET.Sdk">
873
+ <PropertyGroup>
874
+ <TargetFramework>net8.0</TargetFramework>
875
+ <SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
876
+ </PropertyGroup>
742
877
 
743
- <ItemGroup>
744
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
745
- </ItemGroup>
746
- </Project>
747
- """,
878
+ <ItemGroup>
879
+ <PackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
880
+ </ItemGroup>
881
+ </Project>
882
+ """,
748
883
  // expected
749
884
  expectedProjectContents: """
750
- <Project Sdk="Microsoft.NET.Sdk">
751
- <PropertyGroup>
752
- <TargetFramework>netstandard2.0</TargetFramework>
753
- <NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
754
- </PropertyGroup>
885
+ <Project Sdk="Microsoft.NET.Sdk">
886
+ <PropertyGroup>
887
+ <TargetFramework>net8.0</TargetFramework>
888
+ <SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
889
+ </PropertyGroup>
755
890
 
756
- <ItemGroup>
757
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
758
- </ItemGroup>
759
- </Project>
760
- """);
891
+ <ItemGroup>
892
+ <PackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
893
+ </ItemGroup>
894
+ </Project>
895
+ """
896
+ );
761
897
  }
762
898
 
763
899
  [Fact]
764
900
  public async Task UpdateExactMatchPropertyValue_InProjectFile_ForPackageReferenceInclude()
765
901
  {
766
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
902
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
903
+ packages:
904
+ [
905
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
906
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
907
+ ],
767
908
  // initial
768
909
  projectContents: """
769
- <Project Sdk="Microsoft.NET.Sdk">
770
- <PropertyGroup>
771
- <TargetFramework>netstandard2.0</TargetFramework>
772
- <NewtonsoftJsonPackageVersion>[9.0.1]</NewtonsoftJsonPackageVersion>
773
- </PropertyGroup>
910
+ <Project Sdk="Microsoft.NET.Sdk">
911
+ <PropertyGroup>
912
+ <TargetFramework>net8.0</TargetFramework>
913
+ <SomePackagePackageVersion>[9.0.1]</SomePackagePackageVersion>
914
+ </PropertyGroup>
774
915
 
775
- <ItemGroup>
776
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
777
- </ItemGroup>
778
- </Project>
779
- """,
916
+ <ItemGroup>
917
+ <PackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
918
+ </ItemGroup>
919
+ </Project>
920
+ """,
780
921
  // expected
781
922
  expectedProjectContents: """
782
- <Project Sdk="Microsoft.NET.Sdk">
783
- <PropertyGroup>
784
- <TargetFramework>netstandard2.0</TargetFramework>
785
- <NewtonsoftJsonPackageVersion>[13.0.1]</NewtonsoftJsonPackageVersion>
786
- </PropertyGroup>
923
+ <Project Sdk="Microsoft.NET.Sdk">
924
+ <PropertyGroup>
925
+ <TargetFramework>net8.0</TargetFramework>
926
+ <SomePackagePackageVersion>[13.0.1]</SomePackagePackageVersion>
927
+ </PropertyGroup>
787
928
 
788
- <ItemGroup>
789
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
790
- </ItemGroup>
791
- </Project>
792
- """);
929
+ <ItemGroup>
930
+ <PackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
931
+ </ItemGroup>
932
+ </Project>
933
+ """
934
+ );
793
935
  }
794
936
 
795
937
  [Fact]
796
938
  public async Task UpdateVersionAttributeAndPropertyValue_InProjectFile_ForMultiplePackageReferences()
797
939
  {
798
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
940
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
941
+ packages:
942
+ [
943
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
944
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
945
+ ],
799
946
  // initial
800
947
  projectContents: """
801
- <Project Sdk="Microsoft.NET.Sdk">
802
- <PropertyGroup>
803
- <TargetFramework>netstandard2.0</TargetFramework>
804
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
805
- </PropertyGroup>
948
+ <Project Sdk="Microsoft.NET.Sdk">
949
+ <PropertyGroup>
950
+ <TargetFramework>net8.0</TargetFramework>
951
+ <SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
952
+ </PropertyGroup>
806
953
 
807
- <ItemGroup>
808
- <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
809
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
810
- </ItemGroup>
811
- </Project>
812
- """,
954
+ <ItemGroup>
955
+ <PackageReference Include="Some.Package" Version="9.0.1" />
956
+ <PackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
957
+ </ItemGroup>
958
+ </Project>
959
+ """,
813
960
  // expected
814
961
  expectedProjectContents: """
815
- <Project Sdk="Microsoft.NET.Sdk">
816
- <PropertyGroup>
817
- <TargetFramework>netstandard2.0</TargetFramework>
818
- <NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
819
- </PropertyGroup>
962
+ <Project Sdk="Microsoft.NET.Sdk">
963
+ <PropertyGroup>
964
+ <TargetFramework>net8.0</TargetFramework>
965
+ <SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
966
+ </PropertyGroup>
820
967
 
821
- <ItemGroup>
822
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
823
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
824
- </ItemGroup>
825
- </Project>
826
- """);
968
+ <ItemGroup>
969
+ <PackageReference Include="Some.Package" Version="13.0.1" />
970
+ <PackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
971
+ </ItemGroup>
972
+ </Project>
973
+ """
974
+ );
827
975
  }
828
976
 
829
977
  [Fact]
830
978
  public async Task UpdatePropertyValue_InProjectFile_ForPackageReferenceUpdate()
831
979
  {
832
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
980
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
981
+ packages:
982
+ [
983
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
984
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
985
+ ],
833
986
  // initial
834
987
  projectContents: """
835
- <Project Sdk="Microsoft.NET.Sdk">
836
- <PropertyGroup>
837
- <TargetFramework>netstandard2.0</TargetFramework>
838
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
839
- </PropertyGroup>
988
+ <Project Sdk="Microsoft.NET.Sdk">
989
+ <PropertyGroup>
990
+ <TargetFramework>net8.0</TargetFramework>
991
+ <SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
992
+ </PropertyGroup>
840
993
 
841
- <ItemGroup>
842
- <PackageReference Include="Newtonsoft.Json" />
843
- <PackageReference Update="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
844
- </ItemGroup>
845
- </Project>
846
- """,
994
+ <ItemGroup>
995
+ <PackageReference Include="Some.Package" />
996
+ <PackageReference Update="Some.Package" Version="$(SomePackagePackageVersion)" />
997
+ </ItemGroup>
998
+ </Project>
999
+ """,
847
1000
  // expected
848
1001
  expectedProjectContents: """
849
- <Project Sdk="Microsoft.NET.Sdk">
850
- <PropertyGroup>
851
- <TargetFramework>netstandard2.0</TargetFramework>
852
- <NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
853
- </PropertyGroup>
1002
+ <Project Sdk="Microsoft.NET.Sdk">
1003
+ <PropertyGroup>
1004
+ <TargetFramework>net8.0</TargetFramework>
1005
+ <SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
1006
+ </PropertyGroup>
854
1007
 
855
- <ItemGroup>
856
- <PackageReference Include="Newtonsoft.Json" />
857
- <PackageReference Update="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
858
- </ItemGroup>
859
- </Project>
860
- """);
1008
+ <ItemGroup>
1009
+ <PackageReference Include="Some.Package" />
1010
+ <PackageReference Update="Some.Package" Version="$(SomePackagePackageVersion)" />
1011
+ </ItemGroup>
1012
+ </Project>
1013
+ """
1014
+ );
861
1015
  }
862
1016
 
863
1017
  [Fact]
864
1018
  public async Task UpdatePropertyValue_InDirectoryProps_ForPackageVersion()
865
1019
  {
866
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
867
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
1020
+ // update Some.Package from 9.0.1 to 13.0.1
1021
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
1022
+ packages:
1023
+ [
1024
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
1025
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
1026
+ ],
868
1027
  // initial
869
1028
  projectContents: """
870
- <Project Sdk="Microsoft.NET.Sdk">
871
- <PropertyGroup>
872
- <TargetFramework>netstandard2.0</TargetFramework>
873
- </PropertyGroup>
1029
+ <Project Sdk="Microsoft.NET.Sdk">
1030
+ <PropertyGroup>
1031
+ <TargetFramework>net8.0</TargetFramework>
1032
+ </PropertyGroup>
874
1033
 
875
- <ItemGroup>
876
- <PackageReference Include="Newtonsoft.Json" />
877
- </ItemGroup>
878
- </Project>
879
- """,
1034
+ <ItemGroup>
1035
+ <PackageReference Include="Some.Package" />
1036
+ </ItemGroup>
1037
+ </Project>
1038
+ """,
880
1039
  additionalFiles:
881
1040
  [
1041
+ ("Directory.Build.props", "<Project />"),
882
1042
  ("Directory.Packages.props", """
883
1043
  <Project>
884
1044
  <PropertyGroup>
885
1045
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
886
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
1046
+ <SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
887
1047
  </PropertyGroup>
888
1048
 
889
1049
  <ItemGroup>
890
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1050
+ <PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
891
1051
  </ItemGroup>
892
1052
  </Project>
893
1053
  """)
894
1054
  ],
895
1055
  // expected
896
1056
  expectedProjectContents: """
897
- <Project Sdk="Microsoft.NET.Sdk">
898
- <PropertyGroup>
899
- <TargetFramework>netstandard2.0</TargetFramework>
900
- </PropertyGroup>
1057
+ <Project Sdk="Microsoft.NET.Sdk">
1058
+ <PropertyGroup>
1059
+ <TargetFramework>net8.0</TargetFramework>
1060
+ </PropertyGroup>
901
1061
 
902
- <ItemGroup>
903
- <PackageReference Include="Newtonsoft.Json" />
904
- </ItemGroup>
905
- </Project>
906
- """,
1062
+ <ItemGroup>
1063
+ <PackageReference Include="Some.Package" />
1064
+ </ItemGroup>
1065
+ </Project>
1066
+ """,
907
1067
  additionalFilesExpected:
908
1068
  [
909
1069
  ("Directory.Packages.props", """
910
1070
  <Project>
911
1071
  <PropertyGroup>
912
1072
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
913
- <NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
1073
+ <SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
914
1074
  </PropertyGroup>
915
1075
 
916
1076
  <ItemGroup>
917
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1077
+ <PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
918
1078
  </ItemGroup>
919
1079
  </Project>
920
1080
  """)
921
- ]);
1081
+ ]
1082
+ );
922
1083
  }
923
1084
 
924
1085
  [Fact]
925
1086
  public async Task UpdateExactMatchPropertyValue_InDirectoryProps_ForPackageVersion()
926
1087
  {
927
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
928
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
1088
+ // update Some.Package from 9.0.1 to 13.0.1
1089
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
1090
+ packages:
1091
+ [
1092
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
1093
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
1094
+ ],
929
1095
  // initial
930
1096
  projectContents: """
931
- <Project Sdk="Microsoft.NET.Sdk">
932
- <PropertyGroup>
933
- <TargetFramework>netstandard2.0</TargetFramework>
934
- </PropertyGroup>
1097
+ <Project Sdk="Microsoft.NET.Sdk">
1098
+ <PropertyGroup>
1099
+ <TargetFramework>net8.0</TargetFramework>
1100
+ </PropertyGroup>
935
1101
 
936
- <ItemGroup>
937
- <PackageReference Include="Newtonsoft.Json" />
938
- </ItemGroup>
939
- </Project>
940
- """,
1102
+ <ItemGroup>
1103
+ <PackageReference Include="Some.Package" />
1104
+ </ItemGroup>
1105
+ </Project>
1106
+ """,
941
1107
  additionalFiles:
942
1108
  [
1109
+ ("Directory.Build.props", "<Project />"),
943
1110
  ("Directory.Packages.props", """
944
1111
  <Project>
945
1112
  <PropertyGroup>
946
1113
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
947
- <NewtonsoftJsonPackageVersion>[9.0.1]</NewtonsoftJsonPackageVersion>
1114
+ <SomePackagePackageVersion>[9.0.1]</SomePackagePackageVersion>
948
1115
  </PropertyGroup>
949
1116
 
950
1117
  <ItemGroup>
951
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1118
+ <PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
952
1119
  </ItemGroup>
953
1120
  </Project>
954
1121
  """)
955
1122
  ],
956
1123
  // expected
957
1124
  expectedProjectContents: """
958
- <Project Sdk="Microsoft.NET.Sdk">
959
- <PropertyGroup>
960
- <TargetFramework>netstandard2.0</TargetFramework>
961
- </PropertyGroup>
1125
+ <Project Sdk="Microsoft.NET.Sdk">
1126
+ <PropertyGroup>
1127
+ <TargetFramework>net8.0</TargetFramework>
1128
+ </PropertyGroup>
962
1129
 
963
- <ItemGroup>
964
- <PackageReference Include="Newtonsoft.Json" />
965
- </ItemGroup>
966
- </Project>
967
- """,
1130
+ <ItemGroup>
1131
+ <PackageReference Include="Some.Package" />
1132
+ </ItemGroup>
1133
+ </Project>
1134
+ """,
968
1135
  additionalFilesExpected:
969
1136
  [
970
1137
  ("Directory.Packages.props", """
971
1138
  <Project>
972
1139
  <PropertyGroup>
973
1140
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
974
- <NewtonsoftJsonPackageVersion>[13.0.1]</NewtonsoftJsonPackageVersion>
1141
+ <SomePackagePackageVersion>[13.0.1]</SomePackagePackageVersion>
975
1142
  </PropertyGroup>
976
1143
 
977
1144
  <ItemGroup>
978
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1145
+ <PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
979
1146
  </ItemGroup>
980
1147
  </Project>
981
1148
  """)
982
- ]);
1149
+ ]
1150
+ );
983
1151
  }
984
1152
 
985
1153
  [Fact]
986
1154
  public async Task UpdateVersionOverrideAttributeAndPropertyValue_InProjectFileAndDirectoryProps_ForPackageVersion()
987
1155
  {
988
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
989
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
1156
+ // update Some.Package from 9.0.1 to 13.0.1
1157
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
1158
+ packages:
1159
+ [
1160
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
1161
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
1162
+ ],
990
1163
  // initial
991
1164
  projectContents: """
992
- <Project Sdk="Microsoft.NET.Sdk">
993
- <PropertyGroup>
994
- <TargetFramework>netstandard2.0</TargetFramework>
995
- </PropertyGroup>
1165
+ <Project Sdk="Microsoft.NET.Sdk">
1166
+ <PropertyGroup>
1167
+ <TargetFramework>net8.0</TargetFramework>
1168
+ </PropertyGroup>
996
1169
 
997
- <ItemGroup>
998
- <PackageReference Include="Newtonsoft.Json" VersionOverride="9.0.1" />
999
- </ItemGroup>
1000
- </Project>
1001
- """,
1170
+ <ItemGroup>
1171
+ <PackageReference Include="Some.Package" VersionOverride="9.0.1" />
1172
+ </ItemGroup>
1173
+ </Project>
1174
+ """,
1002
1175
  additionalFiles:
1003
1176
  [
1177
+ ("Directory.Build.props", "<Project />"),
1004
1178
  ("Directory.Packages.props", """
1005
1179
  <Project>
1006
1180
  <PropertyGroup>
1007
1181
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1008
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
1182
+ <SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
1009
1183
  </PropertyGroup>
1010
1184
 
1011
1185
  <ItemGroup>
1012
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1186
+ <PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1013
1187
  </ItemGroup>
1014
1188
  </Project>
1015
1189
  """)
1016
1190
  ],
1017
1191
  // expected
1018
1192
  expectedProjectContents: """
1019
- <Project Sdk="Microsoft.NET.Sdk">
1020
- <PropertyGroup>
1021
- <TargetFramework>netstandard2.0</TargetFramework>
1022
- </PropertyGroup>
1193
+ <Project Sdk="Microsoft.NET.Sdk">
1194
+ <PropertyGroup>
1195
+ <TargetFramework>net8.0</TargetFramework>
1196
+ </PropertyGroup>
1023
1197
 
1024
- <ItemGroup>
1025
- <PackageReference Include="Newtonsoft.Json" VersionOverride="13.0.1" />
1026
- </ItemGroup>
1027
- </Project>
1028
- """,
1198
+ <ItemGroup>
1199
+ <PackageReference Include="Some.Package" VersionOverride="13.0.1" />
1200
+ </ItemGroup>
1201
+ </Project>
1202
+ """,
1029
1203
  additionalFilesExpected:
1030
1204
  [
1031
1205
  ("Directory.Packages.props", """
1032
1206
  <Project>
1033
1207
  <PropertyGroup>
1034
1208
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1035
- <NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
1209
+ <SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
1036
1210
  </PropertyGroup>
1037
1211
 
1038
1212
  <ItemGroup>
1039
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1213
+ <PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1040
1214
  </ItemGroup>
1041
1215
  </Project>
1042
1216
  """)
1043
- ]);
1217
+ ]
1218
+ );
1044
1219
  }
1045
1220
 
1046
1221
  [Fact]
1047
1222
  public async Task UpdateVersionAttribute_InDirectoryProps_ForGlobalPackageReference()
1048
1223
  {
1049
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
1050
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
1224
+ // update Some.Package from 9.0.1 to 13.0.1
1225
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
1226
+ packages:
1227
+ [
1228
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
1229
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
1230
+ ],
1051
1231
  // initial
1052
1232
  projectContents: """
1053
- <Project Sdk="Microsoft.NET.Sdk">
1054
- <PropertyGroup>
1055
- <TargetFramework>netstandard2.0</TargetFramework>
1056
- </PropertyGroup>
1057
- </Project>
1058
- """,
1233
+ <Project Sdk="Microsoft.NET.Sdk">
1234
+ <PropertyGroup>
1235
+ <TargetFramework>net8.0</TargetFramework>
1236
+ </PropertyGroup>
1237
+ </Project>
1238
+ """,
1059
1239
  additionalFiles:
1060
1240
  [
1241
+ ("Directory.Build.props", "<Project />"),
1061
1242
  ("Directory.Packages.props", """
1062
1243
  <Project>
1063
1244
  <PropertyGroup>
@@ -1065,19 +1246,19 @@ public partial class UpdateWorkerTests
1065
1246
  </PropertyGroup>
1066
1247
 
1067
1248
  <ItemGroup>
1068
- <GlobalPackageReference Include="Newtonsoft.Json" Version="9.0.1" />
1249
+ <GlobalPackageReference Include="Some.Package" Version="9.0.1" />
1069
1250
  </ItemGroup>
1070
1251
  </Project>
1071
1252
  """)
1072
1253
  ],
1073
1254
  // expected
1074
1255
  expectedProjectContents: """
1075
- <Project Sdk="Microsoft.NET.Sdk">
1076
- <PropertyGroup>
1077
- <TargetFramework>netstandard2.0</TargetFramework>
1078
- </PropertyGroup>
1079
- </Project>
1080
- """,
1256
+ <Project Sdk="Microsoft.NET.Sdk">
1257
+ <PropertyGroup>
1258
+ <TargetFramework>net8.0</TargetFramework>
1259
+ </PropertyGroup>
1260
+ </Project>
1261
+ """,
1081
1262
  additionalFilesExpected:
1082
1263
  [
1083
1264
  ("Directory.Packages.props", """
@@ -1087,193 +1268,219 @@ public partial class UpdateWorkerTests
1087
1268
  </PropertyGroup>
1088
1269
 
1089
1270
  <ItemGroup>
1090
- <GlobalPackageReference Include="Newtonsoft.Json" Version="13.0.1" />
1271
+ <GlobalPackageReference Include="Some.Package" Version="13.0.1" />
1091
1272
  </ItemGroup>
1092
1273
  </Project>
1093
1274
  """)
1094
- ]);
1275
+ ]
1276
+ );
1095
1277
  }
1096
1278
 
1097
1279
  [Fact]
1098
1280
  public async Task UpdatePropertyValue_InDirectoryProps_ForGlobalPackageReference()
1099
1281
  {
1100
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
1101
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
1282
+ // update Some.Package from 9.0.1 to 13.0.1
1283
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
1284
+ packages:
1285
+ [
1286
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
1287
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
1288
+ ],
1102
1289
  // initial
1103
1290
  projectContents: """
1104
- <Project Sdk="Microsoft.NET.Sdk">
1105
- <PropertyGroup>
1106
- <TargetFramework>netstandard2.0</TargetFramework>
1107
- </PropertyGroup>
1108
- </Project>
1109
- """,
1291
+ <Project Sdk="Microsoft.NET.Sdk">
1292
+ <PropertyGroup>
1293
+ <TargetFramework>net8.0</TargetFramework>
1294
+ </PropertyGroup>
1295
+ </Project>
1296
+ """,
1110
1297
  additionalFiles:
1111
1298
  [
1299
+ ("Directory.Build.props", "<Project />"),
1112
1300
  ("Directory.Packages.props", """
1113
1301
  <Project>
1114
1302
  <PropertyGroup>
1115
1303
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1116
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
1304
+ <SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
1117
1305
  </PropertyGroup>
1118
1306
 
1119
1307
  <ItemGroup>
1120
- <GlobalPackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1308
+ <GlobalPackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1121
1309
  </ItemGroup>
1122
1310
  </Project>
1123
1311
  """)
1124
1312
  ],
1125
1313
  // expected
1126
1314
  expectedProjectContents: """
1127
- <Project Sdk="Microsoft.NET.Sdk">
1128
- <PropertyGroup>
1129
- <TargetFramework>netstandard2.0</TargetFramework>
1130
- </PropertyGroup>
1131
- </Project>
1132
- """,
1315
+ <Project Sdk="Microsoft.NET.Sdk">
1316
+ <PropertyGroup>
1317
+ <TargetFramework>net8.0</TargetFramework>
1318
+ </PropertyGroup>
1319
+ </Project>
1320
+ """,
1133
1321
  additionalFilesExpected:
1134
1322
  [
1135
1323
  ("Directory.Packages.props", """
1136
1324
  <Project>
1137
1325
  <PropertyGroup>
1138
1326
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1139
- <NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
1327
+ <SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
1140
1328
  </PropertyGroup>
1141
1329
 
1142
1330
  <ItemGroup>
1143
- <GlobalPackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1331
+ <GlobalPackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1144
1332
  </ItemGroup>
1145
1333
  </Project>
1146
1334
  """)
1147
- ]);
1335
+ ]
1336
+ );
1148
1337
  }
1149
1338
 
1150
1339
  [Fact]
1151
1340
  public async Task UpdatePropertyValue_InDirectoryProps_ForPackageReferenceInclude()
1152
1341
  {
1153
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
1342
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
1343
+ packages:
1344
+ [
1345
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
1346
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
1347
+ ],
1154
1348
  // initial project
1155
1349
  projectContents: """
1156
- <Project Sdk="Microsoft.NET.Sdk">
1157
- <PropertyGroup>
1158
- <TargetFramework>netstandard2.0</TargetFramework>
1159
- </PropertyGroup>
1350
+ <Project Sdk="Microsoft.NET.Sdk">
1351
+ <PropertyGroup>
1352
+ <TargetFramework>net8.0</TargetFramework>
1353
+ </PropertyGroup>
1160
1354
 
1161
- <ItemGroup>
1162
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1163
- </ItemGroup>
1164
- </Project>
1165
- """,
1355
+ <ItemGroup>
1356
+ <PackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1357
+ </ItemGroup>
1358
+ </Project>
1359
+ """,
1166
1360
  additionalFiles:
1167
1361
  [
1168
1362
  // initial props file
1169
1363
  ("Directory.Build.props", """
1170
1364
  <Project>
1171
1365
  <PropertyGroup>
1172
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
1366
+ <SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
1173
1367
  </PropertyGroup>
1174
1368
  </Project>
1175
1369
  """)
1176
1370
  ],
1177
1371
  // expected project
1178
1372
  expectedProjectContents: """
1179
- <Project Sdk="Microsoft.NET.Sdk">
1180
- <PropertyGroup>
1181
- <TargetFramework>netstandard2.0</TargetFramework>
1182
- </PropertyGroup>
1373
+ <Project Sdk="Microsoft.NET.Sdk">
1374
+ <PropertyGroup>
1375
+ <TargetFramework>net8.0</TargetFramework>
1376
+ </PropertyGroup>
1183
1377
 
1184
- <ItemGroup>
1185
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1186
- </ItemGroup>
1187
- </Project>
1188
- """,
1378
+ <ItemGroup>
1379
+ <PackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1380
+ </ItemGroup>
1381
+ </Project>
1382
+ """,
1189
1383
  additionalFilesExpected:
1190
1384
  [
1191
1385
  // expected props file
1192
1386
  ("Directory.Build.props", """
1193
1387
  <Project>
1194
1388
  <PropertyGroup>
1195
- <NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
1389
+ <SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
1196
1390
  </PropertyGroup>
1197
1391
  </Project>
1198
1392
  """)
1199
- ]);
1393
+ ]
1394
+ );
1200
1395
  }
1201
1396
 
1202
1397
  [Fact]
1203
1398
  public async Task UpdatePropertyValue_InProps_ForPackageReferenceInclude()
1204
1399
  {
1205
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
1400
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
1401
+ packages:
1402
+ [
1403
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
1404
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
1405
+ ],
1206
1406
  // initial project
1207
1407
  projectContents: """
1208
- <Project Sdk="Microsoft.NET.Sdk">
1209
- <Import Project="my-properties.props" />
1408
+ <Project Sdk="Microsoft.NET.Sdk">
1409
+ <Import Project="my-properties.props" />
1210
1410
 
1211
- <PropertyGroup>
1212
- <TargetFramework>netstandard2.0</TargetFramework>
1213
- </PropertyGroup>
1411
+ <PropertyGroup>
1412
+ <TargetFramework>net8.0</TargetFramework>
1413
+ </PropertyGroup>
1214
1414
 
1215
- <ItemGroup>
1216
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1217
- </ItemGroup>
1218
- </Project>
1219
- """,
1415
+ <ItemGroup>
1416
+ <PackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1417
+ </ItemGroup>
1418
+ </Project>
1419
+ """,
1220
1420
  additionalFiles:
1221
1421
  [
1222
1422
  // initial props file
1223
1423
  ("my-properties.props", """
1224
1424
  <Project>
1225
1425
  <PropertyGroup>
1226
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
1426
+ <SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
1227
1427
  </PropertyGroup>
1228
1428
  </Project>
1229
1429
  """)
1230
1430
  ],
1231
1431
  // expected project
1232
1432
  expectedProjectContents: """
1233
- <Project Sdk="Microsoft.NET.Sdk">
1234
- <Import Project="my-properties.props" />
1433
+ <Project Sdk="Microsoft.NET.Sdk">
1434
+ <Import Project="my-properties.props" />
1235
1435
 
1236
- <PropertyGroup>
1237
- <TargetFramework>netstandard2.0</TargetFramework>
1238
- </PropertyGroup>
1436
+ <PropertyGroup>
1437
+ <TargetFramework>net8.0</TargetFramework>
1438
+ </PropertyGroup>
1239
1439
 
1240
- <ItemGroup>
1241
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1242
- </ItemGroup>
1243
- </Project>
1244
- """,
1440
+ <ItemGroup>
1441
+ <PackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1442
+ </ItemGroup>
1443
+ </Project>
1444
+ """,
1245
1445
  additionalFilesExpected:
1246
1446
  [
1247
1447
  // expected props file
1248
1448
  ("my-properties.props", """
1249
1449
  <Project>
1250
1450
  <PropertyGroup>
1251
- <NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
1451
+ <SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
1252
1452
  </PropertyGroup>
1253
1453
  </Project>
1254
1454
  """)
1255
- ]);
1455
+ ]
1456
+ );
1256
1457
  }
1257
1458
 
1258
1459
  [Fact]
1259
1460
  public async Task UpdatePropertyValue_InProps_ForPackageVersion()
1260
1461
  {
1261
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
1262
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
1462
+ // update Some.Package from 9.0.1 to 13.0.1
1463
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
1464
+ packages:
1465
+ [
1466
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
1467
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
1468
+ ],
1263
1469
  // initial
1264
1470
  projectContents: """
1265
- <Project Sdk="Microsoft.NET.Sdk">
1266
- <PropertyGroup>
1267
- <TargetFramework>netstandard2.0</TargetFramework>
1268
- </PropertyGroup>
1471
+ <Project Sdk="Microsoft.NET.Sdk">
1472
+ <PropertyGroup>
1473
+ <TargetFramework>net8.0</TargetFramework>
1474
+ </PropertyGroup>
1269
1475
 
1270
- <ItemGroup>
1271
- <PackageReference Include="Newtonsoft.Json" />
1272
- </ItemGroup>
1273
- </Project>
1274
- """,
1476
+ <ItemGroup>
1477
+ <PackageReference Include="Some.Package" />
1478
+ </ItemGroup>
1479
+ </Project>
1480
+ """,
1275
1481
  additionalFiles:
1276
1482
  [
1483
+ ("Directory.Build.props", "<Project />"),
1277
1484
  // initial props files
1278
1485
  ("Directory.Packages.props", """
1279
1486
  <Project>
@@ -1283,30 +1490,30 @@ public partial class UpdateWorkerTests
1283
1490
  </PropertyGroup>
1284
1491
 
1285
1492
  <ItemGroup>
1286
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1493
+ <PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1287
1494
  </ItemGroup>
1288
1495
  </Project>
1289
1496
  """),
1290
1497
  ("Version.props", """
1291
1498
  <Project>
1292
1499
  <PropertyGroup>
1293
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
1500
+ <SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
1294
1501
  </PropertyGroup>
1295
1502
  </Project>
1296
1503
  """)
1297
1504
  ],
1298
1505
  // expected
1299
1506
  expectedProjectContents: """
1300
- <Project Sdk="Microsoft.NET.Sdk">
1301
- <PropertyGroup>
1302
- <TargetFramework>netstandard2.0</TargetFramework>
1303
- </PropertyGroup>
1507
+ <Project Sdk="Microsoft.NET.Sdk">
1508
+ <PropertyGroup>
1509
+ <TargetFramework>net8.0</TargetFramework>
1510
+ </PropertyGroup>
1304
1511
 
1305
- <ItemGroup>
1306
- <PackageReference Include="Newtonsoft.Json" />
1307
- </ItemGroup>
1308
- </Project>
1309
- """,
1512
+ <ItemGroup>
1513
+ <PackageReference Include="Some.Package" />
1514
+ </ItemGroup>
1515
+ </Project>
1516
+ """,
1310
1517
  additionalFilesExpected:
1311
1518
  [
1312
1519
  // expected props files
@@ -1318,50 +1525,57 @@ public partial class UpdateWorkerTests
1318
1525
  </PropertyGroup>
1319
1526
 
1320
1527
  <ItemGroup>
1321
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1528
+ <PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1322
1529
  </ItemGroup>
1323
1530
  </Project>
1324
1531
  """),
1325
1532
  ("Version.props", """
1326
1533
  <Project>
1327
1534
  <PropertyGroup>
1328
- <NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
1535
+ <SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
1329
1536
  </PropertyGroup>
1330
1537
  </Project>
1331
1538
  """)
1332
- ]);
1539
+ ]
1540
+ );
1333
1541
  }
1334
1542
 
1335
1543
  [Fact]
1336
1544
  public async Task UpdatePropertyValue_InProps_ThenSubstituted_ForPackageVersion()
1337
1545
  {
1338
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
1339
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
1546
+ // update Some.Package from 9.0.1 to 13.0.1
1547
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
1548
+ packages:
1549
+ [
1550
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
1551
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
1552
+ ],
1340
1553
  // initial
1341
1554
  projectContents: """
1342
- <Project Sdk="Microsoft.NET.Sdk">
1343
- <PropertyGroup>
1344
- <TargetFramework>netstandard2.0</TargetFramework>
1345
- </PropertyGroup>
1555
+ <Project Sdk="Microsoft.NET.Sdk">
1556
+ <PropertyGroup>
1557
+ <TargetFramework>net8.0</TargetFramework>
1558
+ </PropertyGroup>
1346
1559
 
1347
- <ItemGroup>
1348
- <PackageReference Include="Newtonsoft.Json" />
1349
- </ItemGroup>
1350
- </Project>
1351
- """,
1560
+ <ItemGroup>
1561
+ <PackageReference Include="Some.Package" />
1562
+ </ItemGroup>
1563
+ </Project>
1564
+ """,
1352
1565
  additionalFiles:
1353
1566
  [
1567
+ ("Directory.Build.props", "<Project />"),
1354
1568
  // initial props files
1355
1569
  ("Directory.Packages.props", """
1356
1570
  <Project>
1357
1571
  <Import Project="Version.props" />
1358
1572
  <PropertyGroup>
1359
1573
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1360
- <NewtonsoftJsonPackageVersion>$(NewtonsoftJsonVersion)</NewtonsoftJsonPackageVersion>
1574
+ <SomePackagePackageVersion>$(NewtonsoftJsonVersion)</SomePackagePackageVersion>
1361
1575
  </PropertyGroup>
1362
1576
 
1363
1577
  <ItemGroup>
1364
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1578
+ <PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1365
1579
  </ItemGroup>
1366
1580
  </Project>
1367
1581
  """),
@@ -1375,16 +1589,16 @@ public partial class UpdateWorkerTests
1375
1589
  ],
1376
1590
  // expected
1377
1591
  expectedProjectContents: """
1378
- <Project Sdk="Microsoft.NET.Sdk">
1379
- <PropertyGroup>
1380
- <TargetFramework>netstandard2.0</TargetFramework>
1381
- </PropertyGroup>
1592
+ <Project Sdk="Microsoft.NET.Sdk">
1593
+ <PropertyGroup>
1594
+ <TargetFramework>net8.0</TargetFramework>
1595
+ </PropertyGroup>
1382
1596
 
1383
- <ItemGroup>
1384
- <PackageReference Include="Newtonsoft.Json" />
1385
- </ItemGroup>
1386
- </Project>
1387
- """,
1597
+ <ItemGroup>
1598
+ <PackageReference Include="Some.Package" />
1599
+ </ItemGroup>
1600
+ </Project>
1601
+ """,
1388
1602
  additionalFilesExpected:
1389
1603
  [
1390
1604
  // expected props files
@@ -1393,11 +1607,11 @@ public partial class UpdateWorkerTests
1393
1607
  <Import Project="Version.props" />
1394
1608
  <PropertyGroup>
1395
1609
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1396
- <NewtonsoftJsonPackageVersion>$(NewtonsoftJsonVersion)</NewtonsoftJsonPackageVersion>
1610
+ <SomePackagePackageVersion>$(NewtonsoftJsonVersion)</SomePackagePackageVersion>
1397
1611
  </PropertyGroup>
1398
1612
 
1399
1613
  <ItemGroup>
1400
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1614
+ <PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1401
1615
  </ItemGroup>
1402
1616
  </Project>
1403
1617
  """),
@@ -1408,63 +1622,70 @@ public partial class UpdateWorkerTests
1408
1622
  </PropertyGroup>
1409
1623
  </Project>
1410
1624
  """)
1411
- ]);
1625
+ ]
1626
+ );
1412
1627
  }
1413
1628
 
1414
1629
  [Fact]
1415
1630
  public async Task UpdatePropertyValues_InProps_ThenRedefinedAndSubstituted_ForPackageVersion()
1416
1631
  {
1417
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
1418
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
1632
+ // update Some.Package from 9.0.1 to 13.0.1
1633
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
1634
+ packages:
1635
+ [
1636
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "net8.0"),
1637
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
1638
+ ],
1419
1639
  // initial
1420
1640
  projectContents: """
1421
- <Project Sdk="Microsoft.NET.Sdk">
1422
- <PropertyGroup>
1423
- <TargetFramework>netstandard2.0</TargetFramework>
1424
- </PropertyGroup>
1641
+ <Project Sdk="Microsoft.NET.Sdk">
1642
+ <PropertyGroup>
1643
+ <TargetFramework>net8.0</TargetFramework>
1644
+ </PropertyGroup>
1425
1645
 
1426
- <ItemGroup>
1427
- <PackageReference Include="Newtonsoft.Json" />
1428
- </ItemGroup>
1429
- </Project>
1430
- """,
1646
+ <ItemGroup>
1647
+ <PackageReference Include="Some.Package" />
1648
+ </ItemGroup>
1649
+ </Project>
1650
+ """,
1431
1651
  additionalFiles:
1432
1652
  [
1653
+ ("Directory.Build.props", "<Project />"),
1433
1654
  // initial props files
1434
1655
  ("Directory.Packages.props", """
1435
1656
  <Project>
1436
1657
  <Import Project="Version.props" />
1437
1658
  <PropertyGroup>
1438
1659
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1439
- <NewtonsoftJsonPackageVersion>$(NewtonsoftJsonVersion)</NewtonsoftJsonPackageVersion>
1660
+ <SomePackagePackageVersion>$(SomePackageVersion)</SomePackagePackageVersion>
1440
1661
  </PropertyGroup>
1441
1662
 
1442
1663
  <ItemGroup>
1443
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1664
+ <PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1444
1665
  </ItemGroup>
1445
1666
  </Project>
1446
1667
  """),
1447
1668
  ("Version.props", """
1448
1669
  <Project>
1449
1670
  <PropertyGroup>
1450
- <NewtonsoftJSONVersion>9.0.1</NewtonsoftJSONVersion>
1451
- <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
1671
+ <SomePACKAGEVersion>9.0.1</SomePACKAGEVersion>
1672
+ <SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
1452
1673
  </PropertyGroup>
1453
1674
  </Project>
1454
1675
  """)
1455
1676
  ],
1456
1677
  // expected
1457
1678
  expectedProjectContents: """
1458
- <Project Sdk="Microsoft.NET.Sdk">
1459
- <PropertyGroup>
1460
- <TargetFramework>netstandard2.0</TargetFramework>
1461
- </PropertyGroup>
1679
+ <Project Sdk="Microsoft.NET.Sdk">
1680
+ <PropertyGroup>
1681
+ <TargetFramework>net8.0</TargetFramework>
1682
+ </PropertyGroup>
1462
1683
 
1463
- <ItemGroup>
1464
- <PackageReference Include="Newtonsoft.Json" />
1465
- </ItemGroup>
1466
- </Project>
1467
- """,
1684
+ <ItemGroup>
1685
+ <PackageReference Include="Some.Package" />
1686
+ </ItemGroup>
1687
+ </Project>
1688
+ """,
1468
1689
  additionalFilesExpected:
1469
1690
  [
1470
1691
  // expected props files
@@ -1473,184 +1694,223 @@ public partial class UpdateWorkerTests
1473
1694
  <Import Project="Version.props" />
1474
1695
  <PropertyGroup>
1475
1696
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1476
- <NewtonsoftJsonPackageVersion>$(NewtonsoftJsonVersion)</NewtonsoftJsonPackageVersion>
1697
+ <SomePackagePackageVersion>$(SomePackageVersion)</SomePackagePackageVersion>
1477
1698
  </PropertyGroup>
1478
1699
 
1479
1700
  <ItemGroup>
1480
- <PackageVersion Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
1701
+ <PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
1481
1702
  </ItemGroup>
1482
1703
  </Project>
1483
1704
  """),
1484
1705
  ("Version.props", """
1485
1706
  <Project>
1486
1707
  <PropertyGroup>
1487
- <NewtonsoftJSONVersion>13.0.1</NewtonsoftJSONVersion>
1488
- <NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
1708
+ <SomePACKAGEVersion>13.0.1</SomePACKAGEVersion>
1709
+ <SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
1489
1710
  </PropertyGroup>
1490
1711
  </Project>
1491
1712
  """)
1492
- ]);
1713
+ ]
1714
+ );
1493
1715
  }
1494
1716
 
1495
1717
  [Fact]
1496
1718
  public async Task UpdatePeerDependencyWithInlineVersion()
1497
1719
  {
1498
- await TestUpdateForProject("Microsoft.Extensions.Http", "2.2.0", "7.0.0",
1720
+ await TestUpdateForProject("Some.Package", "2.2.0", "7.0.0",
1721
+ packages:
1722
+ [
1723
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "2.2.0", "net8.0", [(null, [("Peer.Package", "2.2.0")])]),
1724
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.0", "net8.0", [(null, [("Peer.Package", "7.0.0")])]),
1725
+ MockNuGetPackage.CreateSimplePackage("Peer.Package", "2.2.0", "net8.0"),
1726
+ MockNuGetPackage.CreateSimplePackage("Peer.Package", "7.0.0", "net8.0"),
1727
+ ],
1499
1728
  projectContents: """
1500
- <Project Sdk="Microsoft.NET.Sdk">
1501
- <PropertyGroup>
1502
- <TargetFramework>netstandard2.0</TargetFramework>
1503
- </PropertyGroup>
1504
- <ItemGroup>
1505
- <PackageReference Include="Microsoft.Extensions.Http" Version="2.2.0" />
1506
- <PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
1507
- </ItemGroup>
1508
- </Project>
1509
- """,
1729
+ <Project Sdk="Microsoft.NET.Sdk">
1730
+ <PropertyGroup>
1731
+ <TargetFramework>net8.0</TargetFramework>
1732
+ </PropertyGroup>
1733
+ <ItemGroup>
1734
+ <PackageReference Include="Some.Package" Version="2.2.0" />
1735
+ <PackageReference Include="Peer.Package" Version="2.2.0" />
1736
+ </ItemGroup>
1737
+ </Project>
1738
+ """,
1510
1739
  expectedProjectContents: """
1511
- <Project Sdk="Microsoft.NET.Sdk">
1512
- <PropertyGroup>
1513
- <TargetFramework>netstandard2.0</TargetFramework>
1514
- </PropertyGroup>
1515
- <ItemGroup>
1516
- <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
1517
- <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
1518
- </ItemGroup>
1519
- </Project>
1520
- """);
1740
+ <Project Sdk="Microsoft.NET.Sdk">
1741
+ <PropertyGroup>
1742
+ <TargetFramework>net8.0</TargetFramework>
1743
+ </PropertyGroup>
1744
+ <ItemGroup>
1745
+ <PackageReference Include="Some.Package" Version="7.0.0" />
1746
+ <PackageReference Include="Peer.Package" Version="7.0.0" />
1747
+ </ItemGroup>
1748
+ </Project>
1749
+ """
1750
+ );
1521
1751
  }
1522
1752
 
1523
1753
  [Fact]
1524
1754
  public async Task UpdatePeerDependencyFromPropertyInSameFile()
1525
1755
  {
1526
- await TestUpdateForProject("Microsoft.Extensions.Http", "2.2.0", "7.0.0",
1756
+ await TestUpdateForProject("Some.Package", "2.2.0", "7.0.0",
1757
+ packages:
1758
+ [
1759
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "2.2.0", "net8.0", [(null, [("Peer.Package", "2.2.0")])]),
1760
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.0", "net8.0", [(null, [("Peer.Package", "7.0.0")])]),
1761
+ MockNuGetPackage.CreateSimplePackage("Peer.Package", "2.2.0", "net8.0"),
1762
+ MockNuGetPackage.CreateSimplePackage("Peer.Package", "7.0.0", "net8.0"),
1763
+ ],
1527
1764
  projectContents: """
1528
- <Project Sdk="Microsoft.NET.Sdk">
1529
- <PropertyGroup>
1530
- <TargetFramework>netstandard2.0</TargetFramework>
1531
- <MicrosoftExtensionsHttpVersion>2.2.0</MicrosoftExtensionsHttpVersion>
1532
- <MicrosoftExtensionsLoggingVersion>2.2.0</MicrosoftExtensionsLoggingVersion>
1533
- </PropertyGroup>
1534
- <ItemGroup>
1535
- <PackageReference Include="Microsoft.Extensions.Http" Version="$(MicrosoftExtensionsHttpVersion)" />
1536
- <PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingVersion)" />
1537
- </ItemGroup>
1538
- </Project>
1539
- """,
1765
+ <Project Sdk="Microsoft.NET.Sdk">
1766
+ <PropertyGroup>
1767
+ <TargetFramework>net8.0</TargetFramework>
1768
+ <SomePackageVersion>2.2.0</SomePackageVersion>
1769
+ <PeerPackageVersion>2.2.0</PeerPackageVersion>
1770
+ </PropertyGroup>
1771
+ <ItemGroup>
1772
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1773
+ <PackageReference Include="Peer.Package" Version="$(PeerPackageVersion)" />
1774
+ </ItemGroup>
1775
+ </Project>
1776
+ """,
1540
1777
  expectedProjectContents: """
1541
- <Project Sdk="Microsoft.NET.Sdk">
1542
- <PropertyGroup>
1543
- <TargetFramework>netstandard2.0</TargetFramework>
1544
- <MicrosoftExtensionsHttpVersion>7.0.0</MicrosoftExtensionsHttpVersion>
1545
- <MicrosoftExtensionsLoggingVersion>7.0.0</MicrosoftExtensionsLoggingVersion>
1546
- </PropertyGroup>
1547
- <ItemGroup>
1548
- <PackageReference Include="Microsoft.Extensions.Http" Version="$(MicrosoftExtensionsHttpVersion)" />
1549
- <PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingVersion)" />
1550
- </ItemGroup>
1551
- </Project>
1552
- """);
1778
+ <Project Sdk="Microsoft.NET.Sdk">
1779
+ <PropertyGroup>
1780
+ <TargetFramework>net8.0</TargetFramework>
1781
+ <SomePackageVersion>7.0.0</SomePackageVersion>
1782
+ <PeerPackageVersion>7.0.0</PeerPackageVersion>
1783
+ </PropertyGroup>
1784
+ <ItemGroup>
1785
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1786
+ <PackageReference Include="Peer.Package" Version="$(PeerPackageVersion)" />
1787
+ </ItemGroup>
1788
+ </Project>
1789
+ """
1790
+ );
1553
1791
  }
1554
1792
 
1555
1793
  [Fact]
1556
1794
  public async Task UpdatePeerDependencyFromPropertyInDifferentFile()
1557
1795
  {
1558
- await TestUpdateForProject("Microsoft.Extensions.Http", "2.2.0", "7.0.0",
1796
+ await TestUpdateForProject("Some.Package", "2.2.0", "7.0.0",
1797
+ packages:
1798
+ [
1799
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "2.2.0", "net8.0", [(null, [("Peer.Package", "2.2.0")])]),
1800
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.0", "net8.0", [(null, [("Peer.Package", "7.0.0")])]),
1801
+ MockNuGetPackage.CreateSimplePackage("Peer.Package", "2.2.0", "net8.0"),
1802
+ MockNuGetPackage.CreateSimplePackage("Peer.Package", "7.0.0", "net8.0"),
1803
+ ],
1559
1804
  projectContents: """
1560
- <Project Sdk="Microsoft.NET.Sdk">
1561
- <Import Project="Versions.props" />
1562
- <PropertyGroup>
1563
- <TargetFramework>netstandard2.0</TargetFramework>
1564
- </PropertyGroup>
1565
- <ItemGroup>
1566
- <PackageReference Include="Microsoft.Extensions.Http" Version="$(MicrosoftExtensionsHttpVersion)" />
1567
- <PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingVersion)" />
1568
- </ItemGroup>
1569
- </Project>
1570
- """,
1805
+ <Project Sdk="Microsoft.NET.Sdk">
1806
+ <Import Project="Versions.props" />
1807
+ <PropertyGroup>
1808
+ <TargetFramework>net8.0</TargetFramework>
1809
+ </PropertyGroup>
1810
+ <ItemGroup>
1811
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1812
+ <PackageReference Include="Peer.Package" Version="$(PeerPackageVersion)" />
1813
+ </ItemGroup>
1814
+ </Project>
1815
+ """,
1571
1816
  additionalFiles:
1572
1817
  [
1573
1818
  ("Versions.props", """
1574
1819
  <Project>
1575
1820
  <PropertyGroup>
1576
- <MicrosoftExtensionsHttpVersion>2.2.0</MicrosoftExtensionsHttpVersion>
1577
- <MicrosoftExtensionsLoggingVersion>2.2.0</MicrosoftExtensionsLoggingVersion>
1821
+ <SomePackageVersion>2.2.0</SomePackageVersion>
1822
+ <PeerPackageVersion>2.2.0</PeerPackageVersion>
1578
1823
  </PropertyGroup>
1579
1824
  </Project>
1580
1825
  """)
1581
1826
  ],
1582
1827
  expectedProjectContents: """
1583
- <Project Sdk="Microsoft.NET.Sdk">
1584
- <Import Project="Versions.props" />
1585
- <PropertyGroup>
1586
- <TargetFramework>netstandard2.0</TargetFramework>
1587
- </PropertyGroup>
1588
- <ItemGroup>
1589
- <PackageReference Include="Microsoft.Extensions.Http" Version="$(MicrosoftExtensionsHttpVersion)" />
1590
- <PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingVersion)" />
1591
- </ItemGroup>
1592
- </Project>
1593
- """,
1828
+ <Project Sdk="Microsoft.NET.Sdk">
1829
+ <Import Project="Versions.props" />
1830
+ <PropertyGroup>
1831
+ <TargetFramework>net8.0</TargetFramework>
1832
+ </PropertyGroup>
1833
+ <ItemGroup>
1834
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
1835
+ <PackageReference Include="Peer.Package" Version="$(PeerPackageVersion)" />
1836
+ </ItemGroup>
1837
+ </Project>
1838
+ """,
1594
1839
  additionalFilesExpected:
1595
1840
  [
1596
1841
  ("Versions.props", """
1597
1842
  <Project>
1598
1843
  <PropertyGroup>
1599
- <MicrosoftExtensionsHttpVersion>7.0.0</MicrosoftExtensionsHttpVersion>
1600
- <MicrosoftExtensionsLoggingVersion>7.0.0</MicrosoftExtensionsLoggingVersion>
1844
+ <SomePackageVersion>7.0.0</SomePackageVersion>
1845
+ <PeerPackageVersion>7.0.0</PeerPackageVersion>
1601
1846
  </PropertyGroup>
1602
1847
  </Project>
1603
1848
  """)
1604
- ]);
1849
+ ]
1850
+ );
1605
1851
  }
1606
1852
 
1607
1853
  [Fact]
1608
1854
  public async Task UpdatePeerDependencyWithInlineVersionAndMultipleTfms()
1609
1855
  {
1610
- await TestUpdateForProject("Microsoft.Extensions.Http", "2.2.0", "7.0.0",
1856
+ await TestUpdateForProject("Some.Package", "2.2.0", "7.0.0",
1857
+ packages:
1858
+ [
1859
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "2.2.0", "net7.0", [(null, [("Peer.Package", "2.2.0")])]),
1860
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.0", "net7.0", [(null, [("Peer.Package", "7.0.0")])]),
1861
+ MockNuGetPackage.CreateSimplePackage("Peer.Package", "2.2.0", "net7.0"),
1862
+ MockNuGetPackage.CreateSimplePackage("Peer.Package", "7.0.0", "net7.0"),
1863
+ ],
1611
1864
  projectContents: """
1612
- <Project Sdk="Microsoft.NET.Sdk">
1613
- <PropertyGroup>
1614
- <TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
1615
- </PropertyGroup>
1616
- <ItemGroup>
1617
- <PackageReference Include="Microsoft.Extensions.Http" Version="2.2.0" />
1618
- <PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
1619
- </ItemGroup>
1620
- </Project>
1621
- """,
1865
+ <Project Sdk="Microsoft.NET.Sdk">
1866
+ <PropertyGroup>
1867
+ <TargetFrameworks>net7.0;net8.0</TargetFrameworks>
1868
+ </PropertyGroup>
1869
+ <ItemGroup>
1870
+ <PackageReference Include="Some.Package" Version="2.2.0" />
1871
+ <PackageReference Include="Peer.Package" Version="2.2.0" />
1872
+ </ItemGroup>
1873
+ </Project>
1874
+ """,
1622
1875
  expectedProjectContents: """
1623
- <Project Sdk="Microsoft.NET.Sdk">
1624
- <PropertyGroup>
1625
- <TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
1626
- </PropertyGroup>
1627
- <ItemGroup>
1628
- <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
1629
- <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
1630
- </ItemGroup>
1631
- </Project>
1632
- """);
1876
+ <Project Sdk="Microsoft.NET.Sdk">
1877
+ <PropertyGroup>
1878
+ <TargetFrameworks>net7.0;net8.0</TargetFrameworks>
1879
+ </PropertyGroup>
1880
+ <ItemGroup>
1881
+ <PackageReference Include="Some.Package" Version="7.0.0" />
1882
+ <PackageReference Include="Peer.Package" Version="7.0.0" />
1883
+ </ItemGroup>
1884
+ </Project>
1885
+ """
1886
+ );
1633
1887
  }
1634
1888
 
1635
1889
  [Fact]
1636
1890
  public async Task NoUpdateForPeerDependenciesWhichAreHigherVersion()
1637
1891
  {
1638
- await TestUpdateForProject("Microsoft.Identity.Web", "2.13.0", "2.13.2",
1892
+ await TestUpdateForProject("Some.Package", "1.0.0", "1.1.0",
1893
+ packages:
1894
+ [
1895
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0", [(null, [("Transitive.Dependency", "1.0.0")])]),
1896
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.1.0", "net8.0", [(null, [("Transitive.Dependency", "1.0.0")])]),
1897
+ MockNuGetPackage.CreateSimplePackage("Transitive.Dependency", "1.0.0", "net8.0"),
1898
+ MockNuGetPackage.CreateSimplePackage("Transitive.Dependency", "1.1.0", "net8.0"), // we shouldn't update to this
1899
+ ],
1639
1900
  projectContents: """
1640
- <Project Sdk="Microsoft.NET.Sdk">
1641
- <PropertyGroup>
1642
- <TargetFramework>netstandard2.0</TargetFramework>
1643
- </PropertyGroup>
1644
- <ItemGroup>
1645
- <PackageReference Include="Azure.Identity" />
1646
- <PackageReference Include="Azure.Security.KeyVault.Keys" />
1647
- <PackageReference Include="Azure.Security.KeyVault.Secrets" />
1648
- <PackageReference Include="Microsoft.Identity.Web" />
1649
- </ItemGroup>
1650
- </Project>
1651
- """,
1901
+ <Project Sdk="Microsoft.NET.Sdk">
1902
+ <PropertyGroup>
1903
+ <TargetFramework>net8.0</TargetFramework>
1904
+ </PropertyGroup>
1905
+ <ItemGroup>
1906
+ <PackageReference Include="Some.Package" />
1907
+ <PackageReference Include="Transitive.Dependency" />
1908
+ </ItemGroup>
1909
+ </Project>
1910
+ """,
1652
1911
  additionalFiles:
1653
1912
  [
1913
+ ("Directory.Build.props", "<Project />"),
1654
1914
  ("Directory.Packages.props", """
1655
1915
  <Project>
1656
1916
  <PropertyGroup>
@@ -1658,27 +1918,23 @@ public partial class UpdateWorkerTests
1658
1918
  <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
1659
1919
  </PropertyGroup>
1660
1920
  <ItemGroup>
1661
- <PackageVersion Include="Azure.Identity" Version="1.9.0" />
1662
- <PackageVersion Include="Azure.Security.KeyVault.Keys" Version="4.5.0" />
1663
- <PackageVersion Include="Azure.Security.KeyVault.Secrets" Version="4.5.0" />
1664
- <PackageVersion Include="Microsoft.Identity.Web" Version="2.13.0" />
1921
+ <PackageVersion Include="Some.Package" Version="1.0.0" />
1922
+ <PackageVersion Include="Transitive.Dependency" Version="1.0.0" />
1665
1923
  </ItemGroup>
1666
1924
  </Project>
1667
1925
  """)
1668
1926
  ],
1669
1927
  expectedProjectContents: """
1670
- <Project Sdk="Microsoft.NET.Sdk">
1671
- <PropertyGroup>
1672
- <TargetFramework>netstandard2.0</TargetFramework>
1673
- </PropertyGroup>
1674
- <ItemGroup>
1675
- <PackageReference Include="Azure.Identity" />
1676
- <PackageReference Include="Azure.Security.KeyVault.Keys" />
1677
- <PackageReference Include="Azure.Security.KeyVault.Secrets" />
1678
- <PackageReference Include="Microsoft.Identity.Web" />
1679
- </ItemGroup>
1680
- </Project>
1681
- """,
1928
+ <Project Sdk="Microsoft.NET.Sdk">
1929
+ <PropertyGroup>
1930
+ <TargetFramework>net8.0</TargetFramework>
1931
+ </PropertyGroup>
1932
+ <ItemGroup>
1933
+ <PackageReference Include="Some.Package" />
1934
+ <PackageReference Include="Transitive.Dependency" />
1935
+ </ItemGroup>
1936
+ </Project>
1937
+ """,
1682
1938
  additionalFilesExpected:
1683
1939
  [
1684
1940
  ("Directory.Packages.props", """
@@ -1688,149 +1944,155 @@ public partial class UpdateWorkerTests
1688
1944
  <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
1689
1945
  </PropertyGroup>
1690
1946
  <ItemGroup>
1691
- <PackageVersion Include="Azure.Identity" Version="1.9.0" />
1692
- <PackageVersion Include="Azure.Security.KeyVault.Keys" Version="4.5.0" />
1693
- <PackageVersion Include="Azure.Security.KeyVault.Secrets" Version="4.5.0" />
1694
- <PackageVersion Include="Microsoft.Identity.Web" Version="2.13.2" />
1947
+ <PackageVersion Include="Some.Package" Version="1.1.0" />
1948
+ <PackageVersion Include="Transitive.Dependency" Version="1.0.0" />
1695
1949
  </ItemGroup>
1696
1950
  </Project>
1697
1951
  """)
1698
- ]);
1952
+ ]
1953
+ );
1699
1954
  }
1700
1955
 
1701
1956
  [Fact]
1702
1957
  public async Task UpdatingToNotCompatiblePackageDoesNothing()
1703
1958
  {
1704
- await TestUpdateForProject("Microsoft.AspNetCore.Authentication.JwtBearer", "3.1.18", "7.0.5",
1959
+ // can't upgrade to the newer package because of a TFM mismatch
1960
+ await TestNoChangeforProject("Some.Package", "7.0.0", "8.0.0",
1961
+ packages:
1962
+ [
1963
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.0", "net7.0"),
1964
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "8.0.0", "net8.0"),
1965
+ ],
1705
1966
  projectContents: """
1706
- <Project Sdk="Microsoft.NET.Sdk">
1707
- <PropertyGroup>
1708
- <TargetFramework>netcoreapp3.1</TargetFramework>
1709
- </PropertyGroup>
1710
- <ItemGroup>
1711
- <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.18" />
1712
- </ItemGroup>
1713
- </Project>
1714
- """,
1715
- expectedProjectContents: """
1716
- <Project Sdk="Microsoft.NET.Sdk">
1717
- <PropertyGroup>
1718
- <TargetFramework>netcoreapp3.1</TargetFramework>
1719
- </PropertyGroup>
1720
- <ItemGroup>
1721
- <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.18" />
1722
- </ItemGroup>
1723
- </Project>
1724
- """);
1967
+ <Project Sdk="Microsoft.NET.Sdk">
1968
+ <PropertyGroup>
1969
+ <TargetFramework>net7.0</TargetFramework>
1970
+ </PropertyGroup>
1971
+ <ItemGroup>
1972
+ <PackageReference Include="Some.Package" Version="7.0.0" />
1973
+ </ItemGroup>
1974
+ </Project>
1975
+ """
1976
+ );
1725
1977
  }
1726
1978
 
1727
1979
  [Fact]
1728
1980
  public async Task UpdatingToNotCompatiblePackageDoesNothingWithSingleOfMultileTfmNotSupported()
1729
1981
  {
1730
- // the requested package upgrade is supported on net7.0, but not netcoreapp3.1, so we skip the whole thing
1731
- await TestUpdateForProject("Microsoft.AspNetCore.Authentication.JwtBearer", "3.1.18", "7.0.5",
1982
+ // can't upgrade to the newer package because one of the TFMs doesn't match
1983
+ await TestNoChangeforProject("Some.Package", "7.0.0", "8.0.0",
1984
+ packages:
1985
+ [
1986
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.0", "net7.0"),
1987
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "8.0.0", "net8.0"),
1988
+ ],
1732
1989
  projectContents: """
1733
- <Project Sdk="Microsoft.NET.Sdk">
1734
- <PropertyGroup>
1735
- <TargetFrameworks>netcoreapp3.1;net7.0</TargetFrameworks>
1736
- </PropertyGroup>
1737
- <ItemGroup>
1738
- <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.18" />
1739
- </ItemGroup>
1740
- </Project>
1741
- """,
1742
- expectedProjectContents: """
1743
- <Project Sdk="Microsoft.NET.Sdk">
1744
- <PropertyGroup>
1745
- <TargetFrameworks>netcoreapp3.1;net7.0</TargetFrameworks>
1746
- </PropertyGroup>
1747
- <ItemGroup>
1748
- <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.18" />
1749
- </ItemGroup>
1750
- </Project>
1751
- """);
1990
+ <Project Sdk="Microsoft.NET.Sdk">
1991
+ <PropertyGroup>
1992
+ <TargetFrameworks>net7.0;net8.0</TargetFrameworks>
1993
+ </PropertyGroup>
1994
+ <ItemGroup>
1995
+ <PackageReference Include="Some.Package" Version="7.0.0" />
1996
+ </ItemGroup>
1997
+ </Project>
1998
+ """
1999
+ );
1752
2000
  }
1753
2001
 
1754
2002
  [Fact]
1755
2003
  public async Task UpdateVersionAttribute_InProjectFile_WhereTargetFrameworksIsSelfReferential()
1756
2004
  {
1757
- // update Newtonsoft.Json from 9.0.1 to 13.0.1
1758
- await TestUpdateForProject("Newtonsoft.Json", "9.0.1", "13.0.1",
2005
+ // update Some.Package from 9.0.1 to 13.0.1
2006
+ await TestUpdateForProject("Some.Package", "9.0.1", "13.0.1",
2007
+ packages:
2008
+ [
2009
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "9.0.1", "netstandard2.0"),
2010
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "netstandard2.0"),
2011
+ ],
1759
2012
  projectContents: """
1760
- <Project Sdk="Microsoft.NET.Sdk">
1761
- <PropertyGroup>
1762
- <TargetFrameworks Condition="!$(TargetFrameworks.Contains('net472'))">$(TargetFrameworks);net472</TargetFrameworks>
1763
- <TargetFrameworks Condition="!$(TargetFrameworks.Contains('netstandard2.0'))">$(TargetFrameworks);netstandard2.0</TargetFrameworks>
1764
- </PropertyGroup>
1765
- <ItemGroup>
1766
- <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
1767
- </ItemGroup>
1768
- </Project>
1769
- """,
2013
+ <Project Sdk="Microsoft.NET.Sdk">
2014
+ <PropertyGroup>
2015
+ <TargetFrameworks Condition="!$(TargetFrameworks.Contains('net472'))">$(TargetFrameworks);net472</TargetFrameworks>
2016
+ <TargetFrameworks Condition="!$(TargetFrameworks.Contains('net8.0'))">$(TargetFrameworks);net8.0</TargetFrameworks>
2017
+ </PropertyGroup>
2018
+ <ItemGroup>
2019
+ <PackageReference Include="Some.Package" Version="9.0.1" />
2020
+ </ItemGroup>
2021
+ </Project>
2022
+ """,
1770
2023
  expectedProjectContents: """
1771
- <Project Sdk="Microsoft.NET.Sdk">
1772
- <PropertyGroup>
1773
- <TargetFrameworks Condition="!$(TargetFrameworks.Contains('net472'))">$(TargetFrameworks);net472</TargetFrameworks>
1774
- <TargetFrameworks Condition="!$(TargetFrameworks.Contains('netstandard2.0'))">$(TargetFrameworks);netstandard2.0</TargetFrameworks>
1775
- </PropertyGroup>
1776
- <ItemGroup>
1777
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
1778
- </ItemGroup>
1779
- </Project>
1780
- """);
2024
+ <Project Sdk="Microsoft.NET.Sdk">
2025
+ <PropertyGroup>
2026
+ <TargetFrameworks Condition="!$(TargetFrameworks.Contains('net472'))">$(TargetFrameworks);net472</TargetFrameworks>
2027
+ <TargetFrameworks Condition="!$(TargetFrameworks.Contains('net8.0'))">$(TargetFrameworks);net8.0</TargetFrameworks>
2028
+ </PropertyGroup>
2029
+ <ItemGroup>
2030
+ <PackageReference Include="Some.Package" Version="13.0.1" />
2031
+ </ItemGroup>
2032
+ </Project>
2033
+ """
2034
+ );
1781
2035
  }
1782
2036
 
1783
2037
  [Fact]
1784
2038
  public async Task UpdateOfNonExistantPackageDoesNothingEvenIfTransitiveDependencyIsPresent()
1785
2039
  {
1786
- // package Microsoft.Extensions.Http isn't present, but one of its transitive dependencies is
1787
- await TestUpdateForProject("Microsoft.Extensions.Http", "2.2.0", "7.0.0",
2040
+ // package Some.Package isn't in the project, but one of its transitive dependencies is
2041
+ await TestNoChangeforProject("Some.Package", "2.2.0", "7.0.0",
2042
+ packages:
2043
+ [
2044
+ // these packages exist in the feed, but aren't used
2045
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "2.2.0", "net8.0", [(null, [("Transitive.Dependency", "2.2.0")])]),
2046
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.0", "net8.0", [(null, [("Transitive.Dependency", "7.0.0")])]),
2047
+ // one of these is used, but we can't update to it
2048
+ MockNuGetPackage.CreateSimplePackage("Transitive.Dependency", "2.2.0", "net8.0"),
2049
+ MockNuGetPackage.CreateSimplePackage("Transitive.Dependency", "7.0.0", "net8.0"),
2050
+ ],
1788
2051
  projectContents: """
1789
- <Project Sdk="Microsoft.NET.Sdk">
1790
- <PropertyGroup>
1791
- <TargetFramework>netstandard2.0</TargetFramework>
1792
- </PropertyGroup>
1793
- <ItemGroup>
1794
- <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
1795
- </ItemGroup>
1796
- </Project>
1797
- """,
1798
- expectedProjectContents: """
1799
- <Project Sdk="Microsoft.NET.Sdk">
1800
- <PropertyGroup>
1801
- <TargetFramework>netstandard2.0</TargetFramework>
1802
- </PropertyGroup>
1803
- <ItemGroup>
1804
- <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
1805
- </ItemGroup>
1806
- </Project>
1807
- """);
2052
+ <Project Sdk="Microsoft.NET.Sdk">
2053
+ <PropertyGroup>
2054
+ <TargetFramework>net8.0</TargetFramework>
2055
+ </PropertyGroup>
2056
+ <ItemGroup>
2057
+ <PackageReference Include="Transitive.Dependency" Version="2.2.0" />
2058
+ </ItemGroup>
2059
+ </Project>
2060
+ """
2061
+ );
1808
2062
  }
1809
2063
 
1810
2064
  [Fact]
1811
2065
  public async Task AvoidPackageDowngradeWhenUpdatingDependency()
1812
2066
  {
1813
- await TestUpdateForProject("Microsoft.VisualStudio.Sdk.TestFramework.Xunit", "17.2.7", "17.6.16",
2067
+ // updating from 1.0.0 to 1.1.0 of Some.Package should not cause a downgrade warning of Some.Dependency; it
2068
+ // should be pulled along, even when the TFM is pulled from a different file. unrelated packages are ignored
2069
+ await TestUpdateForProject("Some.Package", "1.0.0", "1.1.0",
2070
+ packages:
2071
+ [
2072
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0", [(null, [("Some.Dependency", "1.0.0")])]),
2073
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.1.0", "net8.0", [(null, [("Some.Dependency", "1.1.0")])]),
2074
+ MockNuGetPackage.CreateSimplePackage("Some.Dependency", "1.0.0", "net8.0"),
2075
+ MockNuGetPackage.CreateSimplePackage("Some.Dependency", "1.1.0", "net8.0"),
2076
+ MockNuGetPackage.CreateSimplePackage("Unrelated.Package", "1.0.0", "net8.0"),
2077
+ MockNuGetPackage.CreateSimplePackage("Unrelated.Package", "1.1.0", "net8.0"),
2078
+ ],
1814
2079
  projectContents: """
1815
- <Project Sdk="Microsoft.NET.Sdk">
2080
+ <Project Sdk="Microsoft.NET.Sdk">
1816
2081
 
1817
- <PropertyGroup>
1818
- <TargetFramework>$(PreferredTargetFramework)</TargetFramework>
1819
- <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1820
- <RootNamespace />
1821
- </PropertyGroup>
2082
+ <PropertyGroup>
2083
+ <TargetFramework>$(PreferredTargetFramework)</TargetFramework>
2084
+ <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
2085
+ <RootNamespace />
2086
+ </PropertyGroup>
1822
2087
 
1823
- <ItemGroup>
1824
- <PackageReference Include="Microsoft.NET.Test.Sdk" />
1825
- <PackageReference Include="Microsoft.VisualStudio.Sdk.TestFramework" />
1826
- <PackageReference Include="Microsoft.VisualStudio.Sdk.TestFramework.Xunit" />
1827
- <PackageReference Include="Moq" />
1828
- <PackageReference Include="xunit.runner.visualstudio" />
1829
- <PackageReference Include="xunit" />
1830
- </ItemGroup>
2088
+ <ItemGroup>
2089
+ <PackageReference Include="Some.Package" />
2090
+ <PackageReference Include="Some.Dependency" />
2091
+ <PackageReference Include="Unrelated.Package" />
2092
+ </ItemGroup>
1831
2093
 
1832
- </Project>
1833
- """,
2094
+ </Project>
2095
+ """,
1834
2096
  additionalFiles:
1835
2097
  [
1836
2098
  ("Directory.Packages.props", """
@@ -1840,45 +2102,37 @@ public partial class UpdateWorkerTests
1840
2102
  <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
1841
2103
  </PropertyGroup>
1842
2104
  <ItemGroup>
1843
- <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
1844
- <PackageVersion Include="Microsoft.VisualStudio.Sdk.TestFramework" Version="17.2.7" />
1845
- <PackageVersion Include="Microsoft.VisualStudio.Sdk.TestFramework.Xunit" Version="17.2.7" />
1846
- <PackageVersion Include="Microsoft.VisualStudio.Shell.15.0" Version="17.6.36389" />
1847
- <PackageVersion Include="Microsoft.VisualStudio.Text.Data" Version="17.6.268" />
1848
- <PackageVersion Include="Moq" Version="4.18.2" />
1849
- <PackageVersion Include="xunit" Version="2.5.0" />
1850
- <PackageVersion Include="xunit.runner.visualstudio" Version="2.5.0" />
2105
+ <PackageVersion Include="Some.Package" Version="1.0.0" />
2106
+ <PackageVersion Include="Some.Dependency" Version="1.0.0" />
2107
+ <PackageVersion Include="Unrelated.Package" Version="1.0.0" />
1851
2108
  </ItemGroup>
1852
2109
  </Project>
1853
2110
  """),
1854
2111
  ("Directory.Build.props", """
1855
2112
  <Project>
1856
2113
  <PropertyGroup>
1857
- <PreferredTargetFramework>net7.0</PreferredTargetFramework>
2114
+ <PreferredTargetFramework>net8.0</PreferredTargetFramework>
1858
2115
  </PropertyGroup>
1859
2116
  </Project>
1860
2117
  """)
1861
2118
  ],
1862
2119
  expectedProjectContents: """
1863
- <Project Sdk="Microsoft.NET.Sdk">
2120
+ <Project Sdk="Microsoft.NET.Sdk">
1864
2121
 
1865
- <PropertyGroup>
1866
- <TargetFramework>$(PreferredTargetFramework)</TargetFramework>
1867
- <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1868
- <RootNamespace />
1869
- </PropertyGroup>
2122
+ <PropertyGroup>
2123
+ <TargetFramework>$(PreferredTargetFramework)</TargetFramework>
2124
+ <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
2125
+ <RootNamespace />
2126
+ </PropertyGroup>
1870
2127
 
1871
- <ItemGroup>
1872
- <PackageReference Include="Microsoft.NET.Test.Sdk" />
1873
- <PackageReference Include="Microsoft.VisualStudio.Sdk.TestFramework" />
1874
- <PackageReference Include="Microsoft.VisualStudio.Sdk.TestFramework.Xunit" />
1875
- <PackageReference Include="Moq" />
1876
- <PackageReference Include="xunit.runner.visualstudio" />
1877
- <PackageReference Include="xunit" />
1878
- </ItemGroup>
2128
+ <ItemGroup>
2129
+ <PackageReference Include="Some.Package" />
2130
+ <PackageReference Include="Some.Dependency" />
2131
+ <PackageReference Include="Unrelated.Package" />
2132
+ </ItemGroup>
1879
2133
 
1880
- </Project>
1881
- """,
2134
+ </Project>
2135
+ """,
1882
2136
  additionalFilesExpected:
1883
2137
  [
1884
2138
  ("Directory.Packages.props", """
@@ -1888,47 +2142,50 @@ public partial class UpdateWorkerTests
1888
2142
  <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
1889
2143
  </PropertyGroup>
1890
2144
  <ItemGroup>
1891
- <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
1892
- <PackageVersion Include="Microsoft.VisualStudio.Sdk.TestFramework" Version="17.6.16" />
1893
- <PackageVersion Include="Microsoft.VisualStudio.Sdk.TestFramework.Xunit" Version="17.6.16" />
1894
- <PackageVersion Include="Microsoft.VisualStudio.Shell.15.0" Version="17.6.36389" />
1895
- <PackageVersion Include="Microsoft.VisualStudio.Text.Data" Version="17.6.268" />
1896
- <PackageVersion Include="Moq" Version="4.18.4" />
1897
- <PackageVersion Include="xunit" Version="2.5.0" />
1898
- <PackageVersion Include="xunit.runner.visualstudio" Version="2.5.0" />
2145
+ <PackageVersion Include="Some.Package" Version="1.1.0" />
2146
+ <PackageVersion Include="Some.Dependency" Version="1.1.0" />
2147
+ <PackageVersion Include="Unrelated.Package" Version="1.0.0" />
1899
2148
  </ItemGroup>
1900
2149
  </Project>
1901
2150
  """),
1902
2151
  ("Directory.Build.props", """
1903
2152
  <Project>
1904
2153
  <PropertyGroup>
1905
- <PreferredTargetFramework>net7.0</PreferredTargetFramework>
2154
+ <PreferredTargetFramework>net8.0</PreferredTargetFramework>
1906
2155
  </PropertyGroup>
1907
2156
  </Project>
1908
2157
  """)
1909
- ]);
2158
+ ]
2159
+ );
1910
2160
  }
1911
2161
 
1912
2162
  [Fact]
1913
2163
  public async Task AddTransitiveDependencyByAddingPackageReferenceAndVersion()
1914
2164
  {
1915
- await TestUpdateForProject("System.Text.Json", "5.0.0", "5.0.2", isTransitive: true,
2165
+ await TestUpdateForProject("Some.Transitive.Dependency", "5.0.0", "5.0.2", isTransitive: true,
2166
+ packages:
2167
+ [
2168
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "3.1.3", "net8.0", [(null, [("Some.Transitive.Dependency", "5.0.0")])]),
2169
+ MockNuGetPackage.CreateSimplePackage("Some.Transitive.Dependency", "5.0.0", "net8.0"),
2170
+ MockNuGetPackage.CreateSimplePackage("Some.Transitive.Dependency", "5.0.2", "net8.0"),
2171
+ ],
1916
2172
  // initial
1917
2173
  projectContents: """
1918
- <Project Sdk="Microsoft.NET.Sdk">
2174
+ <Project Sdk="Microsoft.NET.Sdk">
1919
2175
 
1920
- <PropertyGroup>
1921
- <TargetFramework>net5.0</TargetFramework>
1922
- </PropertyGroup>
2176
+ <PropertyGroup>
2177
+ <TargetFramework>net8.0</TargetFramework>
2178
+ </PropertyGroup>
1923
2179
 
1924
- <ItemGroup>
1925
- <PackageReference Include="Mongo2Go" />
1926
- </ItemGroup>
2180
+ <ItemGroup>
2181
+ <PackageReference Include="Some.Package" />
2182
+ </ItemGroup>
1927
2183
 
1928
- </Project>
1929
- """,
2184
+ </Project>
2185
+ """,
1930
2186
  additionalFiles:
1931
2187
  [
2188
+ ("Directory.Build.props", "<Project />"),
1932
2189
  // initial props files
1933
2190
  ("Directory.Packages.props", """
1934
2191
  <Project>
@@ -1936,26 +2193,26 @@ public partial class UpdateWorkerTests
1936
2193
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1937
2194
  </PropertyGroup>
1938
2195
  <ItemGroup>
1939
- <PackageVersion Include="Mongo2Go" Version="3.1.3" />
2196
+ <PackageVersion Include="Some.Package" Version="3.1.3" />
1940
2197
  </ItemGroup>
1941
2198
  </Project>
1942
2199
  """)
1943
2200
  ],
1944
2201
  // expected
1945
2202
  expectedProjectContents: """
1946
- <Project Sdk="Microsoft.NET.Sdk">
2203
+ <Project Sdk="Microsoft.NET.Sdk">
1947
2204
 
1948
- <PropertyGroup>
1949
- <TargetFramework>net5.0</TargetFramework>
1950
- </PropertyGroup>
2205
+ <PropertyGroup>
2206
+ <TargetFramework>net8.0</TargetFramework>
2207
+ </PropertyGroup>
1951
2208
 
1952
- <ItemGroup>
1953
- <PackageReference Include="Mongo2Go" />
1954
- <PackageReference Include="System.Text.Json" />
1955
- </ItemGroup>
2209
+ <ItemGroup>
2210
+ <PackageReference Include="Some.Package" />
2211
+ <PackageReference Include="Some.Transitive.Dependency" />
2212
+ </ItemGroup>
1956
2213
 
1957
- </Project>
1958
- """,
2214
+ </Project>
2215
+ """,
1959
2216
  additionalFilesExpected:
1960
2217
  [
1961
2218
  // expected props files
@@ -1965,35 +2222,43 @@ public partial class UpdateWorkerTests
1965
2222
  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1966
2223
  </PropertyGroup>
1967
2224
  <ItemGroup>
1968
- <PackageVersion Include="Mongo2Go" Version="3.1.3" />
1969
- <PackageVersion Include="System.Text.Json" Version="5.0.2" />
2225
+ <PackageVersion Include="Some.Package" Version="3.1.3" />
2226
+ <PackageVersion Include="Some.Transitive.Dependency" Version="5.0.2" />
1970
2227
  </ItemGroup>
1971
2228
  </Project>
1972
2229
  """)
1973
- ]);
2230
+ ]
2231
+ );
1974
2232
  }
1975
2233
 
1976
2234
  [Fact]
1977
2235
  public async Task PinTransitiveDependencyByAddingPackageVersion()
1978
2236
  {
1979
- await TestUpdateForProject("System.Text.Json", "5.0.0", "5.0.2", isTransitive: true,
2237
+ await TestUpdateForProject("Some.Transitive.Dependency", "5.0.0", "5.0.2", isTransitive: true,
2238
+ packages:
2239
+ [
2240
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "3.1.3", "net8.0", [(null, [("Some.Transitive.Dependency", "5.0.0")])]),
2241
+ MockNuGetPackage.CreateSimplePackage("Some.Transitive.Dependency", "5.0.0", "net8.0"),
2242
+ MockNuGetPackage.CreateSimplePackage("Some.Transitive.Dependency", "5.0.2", "net8.0"),
2243
+ ],
1980
2244
  // initial
1981
2245
  projectContents: """
1982
- <Project Sdk="Microsoft.NET.Sdk">
2246
+ <Project Sdk="Microsoft.NET.Sdk">
1983
2247
 
1984
- <PropertyGroup>
1985
- <NoWarn>$(NoWarn);NETSDK1138</NoWarn>
1986
- <TargetFramework>net5.0</TargetFramework>
1987
- </PropertyGroup>
2248
+ <PropertyGroup>
2249
+ <NoWarn>$(NoWarn);NETSDK1138</NoWarn>
2250
+ <TargetFramework>net8.0</TargetFramework>
2251
+ </PropertyGroup>
1988
2252
 
1989
- <ItemGroup>
1990
- <PackageReference Include="Mongo2Go" />
1991
- </ItemGroup>
2253
+ <ItemGroup>
2254
+ <PackageReference Include="Some.Package" />
2255
+ </ItemGroup>
1992
2256
 
1993
- </Project>
1994
- """,
2257
+ </Project>
2258
+ """,
1995
2259
  additionalFiles:
1996
2260
  [
2261
+ ("Directory.Build.props", "<Project />"),
1997
2262
  // initial props files
1998
2263
  ("Directory.Packages.props", """
1999
2264
  <Project>
@@ -2002,26 +2267,26 @@ public partial class UpdateWorkerTests
2002
2267
  <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
2003
2268
  </PropertyGroup>
2004
2269
  <ItemGroup>
2005
- <PackageVersion Include="Mongo2Go" Version="3.1.3" />
2270
+ <PackageVersion Include="Some.Package" Version="3.1.3" />
2006
2271
  </ItemGroup>
2007
2272
  </Project>
2008
2273
  """)
2009
2274
  ],
2010
2275
  // expected
2011
2276
  expectedProjectContents: """
2012
- <Project Sdk="Microsoft.NET.Sdk">
2277
+ <Project Sdk="Microsoft.NET.Sdk">
2013
2278
 
2014
- <PropertyGroup>
2015
- <NoWarn>$(NoWarn);NETSDK1138</NoWarn>
2016
- <TargetFramework>net5.0</TargetFramework>
2017
- </PropertyGroup>
2279
+ <PropertyGroup>
2280
+ <NoWarn>$(NoWarn);NETSDK1138</NoWarn>
2281
+ <TargetFramework>net8.0</TargetFramework>
2282
+ </PropertyGroup>
2018
2283
 
2019
- <ItemGroup>
2020
- <PackageReference Include="Mongo2Go" />
2021
- </ItemGroup>
2284
+ <ItemGroup>
2285
+ <PackageReference Include="Some.Package" />
2286
+ </ItemGroup>
2022
2287
 
2023
- </Project>
2024
- """,
2288
+ </Project>
2289
+ """,
2025
2290
  additionalFilesExpected:
2026
2291
  [
2027
2292
  // expected props files
@@ -2032,28 +2297,34 @@ public partial class UpdateWorkerTests
2032
2297
  <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
2033
2298
  </PropertyGroup>
2034
2299
  <ItemGroup>
2035
- <PackageVersion Include="Mongo2Go" Version="3.1.3" />
2036
- <PackageVersion Include="System.Text.Json" Version="5.0.2" />
2300
+ <PackageVersion Include="Some.Package" Version="3.1.3" />
2301
+ <PackageVersion Include="Some.Transitive.Dependency" Version="5.0.2" />
2037
2302
  </ItemGroup>
2038
2303
  </Project>
2039
2304
  """)
2040
- ]);
2305
+ ]
2306
+ );
2041
2307
  }
2042
2308
 
2043
2309
  [Fact]
2044
2310
  public async Task PropsFileNameWithDifferentCasing()
2045
2311
  {
2046
- await TestUpdateForProject("Newtonsoft.Json", "12.0.1", "13.0.1",
2312
+ await TestUpdateForProject("Some.Package", "12.0.1", "13.0.1",
2313
+ packages:
2314
+ [
2315
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "12.0.1", "net7.0"),
2316
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net7.0"),
2317
+ ],
2047
2318
  projectContents: """
2048
- <Project Sdk="Microsoft.NET.Sdk">
2049
- <PropertyGroup>
2050
- <TargetFramework>net7.0</TargetFramework>
2051
- </PropertyGroup>
2052
- <ItemGroup>
2053
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
2054
- </ItemGroup>
2055
- </Project>
2056
- """,
2319
+ <Project Sdk="Microsoft.NET.Sdk">
2320
+ <PropertyGroup>
2321
+ <TargetFramework>net7.0</TargetFramework>
2322
+ </PropertyGroup>
2323
+ <ItemGroup>
2324
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
2325
+ </ItemGroup>
2326
+ </Project>
2327
+ """,
2057
2328
  additionalFiles:
2058
2329
  [
2059
2330
  ("Directory.Build.props", """
@@ -2065,22 +2336,22 @@ public partial class UpdateWorkerTests
2065
2336
  ("Versions.Props", """
2066
2337
  <Project>
2067
2338
  <PropertyGroup>
2068
- <NewtonsoftJsonVersion>12.0.1</NewtonsoftJsonVersion>
2339
+ <SomePackageVersion>12.0.1</SomePackageVersion>
2069
2340
  </PropertyGroup>
2070
2341
  </Project>
2071
2342
  """)
2072
2343
  ],
2073
2344
  // no change
2074
2345
  expectedProjectContents: """
2075
- <Project Sdk="Microsoft.NET.Sdk">
2076
- <PropertyGroup>
2077
- <TargetFramework>net7.0</TargetFramework>
2078
- </PropertyGroup>
2079
- <ItemGroup>
2080
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
2081
- </ItemGroup>
2082
- </Project>
2083
- """,
2346
+ <Project Sdk="Microsoft.NET.Sdk">
2347
+ <PropertyGroup>
2348
+ <TargetFramework>net7.0</TargetFramework>
2349
+ </PropertyGroup>
2350
+ <ItemGroup>
2351
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
2352
+ </ItemGroup>
2353
+ </Project>
2354
+ """,
2084
2355
  additionalFilesExpected:
2085
2356
  [
2086
2357
  // no change
@@ -2093,7 +2364,7 @@ public partial class UpdateWorkerTests
2093
2364
  ("Versions.Props", """
2094
2365
  <Project>
2095
2366
  <PropertyGroup>
2096
- <NewtonsoftJsonVersion>13.0.1</NewtonsoftJsonVersion>
2367
+ <SomePackageVersion>13.0.1</SomePackageVersion>
2097
2368
  </PropertyGroup>
2098
2369
  </Project>
2099
2370
  """)
@@ -2105,27 +2376,32 @@ public partial class UpdateWorkerTests
2105
2376
  public async Task VersionAttributeWithDifferentCasing_VersionNumberInline()
2106
2377
  {
2107
2378
  // the version attribute in the project has an all lowercase name
2108
- await TestUpdateForProject("Newtonsoft.Json", "12.0.1", "13.0.1",
2379
+ await TestUpdateForProject("Some.Package", "12.0.1", "13.0.1",
2380
+ packages:
2381
+ [
2382
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "12.0.1", "net7.0"),
2383
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net7.0"),
2384
+ ],
2109
2385
  projectContents: """
2110
- <Project Sdk="Microsoft.NET.Sdk">
2111
- <PropertyGroup>
2112
- <TargetFramework>net7.0</TargetFramework>
2113
- </PropertyGroup>
2114
- <ItemGroup>
2115
- <PackageReference Include="Newtonsoft.Json" version="12.0.1" />
2116
- </ItemGroup>
2117
- </Project>
2118
- """,
2386
+ <Project Sdk="Microsoft.NET.Sdk">
2387
+ <PropertyGroup>
2388
+ <TargetFramework>net7.0</TargetFramework>
2389
+ </PropertyGroup>
2390
+ <ItemGroup>
2391
+ <PackageReference Include="Some.Package" version="12.0.1" />
2392
+ </ItemGroup>
2393
+ </Project>
2394
+ """,
2119
2395
  expectedProjectContents: """
2120
- <Project Sdk="Microsoft.NET.Sdk">
2121
- <PropertyGroup>
2122
- <TargetFramework>net7.0</TargetFramework>
2123
- </PropertyGroup>
2124
- <ItemGroup>
2125
- <PackageReference Include="Newtonsoft.Json" version="13.0.1" />
2126
- </ItemGroup>
2127
- </Project>
2128
- """
2396
+ <Project Sdk="Microsoft.NET.Sdk">
2397
+ <PropertyGroup>
2398
+ <TargetFramework>net7.0</TargetFramework>
2399
+ </PropertyGroup>
2400
+ <ItemGroup>
2401
+ <PackageReference Include="Some.Package" version="13.0.1" />
2402
+ </ItemGroup>
2403
+ </Project>
2404
+ """
2129
2405
  );
2130
2406
  }
2131
2407
 
@@ -2133,17 +2409,22 @@ public partial class UpdateWorkerTests
2133
2409
  public async Task VersionAttributeWithDifferentCasing_VersionNumberInProperty()
2134
2410
  {
2135
2411
  // the version attribute in the project has an all lowercase name
2136
- await TestUpdateForProject("Newtonsoft.Json", "12.0.1", "13.0.1",
2412
+ await TestUpdateForProject("Some.Package", "12.0.1", "13.0.1",
2413
+ packages:
2414
+ [
2415
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "12.0.1", "net7.0"),
2416
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net7.0"),
2417
+ ],
2137
2418
  projectContents: """
2138
- <Project Sdk="Microsoft.NET.Sdk">
2139
- <PropertyGroup>
2140
- <TargetFramework>net7.0</TargetFramework>
2141
- </PropertyGroup>
2142
- <ItemGroup>
2143
- <PackageReference Include="Newtonsoft.Json" version="$(NewtonsoftJsonVersion)" />
2144
- </ItemGroup>
2145
- </Project>
2146
- """,
2419
+ <Project Sdk="Microsoft.NET.Sdk">
2420
+ <PropertyGroup>
2421
+ <TargetFramework>net7.0</TargetFramework>
2422
+ </PropertyGroup>
2423
+ <ItemGroup>
2424
+ <PackageReference Include="Some.Package" version="$(SomePackageVersion)" />
2425
+ </ItemGroup>
2426
+ </Project>
2427
+ """,
2147
2428
  additionalFiles:
2148
2429
  [
2149
2430
  ("Directory.Build.props", """
@@ -2154,22 +2435,22 @@ public partial class UpdateWorkerTests
2154
2435
  ("Versions.props", """
2155
2436
  <Project>
2156
2437
  <PropertyGroup>
2157
- <NewtonsoftJsonVersion>12.0.1</NewtonsoftJsonVersion>
2438
+ <SomePackageVersion>12.0.1</SomePackageVersion>
2158
2439
  </PropertyGroup>
2159
2440
  </Project>
2160
2441
  """)
2161
2442
  ],
2162
2443
  // no change
2163
2444
  expectedProjectContents: """
2164
- <Project Sdk="Microsoft.NET.Sdk">
2165
- <PropertyGroup>
2166
- <TargetFramework>net7.0</TargetFramework>
2167
- </PropertyGroup>
2168
- <ItemGroup>
2169
- <PackageReference Include="Newtonsoft.Json" version="$(NewtonsoftJsonVersion)" />
2170
- </ItemGroup>
2171
- </Project>
2172
- """,
2445
+ <Project Sdk="Microsoft.NET.Sdk">
2446
+ <PropertyGroup>
2447
+ <TargetFramework>net7.0</TargetFramework>
2448
+ </PropertyGroup>
2449
+ <ItemGroup>
2450
+ <PackageReference Include="Some.Package" version="$(SomePackageVersion)" />
2451
+ </ItemGroup>
2452
+ </Project>
2453
+ """,
2173
2454
  additionalFilesExpected:
2174
2455
  [
2175
2456
  // no change
@@ -2182,7 +2463,7 @@ public partial class UpdateWorkerTests
2182
2463
  ("Versions.props", """
2183
2464
  <Project>
2184
2465
  <PropertyGroup>
2185
- <NewtonsoftJsonVersion>13.0.1</NewtonsoftJsonVersion>
2466
+ <SomePackageVersion>13.0.1</SomePackageVersion>
2186
2467
  </PropertyGroup>
2187
2468
  </Project>
2188
2469
  """)
@@ -2193,20 +2474,27 @@ public partial class UpdateWorkerTests
2193
2474
  [Fact]
2194
2475
  public async Task DirectoryPackagesPropsDoesCentralPackagePinningGetsUpdatedIfTransitiveFlagIsSet()
2195
2476
  {
2196
- await TestUpdateForProject("xunit.assert", "2.5.2", "2.5.3",
2477
+ await TestUpdateForProject("Some.Package.Extensions", "1.0.0", "1.1.0",
2478
+ packages:
2479
+ [
2480
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net7.0"),
2481
+ MockNuGetPackage.CreateSimplePackage("Some.Package.Extensions", "1.0.0", "net7.0", [(null, [("Some.Package", "1.0.0")])]),
2482
+ MockNuGetPackage.CreateSimplePackage("Some.Package.Extensions", "1.1.0", "net7.0", [(null, [("Some.Package", "1.0.0")])]),
2483
+ ],
2197
2484
  isTransitive: true,
2198
2485
  projectContents: """
2199
- <Project Sdk="Microsoft.NET.Sdk">
2200
- <PropertyGroup>
2201
- <TargetFramework>net7.0</TargetFramework>
2202
- </PropertyGroup>
2203
- <ItemGroup>
2204
- <PackageReference Include="xunit" />
2205
- </ItemGroup>
2206
- </Project>
2207
- """,
2486
+ <Project Sdk="Microsoft.NET.Sdk">
2487
+ <PropertyGroup>
2488
+ <TargetFramework>net7.0</TargetFramework>
2489
+ </PropertyGroup>
2490
+ <ItemGroup>
2491
+ <PackageReference Include="Some.Package.Extensions" />
2492
+ </ItemGroup>
2493
+ </Project>
2494
+ """,
2208
2495
  additionalFiles:
2209
2496
  [
2497
+ ("Directory.Build.props", "<Project />"),
2210
2498
  ("Directory.Packages.props", """
2211
2499
  <Project>
2212
2500
  <PropertyGroup>
@@ -2214,22 +2502,22 @@ public partial class UpdateWorkerTests
2214
2502
  <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
2215
2503
  </PropertyGroup>
2216
2504
  <ItemGroup>
2217
- <PackageVersion Include="xunit" Version="2.5.2" />
2218
- <PackageVersion Include="xunit.assert" Version="2.5.2" />
2505
+ <PackageVersion Include="Some.Package" Version="1.0.0" />
2506
+ <PackageVersion Include="Some.Package.Extensions" Version="1.0.0" />
2219
2507
  </ItemGroup>
2220
2508
  </Project>
2221
2509
  """)
2222
2510
  ],
2223
2511
  expectedProjectContents: """
2224
- <Project Sdk="Microsoft.NET.Sdk">
2225
- <PropertyGroup>
2226
- <TargetFramework>net7.0</TargetFramework>
2227
- </PropertyGroup>
2228
- <ItemGroup>
2229
- <PackageReference Include="xunit" />
2230
- </ItemGroup>
2231
- </Project>
2232
- """,
2512
+ <Project Sdk="Microsoft.NET.Sdk">
2513
+ <PropertyGroup>
2514
+ <TargetFramework>net7.0</TargetFramework>
2515
+ </PropertyGroup>
2516
+ <ItemGroup>
2517
+ <PackageReference Include="Some.Package.Extensions" />
2518
+ </ItemGroup>
2519
+ </Project>
2520
+ """,
2233
2521
  additionalFilesExpected:
2234
2522
  [
2235
2523
  ("Directory.Packages.props", """
@@ -2239,8 +2527,8 @@ public partial class UpdateWorkerTests
2239
2527
  <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
2240
2528
  </PropertyGroup>
2241
2529
  <ItemGroup>
2242
- <PackageVersion Include="xunit" Version="2.5.2" />
2243
- <PackageVersion Include="xunit.assert" Version="2.5.3" />
2530
+ <PackageVersion Include="Some.Package" Version="1.0.0" />
2531
+ <PackageVersion Include="Some.Package.Extensions" Version="1.1.0" />
2244
2532
  </ItemGroup>
2245
2533
  </Project>
2246
2534
  """)
@@ -2251,18 +2539,24 @@ public partial class UpdateWorkerTests
2251
2539
  [Fact]
2252
2540
  public async Task DirectoryPackagesPropsDoesNotGetDuplicateEntryIfCentralTransitivePinningIsUsed()
2253
2541
  {
2254
- await TestUpdateForProject("xunit.assert", "2.5.2", "2.5.3",
2542
+ await TestUpdateForProject("Some.Package.Extensions", "1.0.0", "1.1.0",
2543
+ packages:
2544
+ [
2545
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net7.0"),
2546
+ MockNuGetPackage.CreateSimplePackage("Some.Package.Extensions", "1.0.0", "net7.0", [(null, [("Some.Package", "1.0.0")])]),
2547
+ MockNuGetPackage.CreateSimplePackage("Some.Package.Extensions", "1.1.0", "net7.0", [(null, [("Some.Package", "1.0.0")])]),
2548
+ ],
2255
2549
  isTransitive: true,
2256
2550
  projectContents: """
2257
- <Project Sdk="Microsoft.NET.Sdk">
2258
- <PropertyGroup>
2259
- <TargetFramework>net7.0</TargetFramework>
2260
- </PropertyGroup>
2261
- <ItemGroup>
2262
- <PackageReference Include="xunit" />
2263
- </ItemGroup>
2264
- </Project>
2265
- """,
2551
+ <Project Sdk="Microsoft.NET.Sdk">
2552
+ <PropertyGroup>
2553
+ <TargetFramework>net7.0</TargetFramework>
2554
+ </PropertyGroup>
2555
+ <ItemGroup>
2556
+ <PackageReference Include="Some.Package.Extensions" />
2557
+ </ItemGroup>
2558
+ </Project>
2559
+ """,
2266
2560
  additionalFiles:
2267
2561
  [
2268
2562
  ("Directory.Packages.props", """
@@ -2272,22 +2566,22 @@ public partial class UpdateWorkerTests
2272
2566
  <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
2273
2567
  </PropertyGroup>
2274
2568
  <ItemGroup>
2275
- <PackageVersion Include="xunit" Version="2.5.2" />
2276
- <PackageVersion Include="xunit.assert" Version="2.5.3" />
2569
+ <PackageVersion Include="Some.Package" Version="1.0.0" />
2570
+ <PackageVersion Include="Some.Package.Extensions" Version="1.1.0" />
2277
2571
  </ItemGroup>
2278
2572
  </Project>
2279
2573
  """)
2280
2574
  ],
2281
2575
  expectedProjectContents: """
2282
- <Project Sdk="Microsoft.NET.Sdk">
2283
- <PropertyGroup>
2284
- <TargetFramework>net7.0</TargetFramework>
2285
- </PropertyGroup>
2286
- <ItemGroup>
2287
- <PackageReference Include="xunit" />
2288
- </ItemGroup>
2289
- </Project>
2290
- """,
2576
+ <Project Sdk="Microsoft.NET.Sdk">
2577
+ <PropertyGroup>
2578
+ <TargetFramework>net7.0</TargetFramework>
2579
+ </PropertyGroup>
2580
+ <ItemGroup>
2581
+ <PackageReference Include="Some.Package.Extensions" />
2582
+ </ItemGroup>
2583
+ </Project>
2584
+ """,
2291
2585
  additionalFilesExpected:
2292
2586
  [
2293
2587
  ("Directory.Packages.props", """
@@ -2297,8 +2591,8 @@ public partial class UpdateWorkerTests
2297
2591
  <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
2298
2592
  </PropertyGroup>
2299
2593
  <ItemGroup>
2300
- <PackageVersion Include="xunit" Version="2.5.2" />
2301
- <PackageVersion Include="xunit.assert" Version="2.5.3" />
2594
+ <PackageVersion Include="Some.Package" Version="1.0.0" />
2595
+ <PackageVersion Include="Some.Package.Extensions" Version="1.1.0" />
2302
2596
  </ItemGroup>
2303
2597
  </Project>
2304
2598
  """)
@@ -2309,170 +2603,189 @@ public partial class UpdateWorkerTests
2309
2603
  [Fact]
2310
2604
  public async Task PackageWithFourPartVersionCanBeUpdated()
2311
2605
  {
2312
- await TestUpdateForProject("AWSSDK.Core", "3.7.204.13", "3.7.204.14",
2606
+ await TestUpdateForProject("Some.Package", "1.2.3.4", "1.2.3.5",
2607
+ packages:
2608
+ [
2609
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.2.3.4", "net7.0"),
2610
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.2.3.5", "net7.0"),
2611
+ ],
2313
2612
  projectContents: """
2314
- <Project Sdk="Microsoft.NET.Sdk">
2315
- <PropertyGroup>
2316
- <TargetFramework>net7.0</TargetFramework>
2317
- </PropertyGroup>
2318
- <ItemGroup>
2319
- <PackageReference Include="AWSSDK.Core" Version="3.7.204.13" />
2320
- </ItemGroup>
2321
- </Project>
2322
- """,
2613
+ <Project Sdk="Microsoft.NET.Sdk">
2614
+ <PropertyGroup>
2615
+ <TargetFramework>net7.0</TargetFramework>
2616
+ </PropertyGroup>
2617
+ <ItemGroup>
2618
+ <PackageReference Include="Some.Package" Version="1.2.3.4" />
2619
+ </ItemGroup>
2620
+ </Project>
2621
+ """,
2323
2622
  expectedProjectContents: """
2324
- <Project Sdk="Microsoft.NET.Sdk">
2325
- <PropertyGroup>
2326
- <TargetFramework>net7.0</TargetFramework>
2327
- </PropertyGroup>
2328
- <ItemGroup>
2329
- <PackageReference Include="AWSSDK.Core" Version="3.7.204.14" />
2330
- </ItemGroup>
2331
- </Project>
2332
- """
2623
+ <Project Sdk="Microsoft.NET.Sdk">
2624
+ <PropertyGroup>
2625
+ <TargetFramework>net7.0</TargetFramework>
2626
+ </PropertyGroup>
2627
+ <ItemGroup>
2628
+ <PackageReference Include="Some.Package" Version="1.2.3.5" />
2629
+ </ItemGroup>
2630
+ </Project>
2631
+ """
2333
2632
  );
2334
2633
  }
2335
2634
 
2336
2635
  [Fact]
2337
2636
  public async Task PackageWithOnlyBuildTargetsCanBeUpdated()
2338
2637
  {
2339
- await TestUpdateForProject("Microsoft.Windows.Compatibility", "7.0.0", "8.0.0",
2638
+ await TestUpdateForProject("Some.Package", "7.0.0", "7.1.0",
2639
+ packages:
2640
+ [
2641
+ new("Some.Package", "7.0.0", Files: [("buildTransitive/net7.0/_._", [])]),
2642
+ new("Some.Package", "7.1.0", Files: [("buildTransitive/net7.0/_._", [])]),
2643
+ ],
2340
2644
  projectContents: """
2341
- <Project Sdk="Microsoft.NET.Sdk">
2342
- <PropertyGroup>
2343
- <TargetFramework>net5.0</TargetFramework>
2344
- </PropertyGroup>
2345
- <ItemGroup>
2346
- <PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.0" />
2347
- </ItemGroup>
2348
- </Project>
2349
- """,
2645
+ <Project Sdk="Microsoft.NET.Sdk">
2646
+ <PropertyGroup>
2647
+ <TargetFramework>net8.0</TargetFramework>
2648
+ </PropertyGroup>
2649
+ <ItemGroup>
2650
+ <PackageReference Include="Some.Package" Version="7.0.0" />
2651
+ </ItemGroup>
2652
+ </Project>
2653
+ """,
2350
2654
  expectedProjectContents: """
2351
- <Project Sdk="Microsoft.NET.Sdk">
2352
- <PropertyGroup>
2353
- <TargetFramework>net5.0</TargetFramework>
2354
- </PropertyGroup>
2355
- <ItemGroup>
2356
- <PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.0" />
2357
- </ItemGroup>
2358
- </Project>
2359
- """
2655
+ <Project Sdk="Microsoft.NET.Sdk">
2656
+ <PropertyGroup>
2657
+ <TargetFramework>net8.0</TargetFramework>
2658
+ </PropertyGroup>
2659
+ <ItemGroup>
2660
+ <PackageReference Include="Some.Package" Version="7.1.0" />
2661
+ </ItemGroup>
2662
+ </Project>
2663
+ """
2360
2664
  );
2361
2665
  }
2362
2666
 
2363
2667
  [Fact]
2364
2668
  public async Task UpdatePackageVersionFromPropertiesWithAndWithoutConditions()
2365
2669
  {
2366
- await TestUpdateForProject("Newtonsoft.Json", "12.0.1", "13.0.1",
2670
+ await TestUpdateForProject("Some.Package", "12.0.1", "13.0.1",
2671
+ packages:
2672
+ [
2673
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "12.0.1", "net8.0"),
2674
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
2675
+ ],
2367
2676
  projectContents: """
2368
- <Project Sdk="Microsoft.NET.Sdk">
2369
- <PropertyGroup>
2370
- <TargetFramework>netstandard2.0</TargetFramework>
2371
- <NewtonsoftJsonVersion Condition="$(UseLegacyVersion7) == 'true'">7.0.1</NewtonsoftJsonVersion>
2372
- <NewtonsoftJsonVersion>12.0.1</NewtonsoftJsonVersion>
2373
- <NewtonsoftJsonVersion Condition="$(UseLegacyVersion9) == 'true'">9.0.1</NewtonsoftJsonVersion>
2374
- </PropertyGroup>
2375
- <ItemGroup>
2376
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
2377
- </ItemGroup>
2378
- </Project>
2379
- """,
2677
+ <Project Sdk="Microsoft.NET.Sdk">
2678
+ <PropertyGroup>
2679
+ <TargetFramework>net8.0</TargetFramework>
2680
+ <SomePackageVersion Condition="$(UseLegacyVersion7) == 'true'">7.0.1</SomePackageVersion>
2681
+ <SomePackageVersion>12.0.1</SomePackageVersion>
2682
+ <SomePackageVersion Condition="$(UseLegacyVersion9) == 'true'">9.0.1</SomePackageVersion>
2683
+ </PropertyGroup>
2684
+ <ItemGroup>
2685
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
2686
+ </ItemGroup>
2687
+ </Project>
2688
+ """,
2380
2689
  expectedProjectContents: """
2381
- <Project Sdk="Microsoft.NET.Sdk">
2382
- <PropertyGroup>
2383
- <TargetFramework>netstandard2.0</TargetFramework>
2384
- <NewtonsoftJsonVersion Condition="$(UseLegacyVersion7) == 'true'">7.0.1</NewtonsoftJsonVersion>
2385
- <NewtonsoftJsonVersion>13.0.1</NewtonsoftJsonVersion>
2386
- <NewtonsoftJsonVersion Condition="$(UseLegacyVersion9) == 'true'">9.0.1</NewtonsoftJsonVersion>
2387
- </PropertyGroup>
2388
- <ItemGroup>
2389
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
2390
- </ItemGroup>
2391
- </Project>
2392
- """
2690
+ <Project Sdk="Microsoft.NET.Sdk">
2691
+ <PropertyGroup>
2692
+ <TargetFramework>net8.0</TargetFramework>
2693
+ <SomePackageVersion Condition="$(UseLegacyVersion7) == 'true'">7.0.1</SomePackageVersion>
2694
+ <SomePackageVersion>13.0.1</SomePackageVersion>
2695
+ <SomePackageVersion Condition="$(UseLegacyVersion9) == 'true'">9.0.1</SomePackageVersion>
2696
+ </PropertyGroup>
2697
+ <ItemGroup>
2698
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
2699
+ </ItemGroup>
2700
+ </Project>
2701
+ """
2393
2702
  );
2394
2703
  }
2395
2704
 
2396
2705
  [Fact]
2397
2706
  public async Task UpdatePackageVersionFromPropertyWithConditionCheckingForEmptyString()
2398
2707
  {
2399
- await TestUpdateForProject("Newtonsoft.Json", "12.0.1", "13.0.1",
2708
+ await TestUpdateForProject("Some.Package", "12.0.1", "13.0.1",
2709
+ packages:
2710
+ [
2711
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "12.0.1", "net8.0"),
2712
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
2713
+ ],
2400
2714
  projectContents: """
2401
- <Project Sdk="Microsoft.NET.Sdk">
2402
- <PropertyGroup>
2403
- <TargetFramework>netstandard2.0</TargetFramework>
2404
- <NewtonsoftJsonVersion Condition="$(NewtonsoftJsonVersion) == ''">12.0.1</NewtonsoftJsonVersion>
2405
- <NewtonsoftJsonVersion Condition="$(UseLegacyVersion9) == 'true'">9.0.1</NewtonsoftJsonVersion>
2406
- </PropertyGroup>
2407
- <ItemGroup>
2408
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
2409
- </ItemGroup>
2410
- </Project>
2411
- """,
2715
+ <Project Sdk="Microsoft.NET.Sdk">
2716
+ <PropertyGroup>
2717
+ <TargetFramework>net8.0</TargetFramework>
2718
+ <SomePackageVersion Condition="$(SomePackageVersion) == ''">12.0.1</SomePackageVersion>
2719
+ <SomePackageVersion Condition="$(UseLegacyVersion9) == 'true'">9.0.1</SomePackageVersion>
2720
+ </PropertyGroup>
2721
+ <ItemGroup>
2722
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
2723
+ </ItemGroup>
2724
+ </Project>
2725
+ """,
2412
2726
  expectedProjectContents: """
2413
- <Project Sdk="Microsoft.NET.Sdk">
2414
- <PropertyGroup>
2415
- <TargetFramework>netstandard2.0</TargetFramework>
2416
- <NewtonsoftJsonVersion Condition="$(NewtonsoftJsonVersion) == ''">13.0.1</NewtonsoftJsonVersion>
2417
- <NewtonsoftJsonVersion Condition="$(UseLegacyVersion9) == 'true'">9.0.1</NewtonsoftJsonVersion>
2418
- </PropertyGroup>
2419
- <ItemGroup>
2420
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
2421
- </ItemGroup>
2422
- </Project>
2423
- """
2727
+ <Project Sdk="Microsoft.NET.Sdk">
2728
+ <PropertyGroup>
2729
+ <TargetFramework>net8.0</TargetFramework>
2730
+ <SomePackageVersion Condition="$(SomePackageVersion) == ''">13.0.1</SomePackageVersion>
2731
+ <SomePackageVersion Condition="$(UseLegacyVersion9) == 'true'">9.0.1</SomePackageVersion>
2732
+ </PropertyGroup>
2733
+ <ItemGroup>
2734
+ <PackageReference Include="Some.Package" Version="$(SomePackageVersion)" />
2735
+ </ItemGroup>
2736
+ </Project>
2737
+ """
2424
2738
  );
2425
2739
  }
2426
2740
 
2427
2741
  [Fact]
2428
2742
  public async Task NoChange_IfThereAreIncoherentVersions()
2429
2743
  {
2430
- // Make sure we don't update if there are incoherent versions
2431
- await TestNoChangeforProject("Microsoft.EntityFrameworkCore.SqlServer", "2.1.0", "2.2.0",
2744
+ // trying to update `Transitive.Dependency` to 1.1.0 would normally pull `Some.Package` from 1.0.0 to 1.1.0,
2745
+ // but the TFM doesn't allow it
2746
+ await TestNoChangeforProject("Transitive.Dependency", "1.0.0", "1.1.0",
2747
+ packages:
2748
+ [
2749
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net7.0", [(null, [("Transitive.Dependency", "[1.0.0]")])]),
2750
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "1.1.0", "net8.0", [(null, [("Transitive.Dependency", "[1.1.0]")])]),
2751
+ MockNuGetPackage.CreateSimplePackage("Transitive.Dependency", "1.0.0", "net7.0"),
2752
+ MockNuGetPackage.CreateSimplePackage("Transitive.Dependency", "1.1.0", "net7.0"),
2753
+ ],
2432
2754
  projectContents: """
2433
- <Project Sdk="Microsoft.NET.Sdk">
2434
- <PropertyGroup>
2435
- <TargetFramework>netcoreapp2.1</TargetFramework>
2436
- </PropertyGroup>
2437
- <ItemGroup>
2438
- <PackageReference Include="Microsoft.Extensions.Primitives" Version="2.2.0" />
2439
- <PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
2440
- <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
2441
- <PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
2442
- <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
2443
- <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
2444
- <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.2.0" />
2445
- <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.2.0" />
2446
- <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
2447
- <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" />
2448
- <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="2.2.0" />
2449
- <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.0" />
2450
- <PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="2.2.0" />
2451
- <PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="2.2.0" />
2452
- <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
2453
- <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0" />
2454
- <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0" />
2455
- </ItemGroup>
2456
- </Project>
2457
- """);
2755
+ <Project Sdk="Microsoft.NET.Sdk">
2756
+ <PropertyGroup>
2757
+ <TargetFramework>net7.0</TargetFramework>
2758
+ </PropertyGroup>
2759
+ <ItemGroup>
2760
+ <PackageReference Include="Some.Package" Version="1.0.0" />
2761
+ <PackageReference Include="Transitive.Dependency" Version="1.0.0" />
2762
+ </ItemGroup>
2763
+ </Project>
2764
+ """
2765
+ );
2458
2766
  }
2459
2767
 
2460
2768
  [Fact]
2461
2769
  public async Task NoChange_IfTargetFrameworkCouldNotBeEvaluated()
2462
2770
  {
2463
2771
  // Make sure we don't throw if the project's TFM is an unresolvable property
2464
- await TestNoChangeforProject("Newtonsoft.Json", "7.0.1", "13.0.1",
2772
+ await TestNoChangeforProject("Some.Package", "7.0.1", "13.0.1",
2773
+ packages:
2774
+ [
2775
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net8.0"),
2776
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
2777
+ ],
2465
2778
  projectContents: """
2466
2779
  <Project Sdk="Microsoft.NET.Sdk">
2467
2780
  <PropertyGroup>
2468
2781
  <TargetFramework>$(PropertyThatCannotBeResolved)</TargetFramework>
2469
2782
  </PropertyGroup>
2470
2783
  <ItemGroup>
2471
- <PackageReference Include="Newtonsoft.Json" Version="7.0.1" />
2784
+ <PackageReference Include="Some.Package" Version="7.0.1" />
2472
2785
  </ItemGroup>
2473
2786
  </Project>
2474
2787
  """
2475
- );
2788
+ );
2476
2789
  }
2477
2790
 
2478
2791
  [Fact]
@@ -2480,7 +2793,12 @@ public partial class UpdateWorkerTests
2480
2793
  {
2481
2794
  // enumerating the build files will fail if the Aspire workload is not installed; this test ensures we can
2482
2795
  // still process the update
2483
- await TestUpdateForProject("Newtonsoft.Json", "7.0.1", "13.0.1",
2796
+ await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1",
2797
+ packages:
2798
+ [
2799
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net8.0"),
2800
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
2801
+ ],
2484
2802
  projectContents: """
2485
2803
  <Project Sdk="Microsoft.NET.Sdk">
2486
2804
  <PropertyGroup>
@@ -2488,7 +2806,7 @@ public partial class UpdateWorkerTests
2488
2806
  <IsAspireHost>true</IsAspireHost>
2489
2807
  </PropertyGroup>
2490
2808
  <ItemGroup>
2491
- <PackageReference Include="Newtonsoft.Json" Version="7.0.1" />
2809
+ <PackageReference Include="Some.Package" Version="7.0.1" />
2492
2810
  </ItemGroup>
2493
2811
  </Project>
2494
2812
  """,
@@ -2499,7 +2817,7 @@ public partial class UpdateWorkerTests
2499
2817
  <IsAspireHost>true</IsAspireHost>
2500
2818
  </PropertyGroup>
2501
2819
  <ItemGroup>
2502
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
2820
+ <PackageReference Include="Some.Package" Version="13.0.1" />
2503
2821
  </ItemGroup>
2504
2822
  </Project>
2505
2823
  """
@@ -2509,16 +2827,22 @@ public partial class UpdateWorkerTests
2509
2827
  [Fact]
2510
2828
  public async Task UnresolvablePropertyDoesNotStopOtherUpdates()
2511
2829
  {
2512
- // the property `$(MauiVersion)` cannot be resolved
2513
- await TestUpdateForProject("Newtonsoft.Json", "7.0.1", "13.0.1",
2830
+ // the property `$(SomeUnresolvableProperty)` cannot be resolved
2831
+ await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1",
2832
+ packages:
2833
+ [
2834
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net8.0"),
2835
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
2836
+ MockNuGetPackage.CreateSimplePackage("Some.Other.Package", "1.0.0", "net8.0"),
2837
+ ],
2514
2838
  projectContents: """
2515
2839
  <Project Sdk="Microsoft.NET.Sdk">
2516
2840
  <PropertyGroup>
2517
2841
  <TargetFramework>net8.0</TargetFramework>
2518
2842
  </PropertyGroup>
2519
2843
  <ItemGroup>
2520
- <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
2521
- <PackageReference Include="Newtonsoft.Json" Version="7.0.1" />
2844
+ <PackageReference Include="Some.Other.Package" Version="$(SomeUnresolvableProperty)" />
2845
+ <PackageReference Include="Some.Package" Version="7.0.1" />
2522
2846
  </ItemGroup>
2523
2847
  </Project>
2524
2848
  """,
@@ -2528,8 +2852,8 @@ public partial class UpdateWorkerTests
2528
2852
  <TargetFramework>net8.0</TargetFramework>
2529
2853
  </PropertyGroup>
2530
2854
  <ItemGroup>
2531
- <PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
2532
- <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
2855
+ <PackageReference Include="Some.Other.Package" Version="$(SomeUnresolvableProperty)" />
2856
+ <PackageReference Include="Some.Package" Version="13.0.1" />
2533
2857
  </ItemGroup>
2534
2858
  </Project>
2535
2859
  """
@@ -2539,31 +2863,40 @@ public partial class UpdateWorkerTests
2539
2863
  [Fact]
2540
2864
  public async Task UpdatingPackageAlsoUpdatesAnythingWithADependencyOnTheUpdatedPackage()
2541
2865
  {
2542
- // updating SpecFlow from 3.3.30 requires that SpecFlow.Tools.MsBuild.Generation also be updated
2543
- await TestUpdateForProject("SpecFlow", "3.3.30", "3.4.3",
2866
+ // updating Some.Package from 3.3.30 requires that Some.Package.Extensions also be updated
2867
+ await TestUpdateForProject("Some.Package", "3.3.30", "3.4.3",
2868
+ packages:
2869
+ [
2870
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "3.3.30", "net8.0"),
2871
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "3.4.0", "net8.0"), // this will be ignored
2872
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "3.4.3", "net8.0"),
2873
+ MockNuGetPackage.CreateSimplePackage("Some.Package.Extensions", "3.3.30", "net8.0", [(null, [("Some.Package", "[3.3.30]")])]), // the dependency version is very strict with []
2874
+ MockNuGetPackage.CreateSimplePackage("Some.Package.Extensions", "3.4.0", "net8.0", [(null, [("Some.Package", "[3.4.0]")])]), // this will be ignored
2875
+ MockNuGetPackage.CreateSimplePackage("Some.Package.Extensions", "3.4.3", "net8.0", [(null, [("Some.Package", "[3.4.3]")])]),
2876
+ ],
2544
2877
  projectContents: """
2545
2878
  <Project Sdk="Microsoft.NET.Sdk">
2546
2879
  <PropertyGroup>
2547
- <TargetFramework>netstandard2.0</TargetFramework>
2880
+ <TargetFramework>net8.0</TargetFramework>
2548
2881
  </PropertyGroup>
2549
2882
  <ItemGroup>
2550
- <PackageReference Include="SpecFlow" Version="3.3.30" />
2551
- <PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.3.30" />
2883
+ <PackageReference Include="Some.Package" Version="3.3.30" />
2884
+ <PackageReference Include="Some.Package.Extensions" Version="3.3.30" />
2552
2885
  </ItemGroup>
2553
2886
  </Project>
2554
2887
  """,
2555
2888
  expectedProjectContents: """
2556
2889
  <Project Sdk="Microsoft.NET.Sdk">
2557
2890
  <PropertyGroup>
2558
- <TargetFramework>netstandard2.0</TargetFramework>
2891
+ <TargetFramework>net8.0</TargetFramework>
2559
2892
  </PropertyGroup>
2560
2893
  <ItemGroup>
2561
- <PackageReference Include="SpecFlow" Version="3.4.3" />
2562
- <PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.4.3" />
2894
+ <PackageReference Include="Some.Package" Version="3.4.3" />
2895
+ <PackageReference Include="Some.Package.Extensions" Version="3.4.3" />
2563
2896
  </ItemGroup>
2564
2897
  </Project>
2565
2898
  """
2566
- );
2899
+ );
2567
2900
  }
2568
2901
  }
2569
2902
  }