dependabot-nuget 0.242.1 → 0.244.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/.editorconfig +37 -28
- data/helpers/lib/NuGetUpdater/.gitignore +1 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.CommandLine/AssemblyMetadataExtractor.cs +2 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +178 -176
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +2 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/PackagesConfigBuildFile.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/ProjectBuildFile.cs +5 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/FrameworkCompatibilityService.cs +10 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/SupportedFrameworks.cs +16 -12
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +18 -17
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectResolver.cs +7 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +13 -20
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +9 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +32 -16
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs +44 -24
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +32 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/WebApplicationTargetsConditionPatcher.cs +47 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/XmlFilePreAndPostProcessor.cs +55 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs +12 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +78 -54
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +16 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProcessExtensions.cs +6 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/XmlExtensions.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/ProjectBuildFileTests.cs +18 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/CompatibilityCheckerFacts.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/FrameworkCompatibilityServiceFacts.cs +7 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/SupportedFrameworkFacts.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +9 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorker.DirsProj.cs +228 -75
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +22 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +140 -104
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +25 -25
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +8 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +198 -22
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +401 -399
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/JsonHelperTests.cs +17 -15
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +114 -45
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterTests.cs +103 -87
- data/lib/dependabot/nuget/file_parser/project_file_parser.rb +109 -39
- data/lib/dependabot/nuget/file_parser.rb +23 -4
- data/lib/dependabot/nuget/file_updater.rb +44 -7
- data/lib/dependabot/nuget/native_helpers.rb +27 -8
- data/lib/dependabot/nuget/nuget_client.rb +66 -23
- data/lib/dependabot/nuget/nuget_config_credential_helpers.rb +7 -3
- data/lib/dependabot/nuget/update_checker/compatibility_checker.rb +63 -59
- data/lib/dependabot/nuget/update_checker/dependency_finder.rb +7 -5
- data/lib/dependabot/nuget/update_checker/nupkg_fetcher.rb +1 -1
- data/lib/dependabot/nuget/update_checker/nuspec_fetcher.rb +22 -17
- data/lib/dependabot/nuget/update_checker/property_updater.rb +7 -4
- data/lib/dependabot/nuget/update_checker/repository_finder.rb +292 -270
- data/lib/dependabot/nuget/update_checker/tfm_comparer.rb +11 -13
- data/lib/dependabot/nuget/update_checker/tfm_finder.rb +82 -82
- data/lib/dependabot/nuget/update_checker/version_finder.rb +9 -5
- data/lib/dependabot/nuget/update_checker.rb +6 -3
- data/lib/dependabot/nuget/version.rb +18 -7
- data/lib/dependabot/nuget.rb +0 -2
- metadata +7 -5
@@ -133,17 +133,26 @@ public class ProjectBuildFileTests
|
|
133
133
|
}
|
134
134
|
|
135
135
|
[Theory]
|
136
|
-
|
137
|
-
|
138
|
-
|
136
|
+
// no change made
|
137
|
+
[InlineData(
|
138
|
+
// language=csproj
|
139
|
+
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>",
|
140
|
+
// language=csproj
|
141
|
+
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>"
|
139
142
|
)]
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
+
// change from `/` to `\`
|
144
|
+
[InlineData(
|
145
|
+
// language=csproj
|
146
|
+
"<Project><ItemGroup><Reference><HintPath>path/to/file.dll</HintPath></Reference></ItemGroup></Project>",
|
147
|
+
// language=csproj
|
148
|
+
@"<Project><ItemGroup><Reference><HintPath>path\to\file.dll</HintPath></Reference></ItemGroup></Project>"
|
143
149
|
)]
|
144
|
-
|
145
|
-
|
146
|
-
|
150
|
+
// multiple changes made
|
151
|
+
[InlineData(
|
152
|
+
// language=csproj
|
153
|
+
"<Project><ItemGroup><Reference><HintPath>path1/to1/file1.dll</HintPath></Reference><Reference><HintPath>path2/to2/file2.dll</HintPath></Reference></ItemGroup></Project>",
|
154
|
+
// language=csproj
|
155
|
+
@"<Project><ItemGroup><Reference><HintPath>path1\to1\file1.dll</HintPath></Reference><Reference><HintPath>path2\to2\file2.dll</HintPath></Reference></ItemGroup></Project>"
|
147
156
|
)]
|
148
157
|
public void ReferenceHintPathsCanBeNormalized(string originalXml, string expectedXml)
|
149
158
|
{
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/CompatibilityCheckerFacts.cs
CHANGED
@@ -20,7 +20,7 @@ public class CompatibilityCheckerFacts
|
|
20
20
|
[InlineData("net4.8", "netstandard1.3")]
|
21
21
|
public void PackageContainsCompatibleFramework(string projectTfm, string packageTfm)
|
22
22
|
{
|
23
|
-
var result = CompatibilityChecker.IsCompatible(
|
23
|
+
var result = CompatibilityChecker.IsCompatible([projectTfm], [packageTfm], new Logger(verbose: true));
|
24
24
|
|
25
25
|
Assert.True(result);
|
26
26
|
}
|
@@ -37,7 +37,7 @@ public class CompatibilityCheckerFacts
|
|
37
37
|
[InlineData("net7.0", "net48")]
|
38
38
|
public void PackageContainsIncompatibleFramework(string projectTfm, string packageTfm)
|
39
39
|
{
|
40
|
-
var result = CompatibilityChecker.IsCompatible(
|
40
|
+
var result = CompatibilityChecker.IsCompatible([projectTfm], [packageTfm], new Logger(verbose: true));
|
41
41
|
|
42
42
|
Assert.False(result);
|
43
43
|
}
|
@@ -41,11 +41,11 @@ public class FrameworkCompatibilityServiceFacts
|
|
41
41
|
public void UnknownSupportedPackageReturnsSetWithSameFramework()
|
42
42
|
{
|
43
43
|
var framework = NuGetFramework.Parse("net45-client");
|
44
|
-
var frameworks = new List<NuGetFramework>
|
44
|
+
var frameworks = new List<NuGetFramework> { framework };
|
45
45
|
var compatible = _service.GetCompatibleFrameworks(frameworks);
|
46
46
|
|
47
47
|
Assert.False(framework.IsUnsupported);
|
48
|
-
Assert.
|
48
|
+
Assert.Single(compatible);
|
49
49
|
Assert.Contains(framework, compatible);
|
50
50
|
}
|
51
51
|
|
@@ -57,10 +57,10 @@ public class FrameworkCompatibilityServiceFacts
|
|
57
57
|
{
|
58
58
|
var unsupportedFramework = NuGetFramework.Parse(unsupportedFrameworkName);
|
59
59
|
|
60
|
-
var result = _service.GetCompatibleFrameworks(
|
60
|
+
var result = _service.GetCompatibleFrameworks([unsupportedFramework]);
|
61
61
|
|
62
62
|
Assert.True(unsupportedFramework.IsUnsupported);
|
63
|
-
Assert.
|
63
|
+
Assert.Empty(result);
|
64
64
|
}
|
65
65
|
|
66
66
|
[Theory]
|
@@ -71,10 +71,10 @@ public class FrameworkCompatibilityServiceFacts
|
|
71
71
|
{
|
72
72
|
var portableFramework = NuGetFramework.Parse(pclFrameworkName);
|
73
73
|
|
74
|
-
var result = _service.GetCompatibleFrameworks(
|
74
|
+
var result = _service.GetCompatibleFrameworks([portableFramework]);
|
75
75
|
|
76
76
|
Assert.True(portableFramework.IsPCL);
|
77
|
-
Assert.
|
77
|
+
Assert.Empty(result);
|
78
78
|
}
|
79
79
|
|
80
80
|
[Theory]
|
@@ -113,7 +113,7 @@ public class FrameworkCompatibilityServiceFacts
|
|
113
113
|
projectFrameworks.Add(NuGetFramework.Parse(frameworkName));
|
114
114
|
}
|
115
115
|
|
116
|
-
var compatibleFrameworks = _service.GetCompatibleFrameworks(
|
116
|
+
var compatibleFrameworks = _service.GetCompatibleFrameworks([packageFramework]);
|
117
117
|
Assert.Equal(windowsProjectFrameworks.Length, compatibleFrameworks.Count);
|
118
118
|
|
119
119
|
var containsAllCompatibleFrameworks = compatibleFrameworks.All(cf => projectFrameworks.Contains(cf));
|
@@ -23,8 +23,8 @@ public class PackagesConfigUpdaterTests
|
|
23
23
|
public static IEnumerable<object[]> PackagesDirectoryPathTestData()
|
24
24
|
{
|
25
25
|
// project with namespace
|
26
|
-
yield return
|
27
|
-
|
26
|
+
yield return
|
27
|
+
[
|
28
28
|
"""
|
29
29
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
30
30
|
<ItemGroup>
|
@@ -38,11 +38,11 @@ public class PackagesConfigUpdaterTests
|
|
38
38
|
"Newtonsoft.Json",
|
39
39
|
"7.0.1",
|
40
40
|
@"..\packages"
|
41
|
-
|
41
|
+
];
|
42
42
|
|
43
43
|
// project without namespace
|
44
|
-
yield return
|
45
|
-
|
44
|
+
yield return
|
45
|
+
[
|
46
46
|
"""
|
47
47
|
<Project>
|
48
48
|
<ItemGroup>
|
@@ -56,11 +56,11 @@ public class PackagesConfigUpdaterTests
|
|
56
56
|
"Newtonsoft.Json",
|
57
57
|
"7.0.1",
|
58
58
|
@"..\packages"
|
59
|
-
|
59
|
+
];
|
60
60
|
|
61
61
|
// project with non-standard packages path
|
62
|
-
yield return
|
63
|
-
|
62
|
+
yield return
|
63
|
+
[
|
64
64
|
"""
|
65
65
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
66
66
|
<ItemGroup>
|
@@ -74,6 +74,6 @@ public class PackagesConfigUpdaterTests
|
|
74
74
|
"Newtonsoft.Json",
|
75
75
|
"7.0.1",
|
76
76
|
@"..\not-a-path-you-would-expect"
|
77
|
-
|
77
|
+
];
|
78
78
|
}
|
79
79
|
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
using System;
|
2
|
+
using System.Collections.Generic;
|
2
3
|
using System.IO;
|
3
4
|
using System.Linq;
|
4
5
|
using System.Threading.Tasks;
|
@@ -23,53 +24,53 @@ public partial class UpdateWorkerTests
|
|
23
24
|
// initial
|
24
25
|
projectContents: """
|
25
26
|
<Project Sdk="Microsoft.Build.NoTargets">
|
26
|
-
|
27
|
+
|
27
28
|
<ItemGroup>
|
28
29
|
<ProjectReference Include="src/test-project.csproj" />
|
29
30
|
</ItemGroup>
|
30
31
|
|
31
32
|
</Project>
|
32
33
|
""",
|
33
|
-
additionalFiles:
|
34
|
-
|
34
|
+
additionalFiles:
|
35
|
+
[
|
35
36
|
("src/test-project.csproj",
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
"""
|
38
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
39
|
+
<PropertyGroup>
|
40
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
41
|
+
</PropertyGroup>
|
42
|
+
|
43
|
+
<ItemGroup>
|
44
|
+
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
|
45
|
+
</ItemGroup>
|
46
|
+
</Project>
|
47
|
+
""")
|
48
|
+
],
|
48
49
|
// expected
|
49
50
|
expectedProjectContents: """
|
50
51
|
<Project Sdk="Microsoft.Build.NoTargets">
|
51
|
-
|
52
|
+
|
52
53
|
<ItemGroup>
|
53
54
|
<ProjectReference Include="src/test-project.csproj" />
|
54
55
|
</ItemGroup>
|
55
56
|
|
56
57
|
</Project>
|
57
58
|
""",
|
58
|
-
additionalFilesExpected:
|
59
|
-
|
59
|
+
additionalFilesExpected:
|
60
|
+
[
|
60
61
|
("src/test-project.csproj",
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
62
|
+
"""
|
63
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
64
|
+
<PropertyGroup>
|
65
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
66
|
+
</PropertyGroup>
|
67
|
+
|
68
|
+
<ItemGroup>
|
69
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
70
|
+
</ItemGroup>
|
71
|
+
</Project>
|
72
|
+
""")
|
73
|
+
]);
|
73
74
|
}
|
74
75
|
|
75
76
|
[Fact]
|
@@ -100,73 +101,225 @@ public partial class UpdateWorkerTests
|
|
100
101
|
// initial
|
101
102
|
projectContents: """
|
102
103
|
<Project Sdk="Microsoft.Build.NoTargets">
|
104
|
+
|
105
|
+
<ItemGroup>
|
106
|
+
<ProjectReference Include="src/dirs.proj" />
|
107
|
+
</ItemGroup>
|
108
|
+
|
109
|
+
</Project>
|
110
|
+
""",
|
111
|
+
additionalFiles:
|
112
|
+
[
|
113
|
+
("src/dirs.proj",
|
114
|
+
"""
|
115
|
+
<Project Sdk="Microsoft.Build.NoTargets">
|
116
|
+
|
117
|
+
<ItemGroup>
|
118
|
+
<ProjectReference Include="test-project/test-project.csproj" />
|
119
|
+
</ItemGroup>
|
103
120
|
|
121
|
+
</Project>
|
122
|
+
"""),
|
123
|
+
("src/test-project/test-project.csproj",
|
124
|
+
"""
|
125
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
126
|
+
<PropertyGroup>
|
127
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
128
|
+
</PropertyGroup>
|
129
|
+
|
130
|
+
<ItemGroup>
|
131
|
+
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
|
132
|
+
</ItemGroup>
|
133
|
+
</Project>
|
134
|
+
""")
|
135
|
+
],
|
136
|
+
// expected
|
137
|
+
expectedProjectContents: """
|
138
|
+
<Project Sdk="Microsoft.Build.NoTargets">
|
139
|
+
|
104
140
|
<ItemGroup>
|
105
141
|
<ProjectReference Include="src/dirs.proj" />
|
106
142
|
</ItemGroup>
|
107
143
|
|
108
144
|
</Project>
|
109
145
|
""",
|
110
|
-
|
111
|
-
|
146
|
+
additionalFilesExpected:
|
147
|
+
[
|
112
148
|
("src/dirs.proj",
|
113
|
-
|
114
|
-
|
149
|
+
"""
|
150
|
+
<Project Sdk="Microsoft.Build.NoTargets">
|
151
|
+
|
152
|
+
<ItemGroup>
|
153
|
+
<ProjectReference Include="test-project/test-project.csproj" />
|
154
|
+
</ItemGroup>
|
115
155
|
|
116
|
-
|
117
|
-
|
118
|
-
|
156
|
+
</Project>
|
157
|
+
"""),
|
158
|
+
("src/test-project/test-project.csproj",
|
159
|
+
"""
|
160
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
161
|
+
<PropertyGroup>
|
162
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
163
|
+
</PropertyGroup>
|
164
|
+
|
165
|
+
<ItemGroup>
|
166
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
167
|
+
</ItemGroup>
|
168
|
+
</Project>
|
169
|
+
""")
|
170
|
+
]);
|
171
|
+
}
|
172
|
+
|
173
|
+
[Fact]
|
174
|
+
public async Task UpdateSingleDependencyInNestedDirsProjUsingWildcard()
|
175
|
+
{
|
176
|
+
await TestUpdateForDirsProj("Newtonsoft.Json", "9.0.1", "13.0.1",
|
177
|
+
// initial
|
178
|
+
projectContents: """
|
179
|
+
<Project Sdk="Microsoft.Build.NoTargets">
|
180
|
+
|
181
|
+
<ItemGroup>
|
182
|
+
<ProjectReference Include="src/*.proj" />
|
183
|
+
</ItemGroup>
|
184
|
+
|
185
|
+
</Project>
|
186
|
+
""",
|
187
|
+
additionalFiles:
|
188
|
+
[
|
189
|
+
("src/dirs.proj",
|
190
|
+
"""
|
191
|
+
<Project Sdk="Microsoft.Build.NoTargets">
|
192
|
+
|
193
|
+
<ItemGroup>
|
194
|
+
<ProjectReference Include="test-project/test-project.csproj" />
|
195
|
+
</ItemGroup>
|
119
196
|
|
120
|
-
|
121
|
-
|
197
|
+
</Project>
|
198
|
+
"""),
|
122
199
|
("src/test-project/test-project.csproj",
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
200
|
+
"""
|
201
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
202
|
+
<PropertyGroup>
|
203
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
204
|
+
</PropertyGroup>
|
205
|
+
|
206
|
+
<ItemGroup>
|
207
|
+
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
|
208
|
+
</ItemGroup>
|
209
|
+
</Project>
|
210
|
+
""")
|
211
|
+
],
|
135
212
|
// expected
|
136
213
|
expectedProjectContents: """
|
137
214
|
<Project Sdk="Microsoft.Build.NoTargets">
|
215
|
+
|
216
|
+
<ItemGroup>
|
217
|
+
<ProjectReference Include="src/*.proj" />
|
218
|
+
</ItemGroup>
|
219
|
+
|
220
|
+
</Project>
|
221
|
+
""",
|
222
|
+
additionalFilesExpected:
|
223
|
+
[
|
224
|
+
("src/dirs.proj",
|
225
|
+
"""
|
226
|
+
<Project Sdk="Microsoft.Build.NoTargets">
|
227
|
+
|
228
|
+
<ItemGroup>
|
229
|
+
<ProjectReference Include="test-project/test-project.csproj" />
|
230
|
+
</ItemGroup>
|
138
231
|
|
232
|
+
</Project>
|
233
|
+
"""),
|
234
|
+
("src/test-project/test-project.csproj",
|
235
|
+
"""
|
236
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
237
|
+
<PropertyGroup>
|
238
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
239
|
+
</PropertyGroup>
|
240
|
+
|
241
|
+
<ItemGroup>
|
242
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
243
|
+
</ItemGroup>
|
244
|
+
</Project>
|
245
|
+
""")
|
246
|
+
]);
|
247
|
+
}
|
248
|
+
|
249
|
+
[Fact]
|
250
|
+
public async Task UpdateSingleDependencyInNestedDirsProjUsingRecursiveWildcard()
|
251
|
+
{
|
252
|
+
await TestUpdateForDirsProj("Newtonsoft.Json", "9.0.1", "13.0.1",
|
253
|
+
// initial
|
254
|
+
projectContents: """
|
255
|
+
<Project Sdk="Microsoft.Build.NoTargets">
|
256
|
+
|
139
257
|
<ItemGroup>
|
140
|
-
<ProjectReference Include="
|
258
|
+
<ProjectReference Include="**/*.proj" />
|
141
259
|
</ItemGroup>
|
142
260
|
|
143
261
|
</Project>
|
144
262
|
""",
|
145
|
-
|
146
|
-
|
263
|
+
additionalFiles:
|
264
|
+
[
|
147
265
|
("src/dirs.proj",
|
148
|
-
|
149
|
-
|
266
|
+
"""
|
267
|
+
<Project Sdk="Microsoft.Build.NoTargets">
|
268
|
+
|
269
|
+
<ItemGroup>
|
270
|
+
<ProjectReference Include="test-project/test-project.csproj" />
|
271
|
+
</ItemGroup>
|
150
272
|
|
151
|
-
|
152
|
-
|
153
|
-
|
273
|
+
</Project>
|
274
|
+
"""),
|
275
|
+
("src/test-project/test-project.csproj",
|
276
|
+
"""
|
277
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
278
|
+
<PropertyGroup>
|
279
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
280
|
+
</PropertyGroup>
|
281
|
+
|
282
|
+
<ItemGroup>
|
283
|
+
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
|
284
|
+
</ItemGroup>
|
285
|
+
</Project>
|
286
|
+
""")
|
287
|
+
],
|
288
|
+
// expected
|
289
|
+
expectedProjectContents: """
|
290
|
+
<Project Sdk="Microsoft.Build.NoTargets">
|
291
|
+
|
292
|
+
<ItemGroup>
|
293
|
+
<ProjectReference Include="**/*.proj" />
|
294
|
+
</ItemGroup>
|
295
|
+
|
296
|
+
</Project>
|
297
|
+
""",
|
298
|
+
additionalFilesExpected:
|
299
|
+
[
|
300
|
+
("src/dirs.proj",
|
301
|
+
"""
|
302
|
+
<Project Sdk="Microsoft.Build.NoTargets">
|
303
|
+
|
304
|
+
<ItemGroup>
|
305
|
+
<ProjectReference Include="test-project/test-project.csproj" />
|
306
|
+
</ItemGroup>
|
154
307
|
|
155
|
-
|
156
|
-
|
308
|
+
</Project>
|
309
|
+
"""),
|
157
310
|
("src/test-project/test-project.csproj",
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
311
|
+
"""
|
312
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
313
|
+
<PropertyGroup>
|
314
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
315
|
+
</PropertyGroup>
|
316
|
+
|
317
|
+
<ItemGroup>
|
318
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
319
|
+
</ItemGroup>
|
320
|
+
</Project>
|
321
|
+
""")
|
322
|
+
]);
|
170
323
|
}
|
171
324
|
|
172
325
|
static async Task TestUpdateForDirsProj(
|
@@ -179,8 +332,8 @@ public partial class UpdateWorkerTests
|
|
179
332
|
(string Path, string Content)[]? additionalFiles = null,
|
180
333
|
(string Path, string Content)[]? additionalFilesExpected = null)
|
181
334
|
{
|
182
|
-
additionalFiles ??=
|
183
|
-
additionalFilesExpected ??=
|
335
|
+
additionalFiles ??= [];
|
336
|
+
additionalFilesExpected ??= [];
|
184
337
|
|
185
338
|
var projectName = "dirs";
|
186
339
|
var projectFileName = $"{projectName}.proj";
|
@@ -18,7 +18,15 @@ public abstract class UpdateWorkerTestBase
|
|
18
18
|
bool isTransitive = false,
|
19
19
|
(string Path, string Content)[]? additionalFiles = null,
|
20
20
|
string projectFilePath = "test-project.csproj")
|
21
|
-
=> TestUpdateForProject(
|
21
|
+
=> TestUpdateForProject(
|
22
|
+
dependencyName,
|
23
|
+
oldVersion,
|
24
|
+
newVersion,
|
25
|
+
(projectFilePath, projectContents),
|
26
|
+
expectedProjectContents: projectContents,
|
27
|
+
isTransitive,
|
28
|
+
additionalFiles,
|
29
|
+
additionalFilesExpected: additionalFiles);
|
22
30
|
|
23
31
|
protected static Task TestUpdateForProject(
|
24
32
|
string dependencyName,
|
@@ -30,10 +38,15 @@ public abstract class UpdateWorkerTestBase
|
|
30
38
|
(string Path, string Content)[]? additionalFiles = null,
|
31
39
|
(string Path, string Content)[]? additionalFilesExpected = null,
|
32
40
|
string projectFilePath = "test-project.csproj")
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
41
|
+
=> TestUpdateForProject(
|
42
|
+
dependencyName,
|
43
|
+
oldVersion,
|
44
|
+
newVersion,
|
45
|
+
(Path: projectFilePath, Content: projectContents),
|
46
|
+
expectedProjectContents,
|
47
|
+
isTransitive,
|
48
|
+
additionalFiles,
|
49
|
+
additionalFilesExpected);
|
37
50
|
|
38
51
|
protected static async Task TestUpdateForProject(
|
39
52
|
string dependencyName,
|
@@ -45,8 +58,8 @@ public abstract class UpdateWorkerTestBase
|
|
45
58
|
(string Path, string Content)[]? additionalFiles = null,
|
46
59
|
(string Path, string Content)[]? additionalFilesExpected = null)
|
47
60
|
{
|
48
|
-
additionalFiles ??=
|
49
|
-
additionalFilesExpected ??=
|
61
|
+
additionalFiles ??= [];
|
62
|
+
additionalFilesExpected ??= [];
|
50
63
|
|
51
64
|
var projectFilePath = projectFile.Path;
|
52
65
|
var projectName = Path.GetFileNameWithoutExtension(projectFilePath);
|
@@ -76,7 +89,7 @@ public abstract class UpdateWorkerTestBase
|
|
76
89
|
""";
|
77
90
|
var testFiles = new[] { (slnName, slnContent), projectFile }.Concat(additionalFiles).ToArray();
|
78
91
|
|
79
|
-
var actualResult = await RunUpdate(testFiles, async
|
92
|
+
var actualResult = await RunUpdate(testFiles, async temporaryDirectory =>
|
80
93
|
{
|
81
94
|
var slnPath = Path.Combine(temporaryDirectory, slnName);
|
82
95
|
var worker = new UpdaterWorker(new Logger(verbose: true));
|
@@ -94,7 +107,7 @@ public abstract class UpdateWorkerTestBase
|
|
94
107
|
using var tempDir = new TemporaryDirectory();
|
95
108
|
foreach (var file in files)
|
96
109
|
{
|
97
|
-
var localPath = file.Path.StartsWith(
|
110
|
+
var localPath = file.Path.StartsWith('/') ? file.Path[1..] : file.Path; // remove path rooting character
|
98
111
|
var filePath = Path.Combine(tempDir.DirectoryPath, localPath);
|
99
112
|
var directoryPath = Path.GetDirectoryName(filePath);
|
100
113
|
Directory.CreateDirectory(directoryPath!);
|