dependabot-nuget 0.321.2 → 0.322.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/Directory.Packages.props +22 -22
- data/helpers/lib/NuGetUpdater/DotNetPackageCorrelation/Model/PackageMapper.cs +9 -0
- data/helpers/lib/NuGetUpdater/DotNetPackageCorrelation.Cli/Program.cs +21 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +19 -11
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/CloneCommand.cs +19 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +21 -14
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs +8 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +29 -16
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs +20 -19
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +2 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscoveryTargetingPacks.props +2 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencySolver/IDependencySolver.cs +8 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencySolver/MSBuildDependencySolver.cs +32 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +10 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +3 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/GlobalJsonBuildFile.cs +5 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/PrivateSourceTimedOutException.cs +12 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobErrorBase.cs +4 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PrivateSourceTimedOut.cs +10 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestTextGenerator.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/CreateSecurityUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/GroupUpdateAllVersionsHandler.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +6 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/FileWriterWorker.cs +376 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/IFileWriter.cs +14 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/XmlFileWriter.cs +477 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +9 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdateOperationBase.cs +18 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +26 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +15 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/DependencySolver/MSBuildDependencySolverTests.cs +633 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +0 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +0 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +49 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/EndToEndTests.cs +484 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/HttpApiHandlerTests.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/JobErrorBaseTests.cs +7 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MessageReportTests.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestTextTests.cs +21 -22
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +8 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/DotNetToolsJsonUpdaterTests.cs +181 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterTestsBase.cs +61 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterWorkerTests.cs +917 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterWorkerTests_MiscellaneousTests.cs +154 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/TestFileWriterReturnsConstantResult.cs +20 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/XmlFileWriterTests.cs +1620 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/XmlFileWriterTests_CreateUpdatedVersionRangeTests.cs +25 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/GlobalJsonUpdaterTests.cs +139 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +1961 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateOperationResultTests.cs +116 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +16 -1043
- data/helpers/lib/NuGetUpdater/global.json +1 -1
- metadata +21 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +0 -375
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +0 -296
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.LockFile.cs +0 -251
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +0 -201
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +0 -3821
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +0 -2706
@@ -690,7 +690,6 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
|
|
690
690
|
{
|
691
691
|
FilePath = "global.json",
|
692
692
|
Dependencies = [
|
693
|
-
new("Microsoft.NET.Sdk", "6.0.405", DependencyType.MSBuildSdk),
|
694
693
|
new("My.Custom.Sdk", "5.0.0", DependencyType.MSBuildSdk),
|
695
694
|
new("My.Other.Sdk", "1.0.0-beta", DependencyType.MSBuildSdk),
|
696
695
|
]
|
@@ -1044,7 +1043,6 @@ public partial class DiscoveryWorkerTests : DiscoveryWorkerTestBase
|
|
1044
1043
|
{
|
1045
1044
|
FilePath = "global.json",
|
1046
1045
|
Dependencies = [
|
1047
|
-
new("Microsoft.NET.Sdk", "6.0.405", DependencyType.MSBuildSdk),
|
1048
1046
|
new("My.Custom.Sdk", "5.0.0", DependencyType.MSBuildSdk),
|
1049
1047
|
new("My.Other.Sdk", "1.0.0-beta", DependencyType.MSBuildSdk),
|
1050
1048
|
]
|
@@ -580,6 +580,55 @@ public class SdkProjectDiscoveryTests : DiscoveryWorkerTestBase
|
|
580
580
|
);
|
581
581
|
}
|
582
582
|
|
583
|
+
[Fact]
|
584
|
+
public async Task ExistingPackageIncompatibilityShouldNotPreventRestore()
|
585
|
+
{
|
586
|
+
// Package.A tries to pull in a transitive dependency of Transitive.Package/2.0.0 but that package is explicitly pinned at 1.0.0
|
587
|
+
// Normally this would cause a restore failure which means discovery would also fail
|
588
|
+
// This test ensures we can still run discovery
|
589
|
+
await TestDiscoverAsync(
|
590
|
+
packages: [
|
591
|
+
MockNuGetPackage.CreateSimplePackage("Package.A", "1.0.0", "net8.0", [(null, [("Transitive.Package", "2.0.0")])]),
|
592
|
+
MockNuGetPackage.CreateSimplePackage("Transitive.Package", "1.0.0", "net8.0"),
|
593
|
+
MockNuGetPackage.CreateSimplePackage("Transitive.Package", "2.0.0", "net8.0"),
|
594
|
+
],
|
595
|
+
startingDirectory: "src",
|
596
|
+
projectPath: "src/library.csproj",
|
597
|
+
files: [
|
598
|
+
("src/library.csproj", """
|
599
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
600
|
+
<PropertyGroup>
|
601
|
+
<TargetFramework>net8.0</TargetFramework>
|
602
|
+
</PropertyGroup>
|
603
|
+
<ItemGroup>
|
604
|
+
<PackageReference Include="Package.A" Version="1.0.0" />
|
605
|
+
<PackageReference Include="Transitive.Package" Version="1.0.0" />
|
606
|
+
</ItemGroup>
|
607
|
+
</Project>
|
608
|
+
""")
|
609
|
+
],
|
610
|
+
expectedProjects: [
|
611
|
+
new()
|
612
|
+
{
|
613
|
+
FilePath = "library.csproj",
|
614
|
+
Dependencies =
|
615
|
+
[
|
616
|
+
new("Package.A", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true),
|
617
|
+
new("Transitive.Package", "1.0.0", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true)
|
618
|
+
],
|
619
|
+
ImportedFiles = [],
|
620
|
+
Properties =
|
621
|
+
[
|
622
|
+
new("TargetFramework", "net8.0", "src/library.csproj"),
|
623
|
+
],
|
624
|
+
TargetFrameworks = ["net8.0"],
|
625
|
+
ReferencedProjectPaths = [],
|
626
|
+
AdditionalFiles = [],
|
627
|
+
}
|
628
|
+
]
|
629
|
+
);
|
630
|
+
}
|
631
|
+
|
583
632
|
private static async Task TestDiscoverAsync(string startingDirectory, string projectPath, TestFile[] files, ImmutableArray<ExpectedSdkProjectDiscoveryResult> expectedProjects, MockNuGetPackage[]? packages = null)
|
584
633
|
{
|
585
634
|
using var testDirectory = await TemporaryDirectory.CreateWithContentsAsync(files);
|
@@ -53,7 +53,6 @@ public class GlobalJsonBuildFileTests
|
|
53
53
|
{
|
54
54
|
var expectedDependencies = new List<Dependency>
|
55
55
|
{
|
56
|
-
new("Microsoft.NET.Sdk", "6.0.405", DependencyType.MSBuildSdk),
|
57
56
|
new("My.Custom.Sdk", "5.0.0", DependencyType.MSBuildSdk),
|
58
57
|
new("My.Other.Sdk", "1.0.0-beta", DependencyType.MSBuildSdk)
|
59
58
|
};
|
@@ -4,11 +4,495 @@ using NuGetUpdater.Core.Run.ApiModel;
|
|
4
4
|
using NuGetUpdater.Core.Run;
|
5
5
|
using Xunit;
|
6
6
|
using NuGetUpdater.Core.Analyze;
|
7
|
+
using NuGetUpdater.Core.Discover;
|
8
|
+
using System.Collections.Immutable;
|
7
9
|
|
8
10
|
namespace NuGetUpdater.Core.Test.Run;
|
9
11
|
|
10
12
|
public class EndToEndTests
|
11
13
|
{
|
14
|
+
[Fact]
|
15
|
+
public async Task WithNewFileWriter_PackageReference()
|
16
|
+
{
|
17
|
+
await RunWorkerTests.RunAsync(
|
18
|
+
experimentsManager: new ExperimentsManager() { UseDirectDiscovery = true, UseNewFileUpdater = true },
|
19
|
+
packages: [
|
20
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net9.0"),
|
21
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net9.0"),
|
22
|
+
],
|
23
|
+
job: new()
|
24
|
+
{
|
25
|
+
Source = new()
|
26
|
+
{
|
27
|
+
Provider = "github",
|
28
|
+
Repo = "test/repo",
|
29
|
+
Directory = "/",
|
30
|
+
}
|
31
|
+
},
|
32
|
+
files: [
|
33
|
+
("Directory.Build.props", "<Project />"),
|
34
|
+
("Directory.Build.targets", "<Project />"),
|
35
|
+
("Directory.Packages.props", """
|
36
|
+
<Project>
|
37
|
+
<PropertyGroup>
|
38
|
+
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
|
39
|
+
</PropertyGroup>
|
40
|
+
</Project>
|
41
|
+
"""),
|
42
|
+
("project.csproj", """
|
43
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
44
|
+
<PropertyGroup>
|
45
|
+
<TargetFramework>net9.0</TargetFramework>
|
46
|
+
</PropertyGroup>
|
47
|
+
<ItemGroup>
|
48
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
49
|
+
</ItemGroup>
|
50
|
+
</Project>
|
51
|
+
""")
|
52
|
+
],
|
53
|
+
discoveryWorker: null, // use real worker
|
54
|
+
analyzeWorker: null, // use real worker
|
55
|
+
updaterWorker: null, // use real worker
|
56
|
+
expectedResult: new()
|
57
|
+
{
|
58
|
+
Base64DependencyFiles = [],
|
59
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
60
|
+
},
|
61
|
+
expectedApiMessages: [
|
62
|
+
new IncrementMetric()
|
63
|
+
{
|
64
|
+
Metric = "updater.started",
|
65
|
+
Tags = new()
|
66
|
+
{
|
67
|
+
["operation"] = "group_update_all_versions"
|
68
|
+
}
|
69
|
+
},
|
70
|
+
new UpdatedDependencyList()
|
71
|
+
{
|
72
|
+
Dependencies = [
|
73
|
+
new()
|
74
|
+
{
|
75
|
+
Name = "Some.Package",
|
76
|
+
Version = "1.0.0",
|
77
|
+
Requirements = [
|
78
|
+
new()
|
79
|
+
{
|
80
|
+
Requirement = "1.0.0",
|
81
|
+
File = "/project.csproj",
|
82
|
+
Groups = ["dependencies"],
|
83
|
+
}
|
84
|
+
]
|
85
|
+
},
|
86
|
+
],
|
87
|
+
DependencyFiles = [
|
88
|
+
"/Directory.Build.props",
|
89
|
+
"/Directory.Build.targets",
|
90
|
+
"/Directory.Packages.props",
|
91
|
+
"/project.csproj",
|
92
|
+
],
|
93
|
+
},
|
94
|
+
new CreatePullRequest()
|
95
|
+
{
|
96
|
+
Dependencies = [
|
97
|
+
new()
|
98
|
+
{
|
99
|
+
Name = "Some.Package",
|
100
|
+
Version = "2.0.0",
|
101
|
+
Requirements = [
|
102
|
+
new()
|
103
|
+
{
|
104
|
+
Requirement = "2.0.0",
|
105
|
+
File = "/project.csproj",
|
106
|
+
Groups = ["dependencies"],
|
107
|
+
Source = new()
|
108
|
+
{
|
109
|
+
SourceUrl = null,
|
110
|
+
Type = "nuget_repo",
|
111
|
+
}
|
112
|
+
}
|
113
|
+
],
|
114
|
+
PreviousVersion = "1.0.0",
|
115
|
+
PreviousRequirements = [
|
116
|
+
new()
|
117
|
+
{
|
118
|
+
Requirement = "1.0.0",
|
119
|
+
File = "/project.csproj",
|
120
|
+
Groups = ["dependencies"],
|
121
|
+
}
|
122
|
+
],
|
123
|
+
},
|
124
|
+
],
|
125
|
+
UpdatedDependencyFiles = [
|
126
|
+
new()
|
127
|
+
{
|
128
|
+
Directory = "/",
|
129
|
+
Name = "project.csproj",
|
130
|
+
Content = """
|
131
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
132
|
+
<PropertyGroup>
|
133
|
+
<TargetFramework>net9.0</TargetFramework>
|
134
|
+
</PropertyGroup>
|
135
|
+
<ItemGroup>
|
136
|
+
<PackageReference Include="Some.Package" Version="2.0.0" />
|
137
|
+
</ItemGroup>
|
138
|
+
</Project>
|
139
|
+
"""
|
140
|
+
},
|
141
|
+
],
|
142
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
143
|
+
CommitMessage = RunWorkerTests.TestPullRequestCommitMessage,
|
144
|
+
PrTitle = RunWorkerTests.TestPullRequestTitle,
|
145
|
+
PrBody = RunWorkerTests.TestPullRequestBody,
|
146
|
+
DependencyGroup = null,
|
147
|
+
},
|
148
|
+
new MarkAsProcessed("TEST-COMMIT-SHA")
|
149
|
+
]
|
150
|
+
);
|
151
|
+
}
|
152
|
+
|
153
|
+
[Fact]
|
154
|
+
public async Task WithNewFileWriter_PackagesConfig()
|
155
|
+
{
|
156
|
+
await RunWorkerTests.RunAsync(
|
157
|
+
experimentsManager: new ExperimentsManager() { UseDirectDiscovery = true, UseNewFileUpdater = true },
|
158
|
+
packages: [
|
159
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net45"),
|
160
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net45"),
|
161
|
+
],
|
162
|
+
job: new()
|
163
|
+
{
|
164
|
+
Source = new()
|
165
|
+
{
|
166
|
+
Provider = "github",
|
167
|
+
Repo = "test/repo",
|
168
|
+
Directory = "/src",
|
169
|
+
}
|
170
|
+
},
|
171
|
+
files: [
|
172
|
+
("src/packages.config", """
|
173
|
+
<?xml version="1.0" encoding="utf-8"?>
|
174
|
+
<packages>
|
175
|
+
<package id="Some.Package" version="1.0.0" targetFramework="net45" />
|
176
|
+
</packages>
|
177
|
+
"""),
|
178
|
+
("src/project.csproj", """
|
179
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
180
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
181
|
+
<PropertyGroup>
|
182
|
+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
183
|
+
</PropertyGroup>
|
184
|
+
<ItemGroup>
|
185
|
+
<None Include="packages.config" />
|
186
|
+
</ItemGroup>
|
187
|
+
<ItemGroup>
|
188
|
+
<Reference Include="Some.Package">
|
189
|
+
<HintPath>packages\Some.Package.1.0.0\lib\net45\Some.Package.dll</HintPath>
|
190
|
+
<Private>True</Private>
|
191
|
+
</Reference>
|
192
|
+
</ItemGroup>
|
193
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
194
|
+
</Project>
|
195
|
+
"""),
|
196
|
+
// due to weirdness in the testing setup, we need to ensure sdk-style crawling doesn't escape
|
197
|
+
("Directory.Build.props", "<Project />"),
|
198
|
+
("Directory.Build.targets", "<Project />"),
|
199
|
+
("Directory.Packages.props", """
|
200
|
+
<Project>
|
201
|
+
<PropertyGroup>
|
202
|
+
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
|
203
|
+
</PropertyGroup>
|
204
|
+
</Project>
|
205
|
+
"""),
|
206
|
+
],
|
207
|
+
discoveryWorker: null, // use real worker
|
208
|
+
analyzeWorker: null, // use real worker
|
209
|
+
updaterWorker: null, // use real worker
|
210
|
+
expectedResult: new()
|
211
|
+
{
|
212
|
+
Base64DependencyFiles = [],
|
213
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
214
|
+
},
|
215
|
+
expectedApiMessages: [
|
216
|
+
new IncrementMetric()
|
217
|
+
{
|
218
|
+
Metric = "updater.started",
|
219
|
+
Tags = new()
|
220
|
+
{
|
221
|
+
["operation"] = "group_update_all_versions"
|
222
|
+
}
|
223
|
+
},
|
224
|
+
new UpdatedDependencyList()
|
225
|
+
{
|
226
|
+
Dependencies = [
|
227
|
+
new()
|
228
|
+
{
|
229
|
+
Name = "Some.Package",
|
230
|
+
Version = "1.0.0",
|
231
|
+
Requirements = [
|
232
|
+
new()
|
233
|
+
{
|
234
|
+
Requirement = "1.0.0",
|
235
|
+
File = "/src/project.csproj",
|
236
|
+
Groups = ["dependencies"],
|
237
|
+
}
|
238
|
+
]
|
239
|
+
},
|
240
|
+
],
|
241
|
+
DependencyFiles = [
|
242
|
+
"/src/packages.config",
|
243
|
+
"/src/project.csproj",
|
244
|
+
],
|
245
|
+
},
|
246
|
+
new CreatePullRequest()
|
247
|
+
{
|
248
|
+
Dependencies = [
|
249
|
+
new()
|
250
|
+
{
|
251
|
+
Name = "Some.Package",
|
252
|
+
Version = "2.0.0",
|
253
|
+
Requirements = [
|
254
|
+
new()
|
255
|
+
{
|
256
|
+
Requirement = "2.0.0",
|
257
|
+
File = "/src/project.csproj",
|
258
|
+
Groups = ["dependencies"],
|
259
|
+
Source = new()
|
260
|
+
{
|
261
|
+
SourceUrl = null,
|
262
|
+
Type = "nuget_repo",
|
263
|
+
}
|
264
|
+
}
|
265
|
+
],
|
266
|
+
PreviousVersion = "1.0.0",
|
267
|
+
PreviousRequirements = [
|
268
|
+
new()
|
269
|
+
{
|
270
|
+
Requirement = "1.0.0",
|
271
|
+
File = "/src/project.csproj",
|
272
|
+
Groups = ["dependencies"],
|
273
|
+
}
|
274
|
+
],
|
275
|
+
},
|
276
|
+
],
|
277
|
+
UpdatedDependencyFiles = [
|
278
|
+
new()
|
279
|
+
{
|
280
|
+
Directory = "/src",
|
281
|
+
Name = "packages.config",
|
282
|
+
Content = """
|
283
|
+
<?xml version="1.0" encoding="utf-8"?>
|
284
|
+
<packages>
|
285
|
+
<package id="Some.Package" version="2.0.0" targetFramework="net45" />
|
286
|
+
</packages>
|
287
|
+
"""
|
288
|
+
},
|
289
|
+
new()
|
290
|
+
{
|
291
|
+
Directory = "/src",
|
292
|
+
Name = "project.csproj",
|
293
|
+
Content = """
|
294
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
295
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
296
|
+
<PropertyGroup>
|
297
|
+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
298
|
+
</PropertyGroup>
|
299
|
+
<ItemGroup>
|
300
|
+
<None Include="packages.config" />
|
301
|
+
</ItemGroup>
|
302
|
+
<ItemGroup>
|
303
|
+
<Reference Include="Some.Package">
|
304
|
+
<HintPath>packages\Some.Package.2.0.0\lib\net45\Some.Package.dll</HintPath>
|
305
|
+
<Private>True</Private>
|
306
|
+
</Reference>
|
307
|
+
</ItemGroup>
|
308
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
309
|
+
</Project>
|
310
|
+
"""
|
311
|
+
},
|
312
|
+
],
|
313
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
314
|
+
CommitMessage = RunWorkerTests.TestPullRequestCommitMessage,
|
315
|
+
PrTitle = RunWorkerTests.TestPullRequestTitle,
|
316
|
+
PrBody = RunWorkerTests.TestPullRequestBody,
|
317
|
+
DependencyGroup = null,
|
318
|
+
},
|
319
|
+
new MarkAsProcessed("TEST-COMMIT-SHA")
|
320
|
+
]
|
321
|
+
);
|
322
|
+
}
|
323
|
+
|
324
|
+
[Fact]
|
325
|
+
public async Task WithNewFileWriter_LegacyProject_With_PackageReference()
|
326
|
+
{
|
327
|
+
var experimentsManager = new ExperimentsManager() { UseDirectDiscovery = true, UseNewFileUpdater = true };
|
328
|
+
await RunWorkerTests.RunAsync(
|
329
|
+
experimentsManager: experimentsManager,
|
330
|
+
packages: [
|
331
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "net45"),
|
332
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "net45"),
|
333
|
+
],
|
334
|
+
job: new()
|
335
|
+
{
|
336
|
+
Source = new()
|
337
|
+
{
|
338
|
+
Provider = "github",
|
339
|
+
Repo = "test/repo",
|
340
|
+
Directory = "/",
|
341
|
+
}
|
342
|
+
},
|
343
|
+
files: [
|
344
|
+
("Directory.Build.props", "<Project />"),
|
345
|
+
("Directory.Build.targets", "<Project />"),
|
346
|
+
("Directory.Packages.props", """
|
347
|
+
<Project>
|
348
|
+
<PropertyGroup>
|
349
|
+
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
|
350
|
+
</PropertyGroup>
|
351
|
+
</Project>
|
352
|
+
"""),
|
353
|
+
("project.csproj", """
|
354
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
355
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
356
|
+
<PropertyGroup>
|
357
|
+
<OutputType>Library</OutputType>
|
358
|
+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
359
|
+
</PropertyGroup>
|
360
|
+
<ItemGroup>
|
361
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
362
|
+
</ItemGroup>
|
363
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
364
|
+
</Project>
|
365
|
+
"""),
|
366
|
+
],
|
367
|
+
discoveryWorker: new TestDiscoveryWorker(async args =>
|
368
|
+
{
|
369
|
+
// wrap real worker, but remove ref assemblies package to make testing more deterministic
|
370
|
+
var (repoRootPath, workspacePath) = args;
|
371
|
+
var worker = new DiscoveryWorker("TEST-JOB-ID", experimentsManager, new TestLogger());
|
372
|
+
var discoveryResult = await worker.RunAsync(repoRootPath, workspacePath);
|
373
|
+
return new()
|
374
|
+
{
|
375
|
+
DotNetToolsJson = discoveryResult.DotNetToolsJson,
|
376
|
+
Error = discoveryResult.Error,
|
377
|
+
GlobalJson = discoveryResult.GlobalJson,
|
378
|
+
IsSuccess = discoveryResult.IsSuccess,
|
379
|
+
Path = discoveryResult.Path,
|
380
|
+
Projects = discoveryResult.Projects.Select(p => new ProjectDiscoveryResult()
|
381
|
+
{
|
382
|
+
AdditionalFiles = p.AdditionalFiles,
|
383
|
+
Dependencies = [.. p.Dependencies.Where(d => d.Name != "Microsoft.NETFramework.ReferenceAssemblies")],
|
384
|
+
Error = p.Error,
|
385
|
+
FilePath = p.FilePath,
|
386
|
+
ImportedFiles = p.ImportedFiles,
|
387
|
+
IsSuccess = p.IsSuccess,
|
388
|
+
Properties = p.Properties,
|
389
|
+
ReferencedProjectPaths = p.ReferencedProjectPaths,
|
390
|
+
TargetFrameworks = p.TargetFrameworks,
|
391
|
+
}).ToImmutableArray()
|
392
|
+
};
|
393
|
+
}),
|
394
|
+
analyzeWorker: null, // use real worker
|
395
|
+
updaterWorker: null, // use real worker
|
396
|
+
expectedResult: new()
|
397
|
+
{
|
398
|
+
Base64DependencyFiles = [],
|
399
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
400
|
+
},
|
401
|
+
expectedApiMessages: [
|
402
|
+
new IncrementMetric()
|
403
|
+
{
|
404
|
+
Metric = "updater.started",
|
405
|
+
Tags = new()
|
406
|
+
{
|
407
|
+
["operation"] = "group_update_all_versions"
|
408
|
+
}
|
409
|
+
},
|
410
|
+
new UpdatedDependencyList()
|
411
|
+
{
|
412
|
+
Dependencies = [
|
413
|
+
new()
|
414
|
+
{
|
415
|
+
Name = "Some.Package",
|
416
|
+
Version = "1.0.0",
|
417
|
+
Requirements = [
|
418
|
+
new()
|
419
|
+
{
|
420
|
+
Requirement = "1.0.0",
|
421
|
+
File = "/project.csproj",
|
422
|
+
Groups = ["dependencies"],
|
423
|
+
}
|
424
|
+
]
|
425
|
+
},
|
426
|
+
],
|
427
|
+
DependencyFiles = [
|
428
|
+
"/Directory.Build.props",
|
429
|
+
"/Directory.Build.targets",
|
430
|
+
"/Directory.Packages.props",
|
431
|
+
"/project.csproj",
|
432
|
+
],
|
433
|
+
},
|
434
|
+
new CreatePullRequest()
|
435
|
+
{
|
436
|
+
Dependencies = [
|
437
|
+
new()
|
438
|
+
{
|
439
|
+
Name = "Some.Package",
|
440
|
+
Version = "2.0.0",
|
441
|
+
Requirements = [
|
442
|
+
new()
|
443
|
+
{
|
444
|
+
Requirement = "2.0.0",
|
445
|
+
File = "/project.csproj",
|
446
|
+
Groups = ["dependencies"],
|
447
|
+
Source = new()
|
448
|
+
{
|
449
|
+
SourceUrl = null,
|
450
|
+
Type = "nuget_repo",
|
451
|
+
}
|
452
|
+
}
|
453
|
+
],
|
454
|
+
PreviousVersion = "1.0.0",
|
455
|
+
PreviousRequirements = [
|
456
|
+
new()
|
457
|
+
{
|
458
|
+
Requirement = "1.0.0",
|
459
|
+
File = "/project.csproj",
|
460
|
+
Groups = ["dependencies"],
|
461
|
+
}
|
462
|
+
],
|
463
|
+
},
|
464
|
+
],
|
465
|
+
UpdatedDependencyFiles = [
|
466
|
+
new()
|
467
|
+
{
|
468
|
+
Directory = "/",
|
469
|
+
Name = "project.csproj",
|
470
|
+
Content = """
|
471
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
472
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
473
|
+
<PropertyGroup>
|
474
|
+
<OutputType>Library</OutputType>
|
475
|
+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
476
|
+
</PropertyGroup>
|
477
|
+
<ItemGroup>
|
478
|
+
<PackageReference Include="Some.Package" Version="2.0.0" />
|
479
|
+
</ItemGroup>
|
480
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
481
|
+
</Project>
|
482
|
+
"""
|
483
|
+
},
|
484
|
+
],
|
485
|
+
BaseCommitSha = "TEST-COMMIT-SHA",
|
486
|
+
CommitMessage = RunWorkerTests.TestPullRequestCommitMessage,
|
487
|
+
PrTitle = RunWorkerTests.TestPullRequestTitle,
|
488
|
+
PrBody = RunWorkerTests.TestPullRequestBody,
|
489
|
+
DependencyGroup = null,
|
490
|
+
},
|
491
|
+
new MarkAsProcessed("TEST-COMMIT-SHA")
|
492
|
+
]
|
493
|
+
);
|
494
|
+
}
|
495
|
+
|
12
496
|
[Theory]
|
13
497
|
[InlineData(true)]
|
14
498
|
[InlineData(false)]
|
@@ -149,6 +149,7 @@ public class HttpApiHandlerTests
|
|
149
149
|
yield return [new JobRepoNotFound("unused"), "record_update_job_error"];
|
150
150
|
yield return [new PrivateSourceAuthenticationFailure(["unused"]), "record_update_job_error"];
|
151
151
|
yield return [new PrivateSourceBadResponse(["unused"]), "record_update_job_error"];
|
152
|
+
yield return [new PrivateSourceTimedOut("unused"), "record_update_job_error"];
|
152
153
|
yield return [new PullRequestExistsForLatestVersion("unused", "unused"), "record_update_job_error"];
|
153
154
|
yield return [new PullRequestExistsForSecurityUpdate([]), "record_update_job_error"];
|
154
155
|
yield return [new SecurityUpdateDependencyNotFound(), "record_update_job_error"];
|
@@ -61,6 +61,13 @@ public class JobErrorBaseTests : TestBase
|
|
61
61
|
new PrivateSourceBadResponse(["http://nuget.example.com/v3/index.json"]),
|
62
62
|
];
|
63
63
|
|
64
|
+
// service returned corrupt package
|
65
|
+
yield return
|
66
|
+
[
|
67
|
+
new InvalidDataException("Central Directory corrupt."),
|
68
|
+
new PrivateSourceBadResponse(["http://nuget.example.com/v3/index.json"]),
|
69
|
+
];
|
70
|
+
|
64
71
|
// top-level exception turns into private_source_authentication_failure
|
65
72
|
yield return
|
66
73
|
[
|
@@ -160,6 +160,17 @@ public class MessageReportTests
|
|
160
160
|
"""
|
161
161
|
];
|
162
162
|
|
163
|
+
yield return
|
164
|
+
[
|
165
|
+
// message
|
166
|
+
new PrivateSourceTimedOut("url"),
|
167
|
+
// expected
|
168
|
+
"""
|
169
|
+
Error type: private_source_timed_out
|
170
|
+
- source: url
|
171
|
+
"""
|
172
|
+
];
|
173
|
+
|
163
174
|
yield return
|
164
175
|
[
|
165
176
|
// message
|