dependabot-nuget 0.291.0 → 0.292.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/helpers/lib/NuGetUpdater/.editorconfig +1 -0
- data/helpers/lib/NuGetUpdater/Directory.Build.props +1 -0
- data/helpers/lib/NuGetUpdater/Directory.Packages.props +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/CloneCommand.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +15 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +2 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +87 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementConverter.cs +19 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/BadRequirementException.cs +9 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/CloneWorker.cs +39 -8
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +67 -12
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ErrorType.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +28 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/NuGetUpdater.Core.csproj +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/BadRequirement.cs +10 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/CommitOptions.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/DependencyFileNotFound.cs +3 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobErrorBase.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobRepoNotFound.cs +1 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PrivateSourceAuthenticationFailure.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/UnknownError.cs +6 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/UpdateNotPossible.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +9 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/WebApplicationTargetsConditionPatcher.cs +12 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +0 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +8 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProjectHelper.cs +4 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Clone/CloneWorkerTests.cs +60 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +10 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +56 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +76 -40
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +20 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.LockFile.cs +251 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +6 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +63 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +38 -20
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/ProjectHelperTests.cs +65 -0
- data/helpers/lib/NuGetUpdater/global.json +1 -1
- data/lib/dependabot/nuget/language.rb +21 -5
- data/lib/dependabot/nuget/native_helpers.rb +2 -0
- data/lib/dependabot/nuget/package_manager.rb +4 -4
- metadata +10 -6
@@ -0,0 +1,251 @@
|
|
1
|
+
using Xunit;
|
2
|
+
|
3
|
+
namespace NuGetUpdater.Core.Test.Update;
|
4
|
+
|
5
|
+
public partial class UpdateWorkerTests
|
6
|
+
{
|
7
|
+
public class LockFile : UpdateWorkerTestBase
|
8
|
+
{
|
9
|
+
[Fact]
|
10
|
+
public async Task UpdateSingleDependency()
|
11
|
+
{
|
12
|
+
await TestUpdateForProject("Some.Package", "1.0.0", "2.0.0",
|
13
|
+
packages:
|
14
|
+
[
|
15
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0"),
|
16
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net8.0"),
|
17
|
+
],
|
18
|
+
// initial
|
19
|
+
projectContents: $"""
|
20
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
21
|
+
<PropertyGroup>
|
22
|
+
<TargetFramework>net8.0</TargetFramework>
|
23
|
+
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
24
|
+
</PropertyGroup>
|
25
|
+
|
26
|
+
<ItemGroup>
|
27
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
28
|
+
</ItemGroup>
|
29
|
+
</Project>
|
30
|
+
""",
|
31
|
+
additionalFiles:
|
32
|
+
[
|
33
|
+
("packages.lock.json", "{}")
|
34
|
+
],
|
35
|
+
// expected
|
36
|
+
expectedProjectContents: $"""
|
37
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
38
|
+
<PropertyGroup>
|
39
|
+
<TargetFramework>net8.0</TargetFramework>
|
40
|
+
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
41
|
+
</PropertyGroup>
|
42
|
+
|
43
|
+
<ItemGroup>
|
44
|
+
<PackageReference Include="Some.Package" Version="2.0.0" />
|
45
|
+
</ItemGroup>
|
46
|
+
</Project>
|
47
|
+
""",
|
48
|
+
additionalChecks: path =>
|
49
|
+
{
|
50
|
+
var lockContents = File.ReadAllText(Path.Combine(path, "packages.lock.json"));
|
51
|
+
Assert.Contains("\"resolved\": \"2.0.0\"", lockContents);
|
52
|
+
}
|
53
|
+
);
|
54
|
+
}
|
55
|
+
|
56
|
+
[Fact]
|
57
|
+
public async Task UpdateSingleDependency_CentralPackageManagement()
|
58
|
+
{
|
59
|
+
await TestUpdateForProject("Some.Package", "1.0.0", "2.0.0",
|
60
|
+
packages:
|
61
|
+
[
|
62
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0"),
|
63
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net8.0"),
|
64
|
+
],
|
65
|
+
// initial
|
66
|
+
projectContents: $"""
|
67
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
68
|
+
<PropertyGroup>
|
69
|
+
<TargetFramework>net8.0</TargetFramework>
|
70
|
+
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
71
|
+
</PropertyGroup>
|
72
|
+
|
73
|
+
<ItemGroup>
|
74
|
+
<PackageReference Include="Some.Package" />
|
75
|
+
</ItemGroup>
|
76
|
+
</Project>
|
77
|
+
""",
|
78
|
+
additionalFiles:
|
79
|
+
[
|
80
|
+
("packages.lock.json", "{}"),
|
81
|
+
("Directory.Packages.props", """
|
82
|
+
<Project>
|
83
|
+
<PropertyGroup>
|
84
|
+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
85
|
+
</PropertyGroup>
|
86
|
+
|
87
|
+
<ItemGroup>
|
88
|
+
<PackageVersion Include="Some.Package" Version="1.0.0" />
|
89
|
+
</ItemGroup>
|
90
|
+
</Project>
|
91
|
+
""")
|
92
|
+
],
|
93
|
+
// expected
|
94
|
+
expectedProjectContents: $"""
|
95
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
96
|
+
<PropertyGroup>
|
97
|
+
<TargetFramework>net8.0</TargetFramework>
|
98
|
+
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
99
|
+
</PropertyGroup>
|
100
|
+
|
101
|
+
<ItemGroup>
|
102
|
+
<PackageReference Include="Some.Package" />
|
103
|
+
</ItemGroup>
|
104
|
+
</Project>
|
105
|
+
""",
|
106
|
+
additionalFilesExpected:
|
107
|
+
[
|
108
|
+
("Directory.Packages.props", """
|
109
|
+
<Project>
|
110
|
+
<PropertyGroup>
|
111
|
+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
112
|
+
</PropertyGroup>
|
113
|
+
|
114
|
+
<ItemGroup>
|
115
|
+
<PackageVersion Include="Some.Package" Version="2.0.0" />
|
116
|
+
</ItemGroup>
|
117
|
+
</Project>
|
118
|
+
""")
|
119
|
+
],
|
120
|
+
additionalChecks: path =>
|
121
|
+
{
|
122
|
+
var lockContents = File.ReadAllText(Path.Combine(path, "packages.lock.json"));
|
123
|
+
Assert.Contains("\"resolved\": \"2.0.0\"", lockContents);
|
124
|
+
}
|
125
|
+
);
|
126
|
+
}
|
127
|
+
|
128
|
+
[Fact]
|
129
|
+
public async Task UpdateSingleDependency_WindowsSpecific()
|
130
|
+
{
|
131
|
+
await TestUpdateForProject("Some.Package", "1.0.0", "2.0.0",
|
132
|
+
packages:
|
133
|
+
[
|
134
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0"),
|
135
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net8.0"),
|
136
|
+
],
|
137
|
+
// initial
|
138
|
+
projectContents: $"""
|
139
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
140
|
+
<PropertyGroup>
|
141
|
+
<TargetFramework>net8.0-windows</TargetFramework>
|
142
|
+
<UseWindowsForms>true</UseWindowsForms>
|
143
|
+
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
144
|
+
</PropertyGroup>
|
145
|
+
|
146
|
+
<ItemGroup>
|
147
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
148
|
+
</ItemGroup>
|
149
|
+
</Project>
|
150
|
+
""",
|
151
|
+
additionalFiles:
|
152
|
+
[
|
153
|
+
("packages.lock.json", "{}")
|
154
|
+
],
|
155
|
+
// expected
|
156
|
+
expectedProjectContents: $"""
|
157
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
158
|
+
<PropertyGroup>
|
159
|
+
<TargetFramework>net8.0-windows</TargetFramework>
|
160
|
+
<UseWindowsForms>true</UseWindowsForms>
|
161
|
+
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
162
|
+
</PropertyGroup>
|
163
|
+
|
164
|
+
<ItemGroup>
|
165
|
+
<PackageReference Include="Some.Package" Version="2.0.0" />
|
166
|
+
</ItemGroup>
|
167
|
+
</Project>
|
168
|
+
""",
|
169
|
+
additionalChecks: path =>
|
170
|
+
{
|
171
|
+
var lockContents = File.ReadAllText(Path.Combine(path, "packages.lock.json"));
|
172
|
+
Assert.Contains("\"resolved\": \"2.0.0\"", lockContents);
|
173
|
+
}
|
174
|
+
);
|
175
|
+
}
|
176
|
+
|
177
|
+
[Fact]
|
178
|
+
public async Task UpdateSingleDependency_CentralPackageManagement_WindowsSpecific()
|
179
|
+
{
|
180
|
+
await TestUpdateForProject("Some.Package", "1.0.0", "2.0.0",
|
181
|
+
packages:
|
182
|
+
[
|
183
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0"),
|
184
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net8.0"),
|
185
|
+
],
|
186
|
+
// initial
|
187
|
+
projectContents: $"""
|
188
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
189
|
+
<PropertyGroup>
|
190
|
+
<TargetFramework>net8.0-windows</TargetFramework>
|
191
|
+
<UseWindowsForms>true</UseWindowsForms>
|
192
|
+
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
193
|
+
</PropertyGroup>
|
194
|
+
|
195
|
+
<ItemGroup>
|
196
|
+
<PackageReference Include="Some.Package" />
|
197
|
+
</ItemGroup>
|
198
|
+
</Project>
|
199
|
+
""",
|
200
|
+
additionalFiles:
|
201
|
+
[
|
202
|
+
("packages.lock.json", "{}"),
|
203
|
+
("Directory.Packages.props", """
|
204
|
+
<Project>
|
205
|
+
<PropertyGroup>
|
206
|
+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
207
|
+
</PropertyGroup>
|
208
|
+
|
209
|
+
<ItemGroup>
|
210
|
+
<PackageVersion Include="Some.Package" Version="1.0.0" />
|
211
|
+
</ItemGroup>
|
212
|
+
</Project>
|
213
|
+
""")
|
214
|
+
],
|
215
|
+
// expected
|
216
|
+
expectedProjectContents: $"""
|
217
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
218
|
+
<PropertyGroup>
|
219
|
+
<TargetFramework>net8.0-windows</TargetFramework>
|
220
|
+
<UseWindowsForms>true</UseWindowsForms>
|
221
|
+
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
222
|
+
</PropertyGroup>
|
223
|
+
|
224
|
+
<ItemGroup>
|
225
|
+
<PackageReference Include="Some.Package" />
|
226
|
+
</ItemGroup>
|
227
|
+
</Project>
|
228
|
+
""",
|
229
|
+
additionalFilesExpected:
|
230
|
+
[
|
231
|
+
("Directory.Packages.props", """
|
232
|
+
<Project>
|
233
|
+
<PropertyGroup>
|
234
|
+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
235
|
+
</PropertyGroup>
|
236
|
+
|
237
|
+
<ItemGroup>
|
238
|
+
<PackageVersion Include="Some.Package" Version="2.0.0" />
|
239
|
+
</ItemGroup>
|
240
|
+
</Project>
|
241
|
+
""")
|
242
|
+
],
|
243
|
+
additionalChecks: path =>
|
244
|
+
{
|
245
|
+
var lockContents = File.ReadAllText(Path.Combine(path, "packages.lock.json"));
|
246
|
+
Assert.Contains("\"resolved\": \"2.0.0\"", lockContents);
|
247
|
+
}
|
248
|
+
);
|
249
|
+
}
|
250
|
+
}
|
251
|
+
}
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs
CHANGED
@@ -495,7 +495,7 @@ public partial class UpdateWorkerTests
|
|
495
495
|
MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
|
496
496
|
],
|
497
497
|
projectContents: $"""
|
498
|
-
<Project Sdk="Microsoft.NET.Sdk">
|
498
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
499
499
|
<PropertyGroup>
|
500
500
|
<TargetFramework>net8.0</TargetFramework>
|
501
501
|
<SomePackageVersion>9.0.1</SomePackageVersion>
|
@@ -3075,14 +3075,14 @@ public partial class UpdateWorkerTests
|
|
3075
3075
|
public async Task UpdatingTransitiveDependencyWithNewSolverCanUpdateJustTheTopLevelPackage()
|
3076
3076
|
{
|
3077
3077
|
// we've been asked to explicitly update a transitive dependency, but we can solve it by updating the top-level package instead
|
3078
|
-
await TestUpdateForProject("Transitive.Package", "
|
3078
|
+
await TestUpdateForProject("Transitive.Package", "7.0.0", "8.0.0",
|
3079
3079
|
isTransitive: true,
|
3080
3080
|
packages:
|
3081
3081
|
[
|
3082
|
-
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0", [("net8.0", [("Transitive.Package", "[
|
3083
|
-
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net8.0", [("net8.0", [("Transitive.Package", "[
|
3084
|
-
MockNuGetPackage.CreateSimplePackage("Transitive.Package", "
|
3085
|
-
MockNuGetPackage.CreateSimplePackage("Transitive.Package", "
|
3082
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net8.0", [("net8.0", [("Transitive.Package", "[7.0.0]")])]),
|
3083
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net8.0", [("net8.0", [("Transitive.Package", "[8.0.0]")])]),
|
3084
|
+
MockNuGetPackage.CreateSimplePackage("Transitive.Package", "7.0.0", "net8.0"),
|
3085
|
+
MockNuGetPackage.CreateSimplePackage("Transitive.Package", "8.0.0", "net8.0"),
|
3086
3086
|
],
|
3087
3087
|
projectContents: """
|
3088
3088
|
<Project Sdk="Microsoft.NET.Sdk">
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs
CHANGED
@@ -1969,7 +1969,7 @@ public partial class UpdateWorkerTests
|
|
1969
1969
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">C:\some\path\that\does\not\exist</VSToolsPath>
|
1970
1970
|
</PropertyGroup>
|
1971
1971
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
1972
|
-
<Import Project="$(VSToolsPath)\
|
1972
|
+
<Import Project="$(VSToolsPath)\SomeSubPath\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
1973
1973
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
1974
1974
|
Other similar extension points exist, see Microsoft.Common.targets.
|
1975
1975
|
<Target Name="BeforeBuild">
|
@@ -2050,7 +2050,7 @@ public partial class UpdateWorkerTests
|
|
2050
2050
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">C:\some\path\that\does\not\exist</VSToolsPath>
|
2051
2051
|
</PropertyGroup>
|
2052
2052
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
2053
|
-
<Import Project="$(VSToolsPath)\
|
2053
|
+
<Import Project="$(VSToolsPath)\SomeSubPath\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
2054
2054
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
2055
2055
|
Other similar extension points exist, see Microsoft.Common.targets.
|
2056
2056
|
<Target Name="BeforeBuild">
|
@@ -2292,15 +2292,73 @@ public partial class UpdateWorkerTests
|
|
2292
2292
|
}
|
2293
2293
|
|
2294
2294
|
[Fact]
|
2295
|
-
public async Task
|
2295
|
+
public async Task MissingVisualStudioComponentTargetsAreReportedAsMissingFiles()
|
2296
2296
|
{
|
2297
|
-
|
2297
|
+
using var temporaryDirectory = await TemporaryDirectory.CreateWithContentsAsync(
|
2298
|
+
[
|
2299
|
+
("project.csproj", """
|
2300
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
2301
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
2302
|
+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Some.Visual.Studio.Component.props" />
|
2303
|
+
<PropertyGroup>
|
2304
|
+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
2305
|
+
</PropertyGroup>
|
2306
|
+
<ItemGroup>
|
2307
|
+
<None Include="packages.config" />
|
2308
|
+
</ItemGroup>
|
2309
|
+
<ItemGroup>
|
2310
|
+
<Reference Include="Some.Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
2311
|
+
<HintPath>packages\Some.Package.1.0.0\lib\net45\Some.Package.dll</HintPath>
|
2312
|
+
<Private>True</Private>
|
2313
|
+
</Reference>
|
2314
|
+
</ItemGroup>
|
2315
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
2316
|
+
</Project>
|
2317
|
+
"""),
|
2318
|
+
("packages.config", """
|
2319
|
+
<packages>
|
2320
|
+
<package id="Some.Package" version="1.0.0" targetFramework="net45" />
|
2321
|
+
</packages>
|
2322
|
+
"""),
|
2323
|
+
("NuGet.Config", """
|
2324
|
+
<configuration>
|
2325
|
+
<packageSources>
|
2326
|
+
<clear />
|
2327
|
+
<add key="private_feed" value="packages" />
|
2328
|
+
</packageSources>
|
2329
|
+
</configuration>
|
2330
|
+
""")
|
2331
|
+
]
|
2332
|
+
);
|
2333
|
+
MockNuGetPackage[] packages =
|
2334
|
+
[
|
2335
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net45"),
|
2336
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.1.0", "net45"),
|
2337
|
+
];
|
2338
|
+
await MockNuGetPackagesInDirectory(packages, Path.Combine(temporaryDirectory.DirectoryPath, "packages"));
|
2339
|
+
var resultOutputPath = Path.Combine(temporaryDirectory.DirectoryPath, "result.json");
|
2340
|
+
|
2341
|
+
var worker = new UpdaterWorker(new ExperimentsManager(), new TestLogger());
|
2342
|
+
await worker.RunAsync(temporaryDirectory.DirectoryPath, "project.csproj", "Some.Package", "1.0.0", "1.1.0", isTransitive: false, resultOutputPath: resultOutputPath);
|
2343
|
+
|
2344
|
+
var resultContents = await File.ReadAllTextAsync(resultOutputPath);
|
2345
|
+
var result = JsonSerializer.Deserialize<UpdateOperationResult>(resultContents, UpdaterWorker.SerializerOptions)!;
|
2346
|
+
Assert.Equal(ErrorType.MissingFile, result.ErrorType);
|
2347
|
+
Assert.Equal("$(MSBuildExtensionsPath32)/Microsoft/VisualStudio/v$(VisualStudioVersion)/Some.Visual.Studio.Component.props", result.ErrorDetails!.ToString().NormalizePathToUnix());
|
2348
|
+
}
|
2349
|
+
|
2350
|
+
[Theory]
|
2351
|
+
[InlineData(401)]
|
2352
|
+
[InlineData(403)]
|
2353
|
+
public async Task ReportsPrivateSourceAuthenticationFailure(int httpStatusCode)
|
2354
|
+
{
|
2355
|
+
(int, string) TestHttpHandler(string uriString)
|
2298
2356
|
{
|
2299
2357
|
var uri = new Uri(uriString, UriKind.Absolute);
|
2300
2358
|
var baseUrl = $"{uri.Scheme}://{uri.Host}:{uri.Port}";
|
2301
2359
|
return uri.PathAndQuery switch
|
2302
2360
|
{
|
2303
|
-
_ => (
|
2361
|
+
_ => (httpStatusCode, "{}"), // everything is unauthorized
|
2304
2362
|
};
|
2305
2363
|
}
|
2306
2364
|
using var http = TestHttpServer.CreateTestStringServer(TestHttpHandler);
|
@@ -854,30 +854,45 @@ public class MSBuildHelperTests : TestBase
|
|
854
854
|
|
855
855
|
// Two top level packages (Buildalyzer), (Microsoft.CodeAnalysis.CSharp.Scripting) that share a dependency (Microsoft.CodeAnalysis.Csharp)
|
856
856
|
// Updating ONE of the top level packages, which updates the dependencies and their other "parents"
|
857
|
-
// First family: Buildalyzer 7.0.1 requires Microsoft.CodeAnalysis.CSharp to be
|
858
|
-
// Second family: Microsoft.CodeAnalysis.CSharp.Scripting 4.0.
|
857
|
+
// First family: Buildalyzer 7.0.1 requires Microsoft.CodeAnalysis.CSharp to be = 4.0.1 and Microsoft.CodeAnalysis.Common to be 4.0.1 (@ 6.0.4, Microsoft.CodeAnalysis.Common isn't a dependency of buildalyzer)
|
858
|
+
// Second family: Microsoft.CodeAnalysis.CSharp.Scripting 4.0.1 requires Microsoft.CodeAnalysis.CSharp 4.0.1 and Microsoft.CodeAnalysis.Common to be 4.0.1 (Specific version)
|
859
859
|
// Updating Buildalyzer to 7.0.1 will update its transitive dependency (Microsoft.CodeAnalysis.Common) and then its transitive dependency's "family"
|
860
|
-
[
|
861
|
-
|
862
|
-
[InlineData(false)]
|
863
|
-
public async Task DependencyConflictsCanBeResolvedNewSharingDependency(bool useExistingSdks)
|
860
|
+
[Fact]
|
861
|
+
public async Task DependencyConflictsCanBeResolvedNewSharingDependency()
|
864
862
|
{
|
863
|
+
// arrange
|
865
864
|
using var tempDirectory = new TemporaryDirectory();
|
866
865
|
var projectPath = Path.Join(tempDirectory.DirectoryPath, "project.csproj");
|
867
866
|
await File.WriteAllTextAsync(projectPath, """
|
868
867
|
<Project Sdk="Microsoft.NET.Sdk">
|
869
|
-
|
868
|
+
<PropertyGroup>
|
870
869
|
<TargetFramework>net8.0</TargetFramework>
|
871
|
-
|
872
|
-
|
870
|
+
</PropertyGroup>
|
871
|
+
<ItemGroup>
|
873
872
|
<PackageReference Include="Buildalyzer" Version="6.0.4" />
|
874
873
|
<PackageReference Include="Microsoft.CodeAnalysis.Csharp.Scripting" Version="3.10.0" />
|
875
874
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" />
|
876
875
|
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.10.0" />
|
877
|
-
|
876
|
+
</ItemGroup>
|
878
877
|
</Project>
|
879
878
|
""");
|
880
879
|
|
880
|
+
var testPackages = new MockNuGetPackage[]
|
881
|
+
{
|
882
|
+
MockNuGetPackage.CreateSimplePackage("Buildalyzer", "6.0.4", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[3.10.0]")])]),
|
883
|
+
MockNuGetPackage.CreateSimplePackage("Buildalyzer", "7.0.1", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[4.0.1]")])]),
|
884
|
+
|
885
|
+
MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp.Scripting", "3.10.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[3.10.0]")])]),
|
886
|
+
MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp.Scripting", "4.0.1", "net8.0", [(null, [("Microsoft.CodeAnalysis.CSharp", "[4.0.1]")])]),
|
887
|
+
|
888
|
+
MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "3.10.0", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[3.10.0]")])]),
|
889
|
+
MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.CSharp", "4.0.1", "net8.0", [(null, [("Microsoft.CodeAnalysis.Common", "[4.0.1]")])]),
|
890
|
+
|
891
|
+
MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "3.10.0", "net8.0"),
|
892
|
+
MockNuGetPackage.CreateSimplePackage("Microsoft.CodeAnalysis.Common", "4.0.1", "net8.0"),
|
893
|
+
};
|
894
|
+
await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(testPackages, tempDirectory.DirectoryPath);
|
895
|
+
|
881
896
|
var dependencies = new[]
|
882
897
|
{
|
883
898
|
new Dependency("Buildalyzer", "6.0.4", DependencyType.PackageReference),
|
@@ -890,25 +905,28 @@ public class MSBuildHelperTests : TestBase
|
|
890
905
|
new Dependency("Buildalyzer", "7.0.1", DependencyType.PackageReference),
|
891
906
|
};
|
892
907
|
|
908
|
+
// act
|
893
909
|
var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(
|
894
910
|
tempDirectory.DirectoryPath,
|
895
911
|
projectPath,
|
896
912
|
"net8.0",
|
897
913
|
dependencies,
|
898
914
|
update,
|
899
|
-
new ExperimentsManager()
|
915
|
+
new ExperimentsManager(),
|
900
916
|
new TestLogger()
|
901
917
|
);
|
918
|
+
|
919
|
+
// assert
|
920
|
+
var expectedDependencies = new[]
|
921
|
+
{
|
922
|
+
"Buildalyzer/7.0.1",
|
923
|
+
"Microsoft.CodeAnalysis.CSharp.Scripting/4.0.1",
|
924
|
+
"Microsoft.CodeAnalysis.CSharp/4.0.1",
|
925
|
+
"Microsoft.CodeAnalysis.Common/4.0.1"
|
926
|
+
};
|
902
927
|
Assert.NotNull(resolvedDependencies);
|
903
|
-
|
904
|
-
|
905
|
-
Assert.Equal("7.0.1", resolvedDependencies[0].Version);
|
906
|
-
Assert.Equal("Microsoft.CodeAnalysis.CSharp.Scripting", resolvedDependencies[1].Name);
|
907
|
-
Assert.Equal("4.0.0", resolvedDependencies[1].Version);
|
908
|
-
Assert.Equal("Microsoft.CodeAnalysis.CSharp", resolvedDependencies[2].Name);
|
909
|
-
Assert.Equal("4.0.0", resolvedDependencies[2].Version);
|
910
|
-
Assert.Equal("Microsoft.CodeAnalysis.Common", resolvedDependencies[3].Name);
|
911
|
-
Assert.Equal("4.0.0", resolvedDependencies[3].Version);
|
928
|
+
var actualDependencies = resolvedDependencies.Select(d => $"{d.Name}/{d.Version}").ToArray();
|
929
|
+
AssertEx.Equal(expectedDependencies, actualDependencies);
|
912
930
|
}
|
913
931
|
|
914
932
|
// Updating two families at once to test efficiency
|
@@ -0,0 +1,65 @@
|
|
1
|
+
using NuGetUpdater.Core.Utilities;
|
2
|
+
|
3
|
+
using Xunit;
|
4
|
+
|
5
|
+
namespace NuGetUpdater.Core.Test.Utilities;
|
6
|
+
|
7
|
+
public class ProjectHelperTests : TestBase
|
8
|
+
{
|
9
|
+
[Theory]
|
10
|
+
[MemberData(nameof(AdditionalFile))]
|
11
|
+
public async Task GetAdditionalFilesFromProject(string projectPath, (string Name, string Content)[] files, string[] expectedAdditionalFiles)
|
12
|
+
{
|
13
|
+
using var tempDirectory = await TemporaryDirectory.CreateWithContentsAsync(files);
|
14
|
+
var fullProjectPath = Path.Join(tempDirectory.DirectoryPath, projectPath);
|
15
|
+
|
16
|
+
var actualAdditionalFiles = ProjectHelper.GetAllAdditionalFilesFromProject(fullProjectPath, ProjectHelper.PathFormat.Relative);
|
17
|
+
AssertEx.Equal(expectedAdditionalFiles, actualAdditionalFiles);
|
18
|
+
}
|
19
|
+
|
20
|
+
public static IEnumerable<object[]> AdditionalFile()
|
21
|
+
{
|
22
|
+
// no additional files
|
23
|
+
yield return
|
24
|
+
[
|
25
|
+
// project path
|
26
|
+
"src/project.csproj",
|
27
|
+
// files
|
28
|
+
new[]
|
29
|
+
{
|
30
|
+
("src/project.csproj", """
|
31
|
+
<Project>
|
32
|
+
</Project>
|
33
|
+
""")
|
34
|
+
},
|
35
|
+
// expected additional files
|
36
|
+
Array.Empty<string>()
|
37
|
+
];
|
38
|
+
|
39
|
+
// files with relative paths
|
40
|
+
yield return
|
41
|
+
[
|
42
|
+
// project path
|
43
|
+
"src/project.csproj",
|
44
|
+
// files
|
45
|
+
new[]
|
46
|
+
{
|
47
|
+
("src/project.csproj", """
|
48
|
+
<Project>
|
49
|
+
<ItemGroup>
|
50
|
+
<None Include="..\unexpected-path\packages.config" />
|
51
|
+
</ItemGroup>
|
52
|
+
</Project>
|
53
|
+
"""),
|
54
|
+
("unexpected-path/packages.config", """
|
55
|
+
<packages></packages>
|
56
|
+
""")
|
57
|
+
},
|
58
|
+
// expected additional files
|
59
|
+
new[]
|
60
|
+
{
|
61
|
+
"../unexpected-path/packages.config"
|
62
|
+
}
|
63
|
+
];
|
64
|
+
}
|
65
|
+
}
|
@@ -12,7 +12,11 @@ module Dependabot
|
|
12
12
|
|
13
13
|
sig { params(language: String, raw_version: String, requirement: T.nilable(Requirement)).void }
|
14
14
|
def initialize(language, raw_version, requirement = nil)
|
15
|
-
super(
|
15
|
+
super(
|
16
|
+
name: language,
|
17
|
+
version: Version.new(raw_version),
|
18
|
+
requirement: requirement,
|
19
|
+
)
|
16
20
|
end
|
17
21
|
end
|
18
22
|
|
@@ -28,7 +32,10 @@ module Dependabot
|
|
28
32
|
|
29
33
|
sig { params(language: String, requirement: T.nilable(Requirement)).void }
|
30
34
|
def initialize(language, requirement = nil)
|
31
|
-
super(
|
35
|
+
super(
|
36
|
+
name: language,
|
37
|
+
requirement: requirement,
|
38
|
+
)
|
32
39
|
end
|
33
40
|
end
|
34
41
|
|
@@ -44,7 +51,10 @@ module Dependabot
|
|
44
51
|
|
45
52
|
sig { params(language: String, requirement: T.nilable(Requirement)).void }
|
46
53
|
def initialize(language, requirement = nil)
|
47
|
-
super(
|
54
|
+
super(
|
55
|
+
name: language,
|
56
|
+
requirement: requirement,
|
57
|
+
)
|
48
58
|
end
|
49
59
|
end
|
50
60
|
|
@@ -60,7 +70,10 @@ module Dependabot
|
|
60
70
|
|
61
71
|
sig { params(language: String, requirement: T.nilable(Requirement)).void }
|
62
72
|
def initialize(language, requirement = nil)
|
63
|
-
super(
|
73
|
+
super(
|
74
|
+
name: language,
|
75
|
+
requirement: requirement,
|
76
|
+
)
|
64
77
|
end
|
65
78
|
end
|
66
79
|
|
@@ -75,7 +88,10 @@ module Dependabot
|
|
75
88
|
|
76
89
|
sig { params(language: String, requirement: T.nilable(Requirement)).void }
|
77
90
|
def initialize(language, requirement = nil)
|
78
|
-
super(
|
91
|
+
super(
|
92
|
+
name: language,
|
93
|
+
requirement: requirement,
|
94
|
+
)
|
79
95
|
end
|
80
96
|
end
|
81
97
|
end
|
@@ -301,6 +301,8 @@ module Dependabot
|
|
301
301
|
raise DependencyFileNotParseable, T.must(T.let(error_details, T.nilable(String)))
|
302
302
|
when "AuthenticationFailure"
|
303
303
|
raise PrivateSourceAuthenticationFailure, T.let(error_details, T.nilable(String))
|
304
|
+
when "BadRequirement"
|
305
|
+
raise BadRequirementError, T.let(error_details, T.nilable(String))
|
304
306
|
when "MissingFile"
|
305
307
|
raise DependencyFileNotFound, T.let(error_details, T.nilable(String))
|
306
308
|
when "UpdateNotPossible"
|
@@ -30,10 +30,10 @@ module Dependabot
|
|
30
30
|
end
|
31
31
|
def initialize(raw_version)
|
32
32
|
super(
|
33
|
-
NAME,
|
34
|
-
Version.new(raw_version),
|
35
|
-
|
36
|
-
|
33
|
+
name: NAME,
|
34
|
+
version: Version.new(raw_version),
|
35
|
+
deprecated_versions: DEPRECATED_VERSIONS,
|
36
|
+
supported_versions: SUPPORTED_VERSIONS
|
37
37
|
)
|
38
38
|
end
|
39
39
|
|