dependabot-nuget 0.257.0 → 0.259.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/helpers/lib/NuGetUpdater/Directory.Packages.props +2 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +255 -191
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +63 -35
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +107 -14
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +9 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +18 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +6 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.DotNetToolsJson.cs +6 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +6 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +11 -21
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Proj.cs +95 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +204 -62
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +64 -45
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/MockNuGetPackage.cs +419 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/NuGetUpdater.Core.Test.csproj +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs +7 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +77 -19
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DirsProj.cs +120 -91
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +132 -97
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +93 -75
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +45 -42
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +1089 -956
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +1624 -1291
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +296 -293
- data/helpers/lib/NuGetUpdater/global.json +6 -0
- data/lib/dependabot/nuget/file_parser.rb +4 -5
- data/lib/dependabot/nuget/file_updater.rb +1 -1
- data/lib/dependabot/nuget/update_checker/dependency_finder.rb +7 -2
- data/lib/dependabot/nuget/update_checker/property_updater.rb +1 -0
- data/lib/dependabot/nuget/update_checker/version_finder.rb +2 -3
- data/lib/dependabot/nuget/update_checker.rb +1 -0
- metadata +8 -5
@@ -1,4 +1,5 @@
|
|
1
|
-
using System.
|
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
|
21
|
-
await TestUpdateForProject("
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
28
|
+
<PropertyGroup>
|
29
|
+
<TargetFramework>{tfm}</TargetFramework>
|
30
|
+
</PropertyGroup>
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
<ItemGroup>
|
33
|
+
<PackageReference Include="Some.Package" Version="9.0.1" />
|
34
|
+
</ItemGroup>
|
35
|
+
</Project>
|
36
|
+
""",
|
34
37
|
// expected
|
35
38
|
expectedProjectContents: $"""
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
40
|
+
<PropertyGroup>
|
41
|
+
<TargetFramework>{tfm}</TargetFramework>
|
42
|
+
</PropertyGroup>
|
40
43
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
52
|
-
await TestUpdateForProject("
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
85
|
-
await TestUpdateForProject("
|
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
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
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
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
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
|
120
|
-
await TestUpdateForProject("
|
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
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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>
|
159
|
+
<TargetFramework>net8.0</TargetFramework>
|
139
160
|
</PropertyGroup>
|
140
161
|
<ItemGroup>
|
141
|
-
<PackageReference Include="
|
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
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
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>
|
184
|
+
<TargetFramework>net8.0</TargetFramework>
|
164
185
|
</PropertyGroup>
|
165
186
|
<ItemGroup>
|
166
|
-
<PackageReference Include="
|
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
|
177
|
-
await TestUpdateForProject("
|
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
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
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
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
226
|
+
<ItemGroup>
|
227
|
+
<PackageReference Include="Some.Package" Version="9.0.1" />
|
228
|
+
</ItemGroup>
|
229
|
+
</Project>
|
230
|
+
""",
|
191
231
|
// expected
|
192
232
|
expectedProjectContents: $"""
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
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
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
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
|
210
|
-
await TestUpdateForProject("
|
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
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
259
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
260
|
+
<PropertyGroup>
|
261
|
+
<TargetFramework>net8.0</TargetFramework>
|
262
|
+
</PropertyGroup>
|
217
263
|
|
218
|
-
|
219
|
-
|
220
|
-
|
264
|
+
<ItemGroup>
|
265
|
+
<ProjectReference Include="lib\Library.csproj" />
|
266
|
+
</ItemGroup>
|
221
267
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
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="
|
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
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
289
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
290
|
+
<PropertyGroup>
|
291
|
+
<TargetFramework>net8.0</TargetFramework>
|
292
|
+
</PropertyGroup>
|
247
293
|
|
248
|
-
|
249
|
-
|
250
|
-
|
294
|
+
<ItemGroup>
|
295
|
+
<ProjectReference Include="lib\Library.csproj" />
|
296
|
+
</ItemGroup>
|
251
297
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
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="
|
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("$(
|
275
|
-
[InlineData("$
|
276
|
-
[InlineData("$
|
277
|
-
[InlineData("
|
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("
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
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
|
-
//
|
298
|
-
|
299
|
-
//
|
300
|
-
|
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="
|
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>
|
375
|
+
<TargetFramework>net8.0</TargetFramework>
|
325
376
|
</PropertyGroup>
|
326
377
|
<ItemGroup>
|
327
|
-
<PackageReference Include="
|
378
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
328
379
|
</ItemGroup>
|
329
380
|
</Project>
|
330
|
-
"""
|
331
|
-
|
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
|
-
(
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
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
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
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
|
383
|
-
await TestUpdateForProject("
|
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
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
464
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
465
|
+
<PropertyGroup>
|
466
|
+
<TargetFramework>net8.0</TargetFramework>
|
467
|
+
</PropertyGroup>
|
390
468
|
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
469
|
+
<ItemGroup>
|
470
|
+
<PackageReference Include="Some.Package" Version="[9.0.1]" />
|
471
|
+
</ItemGroup>
|
472
|
+
</Project>
|
473
|
+
""",
|
396
474
|
// expected
|
397
475
|
expectedProjectContents: """
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
476
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
477
|
+
<PropertyGroup>
|
478
|
+
<TargetFramework>net8.0</TargetFramework>
|
479
|
+
</PropertyGroup>
|
402
480
|
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
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
|
414
|
-
await TestUpdateForProject("
|
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
|
-
|
502
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
418
503
|
|
419
|
-
|
420
|
-
|
421
|
-
|
504
|
+
<PropertyGroup>
|
505
|
+
<TargetFramework>net8.0</TargetFramework>
|
506
|
+
</PropertyGroup>
|
422
507
|
|
423
|
-
|
424
|
-
|
425
|
-
|
508
|
+
<ItemGroup>
|
509
|
+
<PackageReference Include="Some.Package" Version="3.1.3" />
|
510
|
+
</ItemGroup>
|
426
511
|
|
427
|
-
|
428
|
-
|
512
|
+
</Project>
|
513
|
+
""",
|
429
514
|
// expected
|
430
515
|
expectedProjectContents: """
|
431
|
-
|
516
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
432
517
|
|
433
|
-
|
434
|
-
|
435
|
-
|
518
|
+
<PropertyGroup>
|
519
|
+
<TargetFramework>net8.0</TargetFramework>
|
520
|
+
</PropertyGroup>
|
436
521
|
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
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
|
-
|
443
|
-
|
527
|
+
</Project>
|
528
|
+
"""
|
529
|
+
);
|
444
530
|
}
|
445
531
|
|
446
532
|
[Fact]
|
447
533
|
public async Task UpdateVersionAttribute_InProjectFile_ForAnalyzerPackageReferenceInclude()
|
448
534
|
{
|
449
|
-
// update
|
450
|
-
await TestUpdateForProject("
|
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
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
544
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
545
|
+
<PropertyGroup>
|
546
|
+
<TargetFramework>net8.0</TargetFramework>
|
547
|
+
</PropertyGroup>
|
457
548
|
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
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
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
559
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
560
|
+
<PropertyGroup>
|
561
|
+
<TargetFramework>net8.0</TargetFramework>
|
562
|
+
</PropertyGroup>
|
472
563
|
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
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
|
487
|
-
await TestUpdateForProject("
|
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
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
587
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
588
|
+
<PropertyGroup>
|
589
|
+
<TargetFramework>net8.0</TargetFramework>
|
590
|
+
</PropertyGroup>
|
494
591
|
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
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
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
600
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
601
|
+
<PropertyGroup>
|
602
|
+
<TargetFramework>net8.0</TargetFramework>
|
603
|
+
</PropertyGroup>
|
507
604
|
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
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
|
520
|
-
await TestUpdateForProject("
|
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
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
626
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
627
|
+
<PropertyGroup>
|
628
|
+
<TargetFramework>net8.0</TargetFramework>
|
629
|
+
</PropertyGroup>
|
527
630
|
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
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
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
639
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
640
|
+
<PropertyGroup>
|
641
|
+
<TargetFramework>net8.0</TargetFramework>
|
642
|
+
</PropertyGroup>
|
540
643
|
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
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
|
553
|
-
await TestUpdateForProject("
|
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
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
665
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
666
|
+
<PropertyGroup>
|
667
|
+
<TargetFramework>net8.0</TargetFramework>
|
668
|
+
</PropertyGroup>
|
560
669
|
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
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="
|
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
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
692
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
693
|
+
<PropertyGroup>
|
694
|
+
<TargetFramework>net8.0</TargetFramework>
|
695
|
+
</PropertyGroup>
|
586
696
|
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
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="
|
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
|
612
|
-
await TestUpdateForProject("
|
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
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
731
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
732
|
+
<PropertyGroup>
|
733
|
+
<TargetFramework>net8.0</TargetFramework>
|
734
|
+
</PropertyGroup>
|
619
735
|
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
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="
|
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
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
758
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
759
|
+
<PropertyGroup>
|
760
|
+
<TargetFramework>net8.0</TargetFramework>
|
761
|
+
</PropertyGroup>
|
645
762
|
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
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="
|
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("
|
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
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
796
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
797
|
+
<PropertyGroup>
|
798
|
+
<TargetFramework>net8.0</TargetFramework>
|
799
|
+
<SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
|
800
|
+
</PropertyGroup>
|
678
801
|
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
802
|
+
<ItemGroup>
|
803
|
+
<PackageReference Include="Some.Package" Version="[$(SomePackagePackageVersion)]" />
|
804
|
+
</ItemGroup>
|
805
|
+
</Project>
|
806
|
+
""",
|
684
807
|
// expected
|
685
808
|
expectedProjectContents: """
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
809
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
810
|
+
<PropertyGroup>
|
811
|
+
<TargetFramework>net8.0</TargetFramework>
|
812
|
+
<SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
|
813
|
+
</PropertyGroup>
|
691
814
|
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
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("
|
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
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
834
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
835
|
+
<PropertyGroup>
|
836
|
+
<TargetFramework>net8.0</TargetFramework>
|
837
|
+
<SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
|
838
|
+
</PropertyGroup>
|
710
839
|
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
840
|
+
<ItemGroup>
|
841
|
+
<PackageReference Include="Some.Package" Version="$(somepackagepackageversion)" />
|
842
|
+
</ItemGroup>
|
843
|
+
</Project>
|
844
|
+
""",
|
716
845
|
// expected
|
717
846
|
expectedProjectContents: """
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
847
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
848
|
+
<PropertyGroup>
|
849
|
+
<TargetFramework>net8.0</TargetFramework>
|
850
|
+
<SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
|
851
|
+
</PropertyGroup>
|
723
852
|
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
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("
|
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
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
872
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
873
|
+
<PropertyGroup>
|
874
|
+
<TargetFramework>net8.0</TargetFramework>
|
875
|
+
<SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
|
876
|
+
</PropertyGroup>
|
742
877
|
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
878
|
+
<ItemGroup>
|
879
|
+
<PackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
|
880
|
+
</ItemGroup>
|
881
|
+
</Project>
|
882
|
+
""",
|
748
883
|
// expected
|
749
884
|
expectedProjectContents: """
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
885
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
886
|
+
<PropertyGroup>
|
887
|
+
<TargetFramework>net8.0</TargetFramework>
|
888
|
+
<SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
|
889
|
+
</PropertyGroup>
|
755
890
|
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
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("
|
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
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
910
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
911
|
+
<PropertyGroup>
|
912
|
+
<TargetFramework>net8.0</TargetFramework>
|
913
|
+
<SomePackagePackageVersion>[9.0.1]</SomePackagePackageVersion>
|
914
|
+
</PropertyGroup>
|
774
915
|
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
916
|
+
<ItemGroup>
|
917
|
+
<PackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
|
918
|
+
</ItemGroup>
|
919
|
+
</Project>
|
920
|
+
""",
|
780
921
|
// expected
|
781
922
|
expectedProjectContents: """
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
923
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
924
|
+
<PropertyGroup>
|
925
|
+
<TargetFramework>net8.0</TargetFramework>
|
926
|
+
<SomePackagePackageVersion>[13.0.1]</SomePackagePackageVersion>
|
927
|
+
</PropertyGroup>
|
787
928
|
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
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("
|
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
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
948
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
949
|
+
<PropertyGroup>
|
950
|
+
<TargetFramework>net8.0</TargetFramework>
|
951
|
+
<SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
|
952
|
+
</PropertyGroup>
|
806
953
|
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
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
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
962
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
963
|
+
<PropertyGroup>
|
964
|
+
<TargetFramework>net8.0</TargetFramework>
|
965
|
+
<SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
|
966
|
+
</PropertyGroup>
|
820
967
|
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
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("
|
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
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
988
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
989
|
+
<PropertyGroup>
|
990
|
+
<TargetFramework>net8.0</TargetFramework>
|
991
|
+
<SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
|
992
|
+
</PropertyGroup>
|
840
993
|
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
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
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
1002
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1003
|
+
<PropertyGroup>
|
1004
|
+
<TargetFramework>net8.0</TargetFramework>
|
1005
|
+
<SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
|
1006
|
+
</PropertyGroup>
|
854
1007
|
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
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
|
867
|
-
await TestUpdateForProject("
|
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
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
1029
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1030
|
+
<PropertyGroup>
|
1031
|
+
<TargetFramework>net8.0</TargetFramework>
|
1032
|
+
</PropertyGroup>
|
874
1033
|
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
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
|
-
<
|
1046
|
+
<SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
|
887
1047
|
</PropertyGroup>
|
888
1048
|
|
889
1049
|
<ItemGroup>
|
890
|
-
<PackageVersion Include="
|
1050
|
+
<PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
|
891
1051
|
</ItemGroup>
|
892
1052
|
</Project>
|
893
1053
|
""")
|
894
1054
|
],
|
895
1055
|
// expected
|
896
1056
|
expectedProjectContents: """
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
1057
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1058
|
+
<PropertyGroup>
|
1059
|
+
<TargetFramework>net8.0</TargetFramework>
|
1060
|
+
</PropertyGroup>
|
901
1061
|
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
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
|
-
<
|
1073
|
+
<SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
|
914
1074
|
</PropertyGroup>
|
915
1075
|
|
916
1076
|
<ItemGroup>
|
917
|
-
<PackageVersion Include="
|
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
|
928
|
-
await TestUpdateForProject("
|
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
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
1097
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1098
|
+
<PropertyGroup>
|
1099
|
+
<TargetFramework>net8.0</TargetFramework>
|
1100
|
+
</PropertyGroup>
|
935
1101
|
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
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
|
-
<
|
1114
|
+
<SomePackagePackageVersion>[9.0.1]</SomePackagePackageVersion>
|
948
1115
|
</PropertyGroup>
|
949
1116
|
|
950
1117
|
<ItemGroup>
|
951
|
-
<PackageVersion Include="
|
1118
|
+
<PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
|
952
1119
|
</ItemGroup>
|
953
1120
|
</Project>
|
954
1121
|
""")
|
955
1122
|
],
|
956
1123
|
// expected
|
957
1124
|
expectedProjectContents: """
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
1125
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1126
|
+
<PropertyGroup>
|
1127
|
+
<TargetFramework>net8.0</TargetFramework>
|
1128
|
+
</PropertyGroup>
|
962
1129
|
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
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
|
-
<
|
1141
|
+
<SomePackagePackageVersion>[13.0.1]</SomePackagePackageVersion>
|
975
1142
|
</PropertyGroup>
|
976
1143
|
|
977
1144
|
<ItemGroup>
|
978
|
-
<PackageVersion Include="
|
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
|
989
|
-
await TestUpdateForProject("
|
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
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
1165
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1166
|
+
<PropertyGroup>
|
1167
|
+
<TargetFramework>net8.0</TargetFramework>
|
1168
|
+
</PropertyGroup>
|
996
1169
|
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
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
|
-
<
|
1182
|
+
<SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
|
1009
1183
|
</PropertyGroup>
|
1010
1184
|
|
1011
1185
|
<ItemGroup>
|
1012
|
-
<PackageVersion Include="
|
1186
|
+
<PackageVersion Include="Some.Package" Version="$(SomePackagePackageVersion)" />
|
1013
1187
|
</ItemGroup>
|
1014
1188
|
</Project>
|
1015
1189
|
""")
|
1016
1190
|
],
|
1017
1191
|
// expected
|
1018
1192
|
expectedProjectContents: """
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1193
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1194
|
+
<PropertyGroup>
|
1195
|
+
<TargetFramework>net8.0</TargetFramework>
|
1196
|
+
</PropertyGroup>
|
1023
1197
|
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
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
|
-
<
|
1209
|
+
<SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
|
1036
1210
|
</PropertyGroup>
|
1037
1211
|
|
1038
1212
|
<ItemGroup>
|
1039
|
-
<PackageVersion Include="
|
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
|
1050
|
-
await TestUpdateForProject("
|
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
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
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="
|
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
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
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="
|
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
|
1101
|
-
await TestUpdateForProject("
|
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
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
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
|
-
<
|
1304
|
+
<SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
|
1117
1305
|
</PropertyGroup>
|
1118
1306
|
|
1119
1307
|
<ItemGroup>
|
1120
|
-
<GlobalPackageReference Include="
|
1308
|
+
<GlobalPackageReference Include="Some.Package" Version="$(SomePackagePackageVersion)" />
|
1121
1309
|
</ItemGroup>
|
1122
1310
|
</Project>
|
1123
1311
|
""")
|
1124
1312
|
],
|
1125
1313
|
// expected
|
1126
1314
|
expectedProjectContents: """
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
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
|
-
<
|
1327
|
+
<SomePackagePackageVersion>13.0.1</SomePackagePackageVersion>
|
1140
1328
|
</PropertyGroup>
|
1141
1329
|
|
1142
1330
|
<ItemGroup>
|
1143
|
-
<GlobalPackageReference Include="
|
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("
|
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
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1350
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1351
|
+
<PropertyGroup>
|
1352
|
+
<TargetFramework>net8.0</TargetFramework>
|
1353
|
+
</PropertyGroup>
|
1160
1354
|
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
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
|
-
<
|
1366
|
+
<SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
|
1173
1367
|
</PropertyGroup>
|
1174
1368
|
</Project>
|
1175
1369
|
""")
|
1176
1370
|
],
|
1177
1371
|
// expected project
|
1178
1372
|
expectedProjectContents: """
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1373
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1374
|
+
<PropertyGroup>
|
1375
|
+
<TargetFramework>net8.0</TargetFramework>
|
1376
|
+
</PropertyGroup>
|
1183
1377
|
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
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
|
-
<
|
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("
|
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
|
-
|
1209
|
-
|
1408
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1409
|
+
<Import Project="my-properties.props" />
|
1210
1410
|
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1411
|
+
<PropertyGroup>
|
1412
|
+
<TargetFramework>net8.0</TargetFramework>
|
1413
|
+
</PropertyGroup>
|
1214
1414
|
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
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
|
-
<
|
1426
|
+
<SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
|
1227
1427
|
</PropertyGroup>
|
1228
1428
|
</Project>
|
1229
1429
|
""")
|
1230
1430
|
],
|
1231
1431
|
// expected project
|
1232
1432
|
expectedProjectContents: """
|
1233
|
-
|
1234
|
-
|
1433
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1434
|
+
<Import Project="my-properties.props" />
|
1235
1435
|
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1436
|
+
<PropertyGroup>
|
1437
|
+
<TargetFramework>net8.0</TargetFramework>
|
1438
|
+
</PropertyGroup>
|
1239
1439
|
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
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
|
-
<
|
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
|
1262
|
-
await TestUpdateForProject("
|
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
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1471
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1472
|
+
<PropertyGroup>
|
1473
|
+
<TargetFramework>net8.0</TargetFramework>
|
1474
|
+
</PropertyGroup>
|
1269
1475
|
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
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="
|
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
|
-
<
|
1500
|
+
<SomePackagePackageVersion>9.0.1</SomePackagePackageVersion>
|
1294
1501
|
</PropertyGroup>
|
1295
1502
|
</Project>
|
1296
1503
|
""")
|
1297
1504
|
],
|
1298
1505
|
// expected
|
1299
1506
|
expectedProjectContents: """
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1507
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1508
|
+
<PropertyGroup>
|
1509
|
+
<TargetFramework>net8.0</TargetFramework>
|
1510
|
+
</PropertyGroup>
|
1304
1511
|
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
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="
|
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
|
-
<
|
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
|
1339
|
-
await TestUpdateForProject("
|
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
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1555
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1556
|
+
<PropertyGroup>
|
1557
|
+
<TargetFramework>net8.0</TargetFramework>
|
1558
|
+
</PropertyGroup>
|
1346
1559
|
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
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
|
-
<
|
1574
|
+
<SomePackagePackageVersion>$(NewtonsoftJsonVersion)</SomePackagePackageVersion>
|
1361
1575
|
</PropertyGroup>
|
1362
1576
|
|
1363
1577
|
<ItemGroup>
|
1364
|
-
<PackageVersion Include="
|
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
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1592
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1593
|
+
<PropertyGroup>
|
1594
|
+
<TargetFramework>net8.0</TargetFramework>
|
1595
|
+
</PropertyGroup>
|
1382
1596
|
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
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
|
-
<
|
1610
|
+
<SomePackagePackageVersion>$(NewtonsoftJsonVersion)</SomePackagePackageVersion>
|
1397
1611
|
</PropertyGroup>
|
1398
1612
|
|
1399
1613
|
<ItemGroup>
|
1400
|
-
<PackageVersion Include="
|
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
|
1418
|
-
await TestUpdateForProject("
|
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
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1641
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1642
|
+
<PropertyGroup>
|
1643
|
+
<TargetFramework>net8.0</TargetFramework>
|
1644
|
+
</PropertyGroup>
|
1425
1645
|
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
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
|
-
<
|
1660
|
+
<SomePackagePackageVersion>$(SomePackageVersion)</SomePackagePackageVersion>
|
1440
1661
|
</PropertyGroup>
|
1441
1662
|
|
1442
1663
|
<ItemGroup>
|
1443
|
-
<PackageVersion Include="
|
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
|
-
<
|
1451
|
-
<
|
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
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1679
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1680
|
+
<PropertyGroup>
|
1681
|
+
<TargetFramework>net8.0</TargetFramework>
|
1682
|
+
</PropertyGroup>
|
1462
1683
|
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
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
|
-
<
|
1697
|
+
<SomePackagePackageVersion>$(SomePackageVersion)</SomePackagePackageVersion>
|
1477
1698
|
</PropertyGroup>
|
1478
1699
|
|
1479
1700
|
<ItemGroup>
|
1480
|
-
<PackageVersion Include="
|
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
|
-
<
|
1488
|
-
<
|
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("
|
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
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
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
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
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("
|
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
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
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
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
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("
|
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
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
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
|
-
<
|
1577
|
-
<
|
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
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
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
|
-
<
|
1600
|
-
<
|
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("
|
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
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
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
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
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("
|
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
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
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="
|
1662
|
-
<PackageVersion Include="
|
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
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
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="
|
1692
|
-
<PackageVersion Include="
|
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
|
-
|
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
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
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
|
-
//
|
1731
|
-
await
|
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
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
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
|
1758
|
-
await TestUpdateForProject("
|
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
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
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
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
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
|
1787
|
-
await
|
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
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
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
|
-
|
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
|
-
|
2080
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1816
2081
|
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
2082
|
+
<PropertyGroup>
|
2083
|
+
<TargetFramework>$(PreferredTargetFramework)</TargetFramework>
|
2084
|
+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
2085
|
+
<RootNamespace />
|
2086
|
+
</PropertyGroup>
|
1822
2087
|
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
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
|
-
|
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="
|
1844
|
-
<PackageVersion Include="
|
1845
|
-
<PackageVersion Include="
|
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>
|
2114
|
+
<PreferredTargetFramework>net8.0</PreferredTargetFramework>
|
1858
2115
|
</PropertyGroup>
|
1859
2116
|
</Project>
|
1860
2117
|
""")
|
1861
2118
|
],
|
1862
2119
|
expectedProjectContents: """
|
1863
|
-
|
2120
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1864
2121
|
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
2122
|
+
<PropertyGroup>
|
2123
|
+
<TargetFramework>$(PreferredTargetFramework)</TargetFramework>
|
2124
|
+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
2125
|
+
<RootNamespace />
|
2126
|
+
</PropertyGroup>
|
1870
2127
|
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
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
|
-
|
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="
|
1892
|
-
<PackageVersion Include="
|
1893
|
-
<PackageVersion Include="
|
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>
|
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("
|
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
|
-
|
2174
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1919
2175
|
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
2176
|
+
<PropertyGroup>
|
2177
|
+
<TargetFramework>net8.0</TargetFramework>
|
2178
|
+
</PropertyGroup>
|
1923
2179
|
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
2180
|
+
<ItemGroup>
|
2181
|
+
<PackageReference Include="Some.Package" />
|
2182
|
+
</ItemGroup>
|
1927
2183
|
|
1928
|
-
|
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="
|
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
|
-
|
2203
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1947
2204
|
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
2205
|
+
<PropertyGroup>
|
2206
|
+
<TargetFramework>net8.0</TargetFramework>
|
2207
|
+
</PropertyGroup>
|
1951
2208
|
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
2209
|
+
<ItemGroup>
|
2210
|
+
<PackageReference Include="Some.Package" />
|
2211
|
+
<PackageReference Include="Some.Transitive.Dependency" />
|
2212
|
+
</ItemGroup>
|
1956
2213
|
|
1957
|
-
|
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="
|
1969
|
-
<PackageVersion Include="
|
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("
|
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
|
-
|
2246
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
1983
2247
|
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
2248
|
+
<PropertyGroup>
|
2249
|
+
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
|
2250
|
+
<TargetFramework>net8.0</TargetFramework>
|
2251
|
+
</PropertyGroup>
|
1988
2252
|
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
2253
|
+
<ItemGroup>
|
2254
|
+
<PackageReference Include="Some.Package" />
|
2255
|
+
</ItemGroup>
|
1992
2256
|
|
1993
|
-
|
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="
|
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
|
-
|
2277
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
2013
2278
|
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2279
|
+
<PropertyGroup>
|
2280
|
+
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
|
2281
|
+
<TargetFramework>net8.0</TargetFramework>
|
2282
|
+
</PropertyGroup>
|
2018
2283
|
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2284
|
+
<ItemGroup>
|
2285
|
+
<PackageReference Include="Some.Package" />
|
2286
|
+
</ItemGroup>
|
2022
2287
|
|
2023
|
-
|
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="
|
2036
|
-
<PackageVersion Include="
|
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("
|
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
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
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
|
-
<
|
2339
|
+
<SomePackageVersion>12.0.1</SomePackageVersion>
|
2069
2340
|
</PropertyGroup>
|
2070
2341
|
</Project>
|
2071
2342
|
""")
|
2072
2343
|
],
|
2073
2344
|
// no change
|
2074
2345
|
expectedProjectContents: """
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
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
|
-
<
|
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("
|
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
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
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
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
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("
|
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
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
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
|
-
<
|
2438
|
+
<SomePackageVersion>12.0.1</SomePackageVersion>
|
2158
2439
|
</PropertyGroup>
|
2159
2440
|
</Project>
|
2160
2441
|
""")
|
2161
2442
|
],
|
2162
2443
|
// no change
|
2163
2444
|
expectedProjectContents: """
|
2164
|
-
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
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
|
-
<
|
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("
|
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
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
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="
|
2218
|
-
<PackageVersion Include="
|
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
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
2231
|
-
|
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="
|
2243
|
-
<PackageVersion Include="
|
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("
|
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
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2264
|
-
|
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="
|
2276
|
-
<PackageVersion Include="
|
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
|
-
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
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="
|
2301
|
-
<PackageVersion Include="
|
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("
|
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
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
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
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2329
|
-
|
2330
|
-
|
2331
|
-
|
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("
|
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
|
-
|
2342
|
-
|
2343
|
-
|
2344
|
-
|
2345
|
-
|
2346
|
-
|
2347
|
-
|
2348
|
-
|
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
|
-
|
2352
|
-
|
2353
|
-
|
2354
|
-
|
2355
|
-
|
2356
|
-
|
2357
|
-
|
2358
|
-
|
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("
|
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
|
-
|
2369
|
-
|
2370
|
-
|
2371
|
-
|
2372
|
-
|
2373
|
-
|
2374
|
-
|
2375
|
-
|
2376
|
-
|
2377
|
-
|
2378
|
-
|
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
|
-
|
2382
|
-
|
2383
|
-
|
2384
|
-
|
2385
|
-
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
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("
|
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
|
-
|
2402
|
-
|
2403
|
-
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2407
|
-
|
2408
|
-
|
2409
|
-
|
2410
|
-
|
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
|
-
|
2414
|
-
|
2415
|
-
|
2416
|
-
|
2417
|
-
|
2418
|
-
|
2419
|
-
|
2420
|
-
|
2421
|
-
|
2422
|
-
|
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
|
-
//
|
2431
|
-
|
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
|
-
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
|
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("
|
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="
|
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("
|
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="
|
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="
|
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 `$(
|
2513
|
-
await TestUpdateForProject("
|
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="
|
2521
|
-
<PackageReference Include="
|
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="
|
2532
|
-
<PackageReference Include="
|
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
|
2543
|
-
await TestUpdateForProject("
|
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>
|
2880
|
+
<TargetFramework>net8.0</TargetFramework>
|
2548
2881
|
</PropertyGroup>
|
2549
2882
|
<ItemGroup>
|
2550
|
-
<PackageReference Include="
|
2551
|
-
<PackageReference Include="
|
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>
|
2891
|
+
<TargetFramework>net8.0</TargetFramework>
|
2559
2892
|
</PropertyGroup>
|
2560
2893
|
<ItemGroup>
|
2561
|
-
<PackageReference Include="
|
2562
|
-
<PackageReference Include="
|
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
|
}
|