dependabot-nuget 0.404.0 → 0.405.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/NuGetUpdater.Core/Analyze/CompatibilityChecker.cs +4 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +66 -70
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/CompatibilityCheckerTests.cs +30 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +6 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +45 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/EndToEndTests.cs +121 -0
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 76d0ffdd404ccec8cee7288d554cfebc99b40acfcdb59b2bf908e454615bd4cc
|
|
4
|
+
data.tar.gz: 8c8bb04b41d766298a5ecc5ed3cc5d8b24fb83d60f1d6fbd47126514d97398bf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e2f8579eb9d66ace7164fdf4d9495824ba5ef025b9db46c4195c094af634b5c959fa92b0153190faec63679a0dc57115ac33eb84c2568ee99e1bcdc4fa2f2f26
|
|
7
|
+
data.tar.gz: e970e586e84299e5b607a9f9cfbfae23cb188b7a89b7bd7bffe44330bb974fa9e309ad75f84cb5e612b4d9e950f95b913d982b660532293994cdd3c96467a542
|
|
@@ -137,7 +137,10 @@ internal static class CompatibilityChecker
|
|
|
137
137
|
return true;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
var incompatibleFrameworks = projectFrameworks.Where(
|
|
140
|
+
var incompatibleFrameworks = projectFrameworks.Where(projectFramework =>
|
|
141
|
+
!compatibleFrameworks.Contains(projectFramework)
|
|
142
|
+
&& !packageFrameworks.Any(packageFramework =>
|
|
143
|
+
DefaultCompatibilityProvider.Instance.IsCompatible(projectFramework, packageFramework))).ToArray();
|
|
141
144
|
if (incompatibleFrameworks.Length > 0)
|
|
142
145
|
{
|
|
143
146
|
logger.Info($"The package {package} is not compatible. Incompatible project frameworks: {string.Join(", ", incompatibleFrameworks.Select(f => f.GetShortFolderName()))}");
|
|
@@ -54,24 +54,20 @@ internal static class SdkProjectDiscovery
|
|
|
54
54
|
"web.config",
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
private static readonly ImmutableArray<string> SingleRestoreTargetNames =
|
|
57
|
+
private static readonly ImmutableArray<string> DiscoveryTargetNames =
|
|
59
58
|
[
|
|
60
|
-
"Restore",
|
|
61
59
|
"ResolveProjectReferences",
|
|
62
60
|
"GenerateBuildDependencyFile"
|
|
63
61
|
];
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
private static readonly ImmutableArray<string> LegacyProjectSingleRestoreTargetNames = ["ResolveProjectReferences"];
|
|
63
|
+
private static readonly ImmutableArray<string> LegacyProjectDiscoveryTargetNames = ["ResolveProjectReferences"];
|
|
67
64
|
|
|
68
65
|
private const string TargetFrameworksPropertyName = "TargetFrameworks";
|
|
69
66
|
|
|
70
67
|
// this property evaluates to a version number in an SDK-style project and is unset or empty otherwise
|
|
71
68
|
private const string NETCoreSdkVersionPropertyName = "NETCoreSdkVersion";
|
|
72
69
|
|
|
73
|
-
|
|
74
|
-
private const int MaximumParallelTargetFrameworkRestores = 2;
|
|
70
|
+
private const int MaximumParallelTargetFrameworkEvaluations = 2;
|
|
75
71
|
|
|
76
72
|
public static async Task<ImmutableArray<ProjectDiscoveryResult>> DiscoverAsync(string repoRootPath, string workspacePath, string startingProjectPath, ExperimentsManager experimentsManager, string? solutionDir, ILogger logger)
|
|
77
73
|
{
|
|
@@ -130,51 +126,84 @@ internal static class SdkProjectDiscovery
|
|
|
130
126
|
var netCoreSdkVersionValue = startingProjectProperties?.GetValueOrDefault(NETCoreSdkVersionPropertyName);
|
|
131
127
|
var isLegacyProject = string.IsNullOrEmpty(netCoreSdkVersionValue);
|
|
132
128
|
var requiredTargets = isLegacyProject
|
|
133
|
-
?
|
|
134
|
-
:
|
|
129
|
+
? LegacyProjectDiscoveryTargetNames
|
|
130
|
+
: DiscoveryTargetNames;
|
|
135
131
|
|
|
136
132
|
// due to how MSBuild handles multi-TFM projects with target platforms we may need to process each TFM separately
|
|
137
133
|
// we detect that by determining if there are multiple target frameworks specified and if any of them have a platform suffix (e.g., `-windows`, `-android`, etc)
|
|
138
134
|
// alternately, if there are too many target frameworks specified, they must be handled individually
|
|
139
135
|
var hasPlatformTfms = projectTfms.Any(tfm => tfm.Contains('-'));
|
|
140
|
-
var
|
|
141
|
-
var
|
|
142
|
-
if (!
|
|
136
|
+
var requiresIndividualEvaluations = hasPlatformTfms || projectTfms.Length > MaximumParallelTargetFrameworkEvaluations;
|
|
137
|
+
var useDirectEvaluation = requiresIndividualEvaluations;
|
|
138
|
+
if (!requiresIndividualEvaluations)
|
|
143
139
|
{
|
|
144
|
-
logger.Info($"Performing single
|
|
145
|
-
projectTfms = [string.Empty]; //
|
|
140
|
+
logger.Info($"Performing single evaluation for project {startingProjectPath}");
|
|
141
|
+
projectTfms = [string.Empty]; // an empty TFM lets the outer build evaluate all target frameworks
|
|
146
142
|
var actualTargets = await MSBuildHelper.GetProjectTargetsAsync(startingProjectPath, logger);
|
|
147
|
-
|
|
143
|
+
useDirectEvaluation = requiredTargets.All(actualTargets.Contains);
|
|
148
144
|
}
|
|
149
145
|
else
|
|
150
146
|
{
|
|
151
|
-
logger.Info($"Performing individual
|
|
147
|
+
logger.Info($"Performing individual evaluations for project {startingProjectPath} using target frameworks {string.Join(", ", projectTfms)}");
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
var commonArgs = new List<string>() { startingProjectPath };
|
|
151
|
+
commonArgs.Add($"/p:ProjectReferenceBuildTargets=\"{string.Join(";", requiredTargets)}\"");
|
|
152
|
+
var dependencyDiscoveryTargetingPacksPropsPath = MSBuildHelper.GetFileFromRuntimeDirectory("DependencyDiscoveryTargetingPacks.props");
|
|
153
|
+
var dependencyDiscoveryTargetsPath = MSBuildHelper.GetFileFromRuntimeDirectory("DependencyDiscovery.targets");
|
|
154
|
+
commonArgs.Add($"/p:CustomBeforeMicrosoftCommonProps={dependencyDiscoveryTargetingPacksPropsPath}");
|
|
155
|
+
commonArgs.Add($"/p:CustomAfterMicrosoftCommonCrossTargetingTargets={dependencyDiscoveryTargetsPath}");
|
|
156
|
+
commonArgs.Add($"/p:CustomAfterMicrosoftCommonTargets={dependencyDiscoveryTargetsPath}");
|
|
157
|
+
if (solutionDir is not null)
|
|
158
|
+
{
|
|
159
|
+
var normalizedSolutionDir = $"{solutionDir.TrimEnd('/', Path.DirectorySeparatorChar)}/";
|
|
160
|
+
commonArgs.Add($"/p:SolutionDir={normalizedSolutionDir}");
|
|
161
|
+
}
|
|
162
|
+
commonArgs.Add("/p:TreatWarningsAsErrors=false");
|
|
163
|
+
commonArgs.Add("/p:MSBuildTreatWarningsAsErrors=false");
|
|
164
|
+
|
|
165
|
+
async Task<(int ExitCode, string Output, string Error)> RunMSBuildAsync(List<string> args)
|
|
166
|
+
{
|
|
167
|
+
var result = await ProcessEx.RunDotnetMSBuildSafelyAsync(args, startingProjectDirectory);
|
|
168
|
+
if (result.ExitCode != 0 && result.Output.Contains("error : Object reference not set to an instance of an object."))
|
|
169
|
+
{
|
|
170
|
+
// https://github.com/NuGet/Home/issues/11761#issuecomment-1105218996
|
|
171
|
+
args.Add("/RestoreProperty:__Unused__=__Unused__");
|
|
172
|
+
result = await ProcessEx.RunDotnetMSBuildSafelyAsync(args, startingProjectDirectory);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
MSBuildHelper.ThrowOnError(result.Output);
|
|
176
|
+
MSBuildHelper.ThrowOnError(result.Error);
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (!isLegacyProject)
|
|
181
|
+
{
|
|
182
|
+
// Restore the graph before inner builds introduce a TargetFramework global property.
|
|
183
|
+
var (exitCode, stdOut, stdErr) = await RunMSBuildAsync([.. commonArgs, "/t:Restore"]);
|
|
184
|
+
if (exitCode != 0)
|
|
185
|
+
{
|
|
186
|
+
logger.Warn($"Error restoring dependencies.\nSTDOUT:\n{stdOut}\nSTDERR:\n{stdErr}");
|
|
187
|
+
if (stdErr.Contains("A compatible .NET SDK was not found."))
|
|
188
|
+
{
|
|
189
|
+
throw new Exception("Missing SDK, check global.json locations vs. job directories.");
|
|
190
|
+
}
|
|
191
|
+
}
|
|
152
192
|
}
|
|
153
193
|
|
|
154
194
|
foreach (var tfm in projectTfms)
|
|
155
195
|
{
|
|
156
|
-
var
|
|
196
|
+
var isIndividualTfmEvaluation = !string.IsNullOrEmpty(tfm);
|
|
157
197
|
|
|
158
198
|
// create a binlog
|
|
159
199
|
var binLogPath = Path.Combine(Path.GetTempPath(), $"msbuild_{Guid.NewGuid():d}.binlog");
|
|
160
200
|
try
|
|
161
201
|
{
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
//
|
|
166
|
-
|
|
167
|
-
// For SDK-style projects the targets `Restore`, `ResolveProjectReferences`, and `GenerateBuildDependencyFile`
|
|
168
|
-
// are necessary. If the project has a single target framework, those magic targets will all be present and can
|
|
169
|
-
// be directly invoked, but if the project has multiple target frameworks, those targets will _NOT_ be directly
|
|
170
|
-
// present and we instead have to invoke the `Build` target and specify the three magic values as `InnerTargets`.
|
|
171
|
-
|
|
172
|
-
// If the project is legacy then those three magic targets will not be present, but we shouldn't use the `Build`
|
|
173
|
-
// and `InnerTargets` trick because that's an SDK-only mechanism, so we instead only need to invoke
|
|
174
|
-
// `ResolveProjectReferences` to gather all `PackageReference` items and further down we re-build the transitive
|
|
175
|
-
// dependency set. Without the legacy project check, we could incorrectly invoke `Build` which eventually tries
|
|
176
|
-
// to call `csc.exe` which is unnecessary and can be slow.
|
|
177
|
-
if (useDirectRestore)
|
|
202
|
+
var args = new List<string>(commonArgs);
|
|
203
|
+
|
|
204
|
+
// Cross-targeting SDK builds dispatch discovery targets through InnerTargets.
|
|
205
|
+
// Legacy projects must invoke their targets directly to avoid compiling them.
|
|
206
|
+
if (useDirectEvaluation)
|
|
178
207
|
{
|
|
179
208
|
// directly call the required targets
|
|
180
209
|
args.Add($"/t:{string.Join(",", requiredTargets)}");
|
|
@@ -186,48 +215,14 @@ internal static class SdkProjectDiscovery
|
|
|
186
215
|
args.Add($"/p:InnerTargets=\"{string.Join(";", requiredTargets)}\"");
|
|
187
216
|
}
|
|
188
217
|
|
|
189
|
-
|
|
190
|
-
args.Add($"/p:ProjectReferenceBuildTargets=\"{string.Join(";", requiredTargets)}\"");
|
|
191
|
-
|
|
192
|
-
// inject various props and targets to help with discovery
|
|
193
|
-
var dependencyDiscoveryTargetingPacksPropsPath = MSBuildHelper.GetFileFromRuntimeDirectory("DependencyDiscoveryTargetingPacks.props");
|
|
194
|
-
var dependencyDiscoveryTargetsPath = MSBuildHelper.GetFileFromRuntimeDirectory("DependencyDiscovery.targets");
|
|
195
|
-
args.Add($"/p:CustomBeforeMicrosoftCommonProps={dependencyDiscoveryTargetingPacksPropsPath}");
|
|
196
|
-
args.Add($"/p:CustomAfterMicrosoftCommonCrossTargetingTargets={dependencyDiscoveryTargetsPath}");
|
|
197
|
-
args.Add($"/p:CustomAfterMicrosoftCommonTargets={dependencyDiscoveryTargetsPath}");
|
|
198
|
-
|
|
199
|
-
if (isIndividualTfmRestore)
|
|
218
|
+
if (isIndividualTfmEvaluation)
|
|
200
219
|
{
|
|
201
220
|
args.Add($"/p:TargetFramework={tfm}");
|
|
202
221
|
}
|
|
203
222
|
|
|
204
|
-
// if the project lives alongside a solution file, fake the MSBuild `SolutionDir` property so that
|
|
205
|
-
// project files referencing `$(SolutionDir)` can be evaluated correctly; MSBuild expects this value
|
|
206
|
-
// to end with a directory separator so that `$(SolutionDir)foo` concatenations form valid paths
|
|
207
|
-
if (solutionDir is not null)
|
|
208
|
-
{
|
|
209
|
-
var normalizedSolutionDir = $"{solutionDir.TrimEnd('/', Path.DirectorySeparatorChar)}/";
|
|
210
|
-
args.Add($"/p:SolutionDir={normalizedSolutionDir}");
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// if using CPM and a project also sets TreatWarningsAsErrors to true, this can cause discovery to fail; explicitly don't allow that
|
|
214
|
-
args.Add("/p:TreatWarningsAsErrors=false");
|
|
215
|
-
args.Add("/p:MSBuildTreatWarningsAsErrors=false");
|
|
216
223
|
args.Add($"/bl:{binLogPath}");
|
|
217
224
|
|
|
218
|
-
var (exitCode, stdOut, stdErr) = await
|
|
219
|
-
if (exitCode != 0 && stdOut.Contains("error : Object reference not set to an instance of an object."))
|
|
220
|
-
{
|
|
221
|
-
// https://github.com/NuGet/Home/issues/11761#issuecomment-1105218996
|
|
222
|
-
// Due to a bug in NuGet, there can be a null reference exception thrown and adding this command line argument will work around it,
|
|
223
|
-
// but this argument can't always be added; it can cause problems in other instances, so we're taking the approach of not using it
|
|
224
|
-
// unless we have to.
|
|
225
|
-
args.Add("/RestoreProperty:__Unused__=__Unused__");
|
|
226
|
-
(exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetMSBuildSafelyAsync(args, startingProjectDirectory);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
MSBuildHelper.ThrowOnError(stdOut);
|
|
230
|
-
MSBuildHelper.ThrowOnError(stdErr);
|
|
225
|
+
var (exitCode, stdOut, stdErr) = await RunMSBuildAsync(args);
|
|
231
226
|
if (exitCode != 0)
|
|
232
227
|
{
|
|
233
228
|
// log error, but still try to resolve what we can
|
|
@@ -547,7 +542,8 @@ internal static class SdkProjectDiscovery
|
|
|
547
542
|
{
|
|
548
543
|
if (!File.Exists(assetsFilePath))
|
|
549
544
|
{
|
|
550
|
-
|
|
545
|
+
// A failed restore can leave no assets; retain dependencies discovered from the build.
|
|
546
|
+
return null;
|
|
551
547
|
}
|
|
552
548
|
|
|
553
549
|
var assetsContent = File.ReadAllText(assetsFilePath);
|
|
@@ -211,6 +211,36 @@ public class CompatibilityCheckerTests
|
|
|
211
211
|
Assert.True(isCompatible);
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
[Theory]
|
|
215
|
+
[InlineData("net10.0-windows", "net10.0", true)]
|
|
216
|
+
[InlineData("net10.0-windows7.0", "net10.0", true)]
|
|
217
|
+
[InlineData("net10.0-windows10.0.19041", "net10.0", true)]
|
|
218
|
+
[InlineData("net10.0-ios18.0", "net10.0", true)]
|
|
219
|
+
[InlineData("net10.0-windows10.0.19041", "net10.0-windows10.0.17763", true)]
|
|
220
|
+
[InlineData("net10.0-windows10.0.17763", "net10.0-windows10.0.19041", false)]
|
|
221
|
+
[InlineData("net10.0", "net10.0-windows", false)]
|
|
222
|
+
[InlineData("net10.0-windows", "net11.0", false)]
|
|
223
|
+
public async Task CheckAsync_PackageWithLibAssembly_ChecksPlatformCompatibility(
|
|
224
|
+
string projectTfm,
|
|
225
|
+
string packageTfm,
|
|
226
|
+
bool expectedCompatible)
|
|
227
|
+
{
|
|
228
|
+
using var tempDir = new TemporaryDirectory();
|
|
229
|
+
var package = MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", packageTfm);
|
|
230
|
+
await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([package], tempDir.DirectoryPath, includeCommonPackages: false);
|
|
231
|
+
var packageId = new PackageIdentity(package.Id, NuGetVersion.Parse(package.Version));
|
|
232
|
+
using var context = new NuGetContext(tempDir.DirectoryPath, NuGet.Common.NullLogger.Instance);
|
|
233
|
+
|
|
234
|
+
var isCompatible = await CompatibilityChecker.CheckAsync(
|
|
235
|
+
packageId,
|
|
236
|
+
[NuGetFramework.Parse(projectTfm)],
|
|
237
|
+
context,
|
|
238
|
+
new TestLogger(),
|
|
239
|
+
TestContext.Current.CancellationToken);
|
|
240
|
+
|
|
241
|
+
Assert.Equal(expectedCompatible, isCompatible);
|
|
242
|
+
}
|
|
243
|
+
|
|
214
244
|
[Fact]
|
|
215
245
|
public async Task ExistsAndIsCompatibleAsync_ExistingPackageWithoutProjectFrameworks_ReportsAsCompatible()
|
|
216
246
|
{
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs
CHANGED
|
@@ -339,10 +339,15 @@ public partial class DiscoveryWorkerTests
|
|
|
339
339
|
FilePath = "myproj.csproj",
|
|
340
340
|
TargetFrameworks = ["net48"],
|
|
341
341
|
Dependencies = [
|
|
342
|
+
new("PackageOnlyCompatibleWithNet8", "2.0.0", DependencyType.PackageReference, TargetFrameworks: ["net48"]),
|
|
342
343
|
new("PackageReferencedThroughLegacyMechanism", "1.0.0", DependencyType.PackagesConfig, TargetFrameworks: ["net48"]),
|
|
343
344
|
],
|
|
344
345
|
ReferencedProjectPaths = [],
|
|
345
|
-
ImportedFiles = [
|
|
346
|
+
ImportedFiles = [
|
|
347
|
+
"../Directory.Build.props",
|
|
348
|
+
"../Directory.Build.targets",
|
|
349
|
+
"../Directory.Packages.props",
|
|
350
|
+
],
|
|
346
351
|
AdditionalFiles = [
|
|
347
352
|
"packages.config"
|
|
348
353
|
],
|
|
@@ -377,6 +377,51 @@ public class SdkProjectDiscoveryTests : DiscoveryWorkerTestBase
|
|
|
377
377
|
);
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
+
[Fact]
|
|
381
|
+
public async Task DiscoveryContinuesAfterPartialRestoreFailure()
|
|
382
|
+
{
|
|
383
|
+
using var testDirectory = await TemporaryDirectory.CreateWithContentsAsync(
|
|
384
|
+
("library.csproj", """
|
|
385
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
386
|
+
<PropertyGroup>
|
|
387
|
+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
|
|
388
|
+
</PropertyGroup>
|
|
389
|
+
<ItemGroup>
|
|
390
|
+
<PackageReference Include="Some.Dependency" Version="1.2.3" />
|
|
391
|
+
</ItemGroup>
|
|
392
|
+
</Project>
|
|
393
|
+
"""));
|
|
394
|
+
await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(
|
|
395
|
+
[
|
|
396
|
+
MockNuGetPackage.CreateSimplePackage("Some.Dependency", "1.2.3", "net9.0",
|
|
397
|
+
[(null, [("Transitive.Dependency", "4.5.6")])]),
|
|
398
|
+
MockNuGetPackage.CreateSimplePackage("Transitive.Dependency", "4.5.6", "net9.0"),
|
|
399
|
+
],
|
|
400
|
+
testDirectory.DirectoryPath);
|
|
401
|
+
var projectPath = Path.Combine(testDirectory.DirectoryPath, "library.csproj");
|
|
402
|
+
var (exitCode, output, _) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(
|
|
403
|
+
["restore", projectPath], testDirectory.DirectoryPath);
|
|
404
|
+
Assert.NotEqual(0, exitCode);
|
|
405
|
+
Assert.Contains("NU1202", output);
|
|
406
|
+
|
|
407
|
+
var projects = await SdkProjectDiscovery.DiscoverAsync(
|
|
408
|
+
testDirectory.DirectoryPath,
|
|
409
|
+
testDirectory.DirectoryPath,
|
|
410
|
+
projectPath,
|
|
411
|
+
new ExperimentsManager(),
|
|
412
|
+
solutionDir: null,
|
|
413
|
+
new TestLogger());
|
|
414
|
+
|
|
415
|
+
var project = Assert.Single(projects);
|
|
416
|
+
foreach (var tfm in new[] { "net9.0", "net10.0" })
|
|
417
|
+
{
|
|
418
|
+
Assert.Contains(project.Dependencies, d => d.Name == "Some.Dependency" &&
|
|
419
|
+
d.Version == "1.2.3" && d.TargetFrameworks?.Contains(tfm) == true && d.IsTopLevel);
|
|
420
|
+
Assert.Contains(project.Dependencies, d => d.Name == "Transitive.Dependency" &&
|
|
421
|
+
d.Version == "4.5.6" && d.TargetFrameworks?.Contains(tfm) == true && !d.IsTopLevel);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
380
425
|
[Fact]
|
|
381
426
|
public async Task DiscoveryIgnoresNetStandardLibrary()
|
|
382
427
|
{
|
|
@@ -1398,6 +1398,127 @@ public class EndToEndTests
|
|
|
1398
1398
|
Assert.Equal("2.1.0", resolvedInLibrary);
|
|
1399
1399
|
}
|
|
1400
1400
|
|
|
1401
|
+
[Theory]
|
|
1402
|
+
[InlineData("net8.0;net472", ".NETFramework,Version=v4.7.2", "net8.0")]
|
|
1403
|
+
[InlineData("net8.0;net9.0;net472", ".NETFramework,Version=v4.7.2", "net8.0", "net9.0")]
|
|
1404
|
+
public async Task LockFilesPreserveTargetFrameworksThroughProjectReferences(string clientTargetFrameworks, params string[] clientLockFileFrameworks)
|
|
1405
|
+
{
|
|
1406
|
+
using var tempDirectory = await TemporaryDirectory.CreateWithContentsAsync(
|
|
1407
|
+
("projects.slnx", """
|
|
1408
|
+
<Solution>
|
|
1409
|
+
<Project Path="src/client/client.csproj" />
|
|
1410
|
+
<Project Path="src/common/common.csproj" />
|
|
1411
|
+
</Solution>
|
|
1412
|
+
"""),
|
|
1413
|
+
("src/client/client.csproj", $"""
|
|
1414
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
1415
|
+
<PropertyGroup>
|
|
1416
|
+
<TargetFrameworks>{clientTargetFrameworks}</TargetFrameworks>
|
|
1417
|
+
</PropertyGroup>
|
|
1418
|
+
<ItemGroup>
|
|
1419
|
+
<PackageReference Include="Some.Package" Version="1.0.0" />
|
|
1420
|
+
<ProjectReference Include="..\common\common.csproj" />
|
|
1421
|
+
</ItemGroup>
|
|
1422
|
+
</Project>
|
|
1423
|
+
"""),
|
|
1424
|
+
("src/client/packages.lock.json", ""),
|
|
1425
|
+
("src/common/common.csproj", """
|
|
1426
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
1427
|
+
<PropertyGroup>
|
|
1428
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
|
1429
|
+
</PropertyGroup>
|
|
1430
|
+
<ItemGroup>
|
|
1431
|
+
<PackageReference Include="Common.Package" Version="1.0.0" />
|
|
1432
|
+
</ItemGroup>
|
|
1433
|
+
</Project>
|
|
1434
|
+
"""),
|
|
1435
|
+
("src/common/packages.lock.json", "")
|
|
1436
|
+
);
|
|
1437
|
+
var repoContentsPath = tempDirectory.DirectoryPath;
|
|
1438
|
+
await UpdateWorkerTestBase.MockNuGetPackagesInDirectory([
|
|
1439
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.0", "netstandard2.0"),
|
|
1440
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "2.0.0", "netstandard2.0"),
|
|
1441
|
+
MockNuGetPackage.CreateSimplePackage("Common.Package", "1.0.0", "netstandard2.0"),
|
|
1442
|
+
], repoContentsPath);
|
|
1443
|
+
var lockFiles = new[]
|
|
1444
|
+
{
|
|
1445
|
+
(Path: "src/common/packages.lock.json", Frameworks: new[] { ".NETStandard,Version=v2.0" }, Package: "Common.Package", UpdatedVersion: "1.0.0"),
|
|
1446
|
+
(Path: "src/client/packages.lock.json", Frameworks: clientLockFileFrameworks, Package: "Some.Package", UpdatedVersion: "2.0.0"),
|
|
1447
|
+
};
|
|
1448
|
+
var (exitCode, output, error) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(
|
|
1449
|
+
["restore", Path.Join(repoContentsPath, "src", "client", "client.csproj")],
|
|
1450
|
+
repoContentsPath);
|
|
1451
|
+
Assert.True(exitCode == 0, $"Initial restore failed.\n{output}\n{error}");
|
|
1452
|
+
foreach (var (path, frameworks, package, _) in lockFiles)
|
|
1453
|
+
{
|
|
1454
|
+
using var lockFile = JsonDocument.Parse(await File.ReadAllTextAsync(Path.Join(repoContentsPath, path), TestContext.Current.CancellationToken));
|
|
1455
|
+
var dependencies = lockFile.RootElement.GetProperty("dependencies");
|
|
1456
|
+
Assert.Equal(frameworks, dependencies.EnumerateObject().Select(p => p.Name).Order().ToArray());
|
|
1457
|
+
foreach (var framework in frameworks)
|
|
1458
|
+
{
|
|
1459
|
+
Assert.Equal("1.0.0", dependencies.GetProperty(framework).GetProperty(package).GetProperty("resolved").GetString());
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
await GitTestHelper.InitializeRepositoryAsync(repoContentsPath, [
|
|
1463
|
+
"projects.slnx",
|
|
1464
|
+
"src/client/client.csproj",
|
|
1465
|
+
"src/client/packages.lock.json",
|
|
1466
|
+
"src/common/common.csproj",
|
|
1467
|
+
"src/common/packages.lock.json",
|
|
1468
|
+
]);
|
|
1469
|
+
|
|
1470
|
+
var jobId = "TEST-JOB-ID";
|
|
1471
|
+
var experimentsManager = new ExperimentsManager();
|
|
1472
|
+
var logger = new TestLogger();
|
|
1473
|
+
var apiHandler = new TestApiHandler();
|
|
1474
|
+
var worker = new RunWorker(
|
|
1475
|
+
jobId,
|
|
1476
|
+
apiHandler,
|
|
1477
|
+
new DiscoveryWorker(jobId, experimentsManager, logger),
|
|
1478
|
+
new AnalyzeWorker(jobId, experimentsManager, logger),
|
|
1479
|
+
new UpdaterWorker(jobId, experimentsManager, logger),
|
|
1480
|
+
logger);
|
|
1481
|
+
var job = new Job()
|
|
1482
|
+
{
|
|
1483
|
+
Dependencies = ["Some.Package"],
|
|
1484
|
+
SecurityAdvisories = [
|
|
1485
|
+
new()
|
|
1486
|
+
{
|
|
1487
|
+
DependencyName = "Some.Package",
|
|
1488
|
+
AffectedVersions = [Requirement.Parse("= 1.0.0")],
|
|
1489
|
+
PatchedVersions = [Requirement.Parse(">= 2.0.0")],
|
|
1490
|
+
}
|
|
1491
|
+
],
|
|
1492
|
+
SecurityUpdatesOnly = true,
|
|
1493
|
+
Source = new()
|
|
1494
|
+
{
|
|
1495
|
+
Provider = "github",
|
|
1496
|
+
Repo = "test/repo",
|
|
1497
|
+
Directory = "/",
|
|
1498
|
+
}
|
|
1499
|
+
};
|
|
1500
|
+
|
|
1501
|
+
await worker.RunAsync(job, new DirectoryInfo(repoContentsPath), null, "TEST-COMMIT-SHA", experimentsManager);
|
|
1502
|
+
|
|
1503
|
+
Assert.Contains(apiHandler.ReceivedMessages, m => m.Type == typeof(CreatePullRequest));
|
|
1504
|
+
var createPr = (CreatePullRequest)apiHandler.ReceivedMessages.Single(m => m.Type == typeof(CreatePullRequest)).Object;
|
|
1505
|
+
var updatedFiles = createPr.UpdatedDependencyFiles.ToDictionary(df => Path.Join(df.Directory, df.Name).NormalizePathToUnix(), df => df.Content);
|
|
1506
|
+
Assert.Contains("/src/client/packages.lock.json", updatedFiles.Keys);
|
|
1507
|
+
foreach (var (path, frameworks, package, updatedVersion) in lockFiles)
|
|
1508
|
+
{
|
|
1509
|
+
var lockFileContent = updatedFiles.TryGetValue($"/{path}", out var updatedContent)
|
|
1510
|
+
? updatedContent
|
|
1511
|
+
: await File.ReadAllTextAsync(Path.Join(repoContentsPath, path), TestContext.Current.CancellationToken);
|
|
1512
|
+
using var lockFile = JsonDocument.Parse(lockFileContent);
|
|
1513
|
+
var dependencies = lockFile.RootElement.GetProperty("dependencies");
|
|
1514
|
+
Assert.Equal(frameworks, dependencies.EnumerateObject().Select(p => p.Name).Order().ToArray());
|
|
1515
|
+
foreach (var framework in frameworks)
|
|
1516
|
+
{
|
|
1517
|
+
Assert.Equal(updatedVersion, dependencies.GetProperty(framework).GetProperty(package).GetProperty("resolved").GetString());
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1401
1522
|
[Fact]
|
|
1402
1523
|
public async Task FindRootDirectory_ExpandsDirectoryThroughProjChain()
|
|
1403
1524
|
{
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dependabot-nuget
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.405.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dependabot
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.405.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 0.405.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: debug
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -592,7 +592,7 @@ licenses:
|
|
|
592
592
|
- MIT
|
|
593
593
|
metadata:
|
|
594
594
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
|
595
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
|
595
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.405.0
|
|
596
596
|
rdoc_options: []
|
|
597
597
|
require_paths:
|
|
598
598
|
- lib
|