dependabot-nuget 0.290.0 → 0.292.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 +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.Cli.Test/EntryPointTests.Update.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +14 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyFinder.cs +2 -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 +111 -17
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +2 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +19 -11
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ErrorType.cs +2 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +31 -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 +3 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +43 -18
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.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 +48 -17
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProcessExtensions.cs +45 -7
- 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/DiscoveryWorkerTests.cs +41 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +2 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/MockNuGetPackage.cs +2 -1
- 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 +277 -73
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/ProjectHelperTests.cs +65 -0
- data/helpers/lib/NuGetUpdater/global.json +1 -1
- data/lib/dependabot/nuget/file_fetcher.rb +1 -0
- data/lib/dependabot/nuget/file_parser.rb +90 -0
- data/lib/dependabot/nuget/language.rb +98 -0
- data/lib/dependabot/nuget/native_helpers.rb +25 -0
- data/lib/dependabot/nuget/package_manager.rb +51 -0
- metadata +12 -6
@@ -48,15 +48,15 @@ internal static class SdkProjectDiscovery
|
|
48
48
|
{
|
49
49
|
if (experimentsManager.UseDirectDiscovery)
|
50
50
|
{
|
51
|
-
return await DiscoverWithBinLogAsync(repoRootPath, workspacePath, startingProjectPath, logger);
|
51
|
+
return await DiscoverWithBinLogAsync(repoRootPath, workspacePath, startingProjectPath, experimentsManager, logger);
|
52
52
|
}
|
53
53
|
else
|
54
54
|
{
|
55
|
-
return await DiscoverWithTempProjectAsync(repoRootPath, workspacePath, startingProjectPath, logger);
|
55
|
+
return await DiscoverWithTempProjectAsync(repoRootPath, workspacePath, startingProjectPath, experimentsManager, logger);
|
56
56
|
}
|
57
57
|
}
|
58
58
|
|
59
|
-
public static async Task<ImmutableArray<ProjectDiscoveryResult>> DiscoverWithBinLogAsync(string repoRootPath, string workspacePath, string startingProjectPath, ILogger logger)
|
59
|
+
public static async Task<ImmutableArray<ProjectDiscoveryResult>> DiscoverWithBinLogAsync(string repoRootPath, string workspacePath, string startingProjectPath, ExperimentsManager experimentsManager, ILogger logger)
|
60
60
|
{
|
61
61
|
// N.b., there are many paths used in this function. The MSBuild binary log always reports fully qualified paths, so that's what will be used
|
62
62
|
// throughout until the very end when the appropriate kind of relative path is returned.
|
@@ -84,7 +84,7 @@ internal static class SdkProjectDiscovery
|
|
84
84
|
Dictionary<string, HashSet<string>> additionalFiles = new(PathComparer.Instance);
|
85
85
|
// projectPath, additionalFiles
|
86
86
|
|
87
|
-
var tfms = await MSBuildHelper.GetTargetFrameworkValuesFromProject(repoRootPath, startingProjectPath, logger);
|
87
|
+
var tfms = await MSBuildHelper.GetTargetFrameworkValuesFromProject(repoRootPath, startingProjectPath, experimentsManager, logger);
|
88
88
|
foreach (var tfm in tfms)
|
89
89
|
{
|
90
90
|
// create a binlog
|
@@ -92,7 +92,7 @@ internal static class SdkProjectDiscovery
|
|
92
92
|
try
|
93
93
|
{
|
94
94
|
// TODO: once the updater image has all relevant SDKs installed, we won't have to sideline global.json anymore
|
95
|
-
var (exitCode, stdOut, stdErr) = await MSBuildHelper.
|
95
|
+
var (exitCode, stdOut, stdErr) = await MSBuildHelper.HandleGlobalJsonAsync(startingProjectDirectory, repoRootPath, experimentsManager, async () =>
|
96
96
|
{
|
97
97
|
// the built-in target `GenerateBuildDependencyFile` forces resolution of all NuGet packages, but doesn't invoke a full build
|
98
98
|
var dependencyDiscoveryTargetsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "DependencyDiscovery.targets");
|
@@ -102,10 +102,11 @@ internal static class SdkProjectDiscovery
|
|
102
102
|
startingProjectPath,
|
103
103
|
"/t:_DiscoverDependencies",
|
104
104
|
$"/p:TargetFramework={tfm}",
|
105
|
-
$"/p:CustomAfterMicrosoftCommonCrossTargetingTargets={dependencyDiscoveryTargetsPath}
|
105
|
+
$"/p:CustomAfterMicrosoftCommonCrossTargetingTargets={dependencyDiscoveryTargetsPath}",
|
106
|
+
$"/p:CustomAfterMicrosoftCommonTargets={dependencyDiscoveryTargetsPath}",
|
106
107
|
$"/bl:{binLogPath}"
|
107
108
|
};
|
108
|
-
var (exitCode, stdOut, stdErr) = await ProcessEx.
|
109
|
+
var (exitCode, stdOut, stdErr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(args, startingProjectDirectory, experimentsManager);
|
109
110
|
return (exitCode, stdOut, stdErr);
|
110
111
|
}, logger, retainMSBuildSdks: true);
|
111
112
|
MSBuildHelper.ThrowOnUnauthenticatedFeed(stdOut);
|
@@ -411,7 +412,7 @@ internal static class SdkProjectDiscovery
|
|
411
412
|
return property.Value;
|
412
413
|
}
|
413
414
|
|
414
|
-
public static async Task<ImmutableArray<ProjectDiscoveryResult>> DiscoverWithTempProjectAsync(string repoRootPath, string workspacePath, string projectPath, ILogger logger)
|
415
|
+
public static async Task<ImmutableArray<ProjectDiscoveryResult>> DiscoverWithTempProjectAsync(string repoRootPath, string workspacePath, string projectPath, ExperimentsManager experimentsManager, ILogger logger)
|
415
416
|
{
|
416
417
|
// Determine which targets and props files contribute to the build.
|
417
418
|
var (buildFiles, projectTargetFrameworks) = await MSBuildHelper.LoadBuildFilesAndTargetFrameworksAsync(repoRootPath, projectPath);
|
@@ -476,7 +477,7 @@ internal static class SdkProjectDiscovery
|
|
476
477
|
dependencies = dependencies
|
477
478
|
.Select(d => d with { TargetFrameworks = tfms })
|
478
479
|
.ToImmutableArray();
|
479
|
-
var transitiveDependencies = await GetTransitiveDependencies(repoRootPath, projectPath, tfms, dependencies, logger);
|
480
|
+
var transitiveDependencies = await GetTransitiveDependencies(repoRootPath, projectPath, tfms, dependencies, experimentsManager, logger);
|
480
481
|
ImmutableArray<Dependency> allDependencies = dependencies.Concat(transitiveDependencies).Concat(sdkDependencies)
|
481
482
|
.OrderBy(d => d.Name)
|
482
483
|
.ToImmutableArray();
|
@@ -514,12 +515,19 @@ internal static class SdkProjectDiscovery
|
|
514
515
|
return results.ToImmutable();
|
515
516
|
}
|
516
517
|
|
517
|
-
private static async Task<ImmutableArray<Dependency>> GetTransitiveDependencies(
|
518
|
+
private static async Task<ImmutableArray<Dependency>> GetTransitiveDependencies(
|
519
|
+
string repoRootPath,
|
520
|
+
string projectPath,
|
521
|
+
ImmutableArray<string> tfms,
|
522
|
+
ImmutableArray<Dependency> directDependencies,
|
523
|
+
ExperimentsManager experimentsManager,
|
524
|
+
ILogger logger
|
525
|
+
)
|
518
526
|
{
|
519
527
|
Dictionary<string, Dependency> transitiveDependencies = new(StringComparer.OrdinalIgnoreCase);
|
520
528
|
foreach (var tfm in tfms)
|
521
529
|
{
|
522
|
-
var tfmDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(repoRootPath, projectPath, tfm, directDependencies, logger);
|
530
|
+
var tfmDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(repoRootPath, projectPath, tfm, directDependencies, experimentsManager, logger);
|
523
531
|
foreach (var dependency in tfmDependencies.Where(d => d.IsTransitive))
|
524
532
|
{
|
525
533
|
if (!transitiveDependencies.TryGetValue(dependency.Name, out var existingDependency))
|
@@ -6,6 +6,7 @@ namespace NuGetUpdater.Core;
|
|
6
6
|
|
7
7
|
public record ExperimentsManager
|
8
8
|
{
|
9
|
+
public bool InstallDotnetSdks { get; init; } = false;
|
9
10
|
public bool UseLegacyDependencySolver { get; init; } = false;
|
10
11
|
public bool UseDirectDiscovery { get; init; } = false;
|
11
12
|
|
@@ -13,6 +14,7 @@ public record ExperimentsManager
|
|
13
14
|
{
|
14
15
|
return new()
|
15
16
|
{
|
17
|
+
["nuget_install_dotnet_sdks"] = InstallDotnetSdks,
|
16
18
|
["nuget_legacy_dependency_solver"] = UseLegacyDependencySolver,
|
17
19
|
["nuget_use_direct_discovery"] = UseDirectDiscovery,
|
18
20
|
};
|
@@ -22,24 +24,48 @@ public record ExperimentsManager
|
|
22
24
|
{
|
23
25
|
return new ExperimentsManager()
|
24
26
|
{
|
27
|
+
InstallDotnetSdks = IsEnabled(experiments, "nuget_install_dotnet_sdks"),
|
25
28
|
UseLegacyDependencySolver = IsEnabled(experiments, "nuget_legacy_dependency_solver"),
|
26
29
|
UseDirectDiscovery = IsEnabled(experiments, "nuget_use_direct_discovery"),
|
27
30
|
};
|
28
31
|
}
|
29
32
|
|
30
|
-
public static async Task<ExperimentsManager> FromJobFileAsync(string jobFilePath
|
33
|
+
public static async Task<(ExperimentsManager ExperimentsManager, NativeResult? ErrorResult)> FromJobFileAsync(string jobFilePath)
|
31
34
|
{
|
32
|
-
var
|
35
|
+
var experimentsManager = new ExperimentsManager();
|
36
|
+
NativeResult? errorResult = null;
|
33
37
|
try
|
34
38
|
{
|
39
|
+
var jobFileContent = await File.ReadAllTextAsync(jobFilePath);
|
35
40
|
var jobWrapper = RunWorker.Deserialize(jobFileContent);
|
36
|
-
|
41
|
+
experimentsManager = GetExperimentsManager(jobWrapper.Job.Experiments);
|
42
|
+
}
|
43
|
+
catch (BadRequirementException ex)
|
44
|
+
{
|
45
|
+
errorResult = new NativeResult
|
46
|
+
{
|
47
|
+
ErrorType = ErrorType.BadRequirement,
|
48
|
+
ErrorDetails = ex.Message,
|
49
|
+
};
|
37
50
|
}
|
38
51
|
catch (JsonException ex)
|
39
52
|
{
|
40
|
-
|
41
|
-
|
53
|
+
errorResult = new NativeResult
|
54
|
+
{
|
55
|
+
ErrorType = ErrorType.Unknown,
|
56
|
+
ErrorDetails = $"Error deserializing job file: {ex}: {File.ReadAllText(jobFilePath)}",
|
57
|
+
};
|
58
|
+
}
|
59
|
+
catch (Exception ex)
|
60
|
+
{
|
61
|
+
errorResult = new NativeResult
|
62
|
+
{
|
63
|
+
ErrorType = ErrorType.Unknown,
|
64
|
+
ErrorDetails = ex.ToString(),
|
65
|
+
};
|
42
66
|
}
|
67
|
+
|
68
|
+
return (experimentsManager, errorResult);
|
43
69
|
}
|
44
70
|
|
45
71
|
private static bool IsEnabled(Dictionary<string, object>? experiments, string experimentName)
|
@@ -2,9 +2,10 @@ namespace NuGetUpdater.Core.Run.ApiModel;
|
|
2
2
|
|
3
3
|
public record DependencyFileNotFound : JobErrorBase
|
4
4
|
{
|
5
|
-
public DependencyFileNotFound(string filePath)
|
5
|
+
public DependencyFileNotFound(string message, string filePath)
|
6
6
|
: base("dependency_file_not_found")
|
7
7
|
{
|
8
|
-
Details =
|
8
|
+
Details["message"] = message;
|
9
|
+
Details["file-path"] = filePath;
|
9
10
|
}
|
10
11
|
}
|
@@ -13,6 +13,5 @@ public abstract record JobErrorBase
|
|
13
13
|
public string Type { get; }
|
14
14
|
|
15
15
|
[JsonPropertyName("error-details")]
|
16
|
-
|
17
|
-
public object? Details { get; init; } = null;
|
16
|
+
public Dictionary<string, object> Details { get; init; } = new();
|
18
17
|
}
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/PrivateSourceAuthenticationFailure.cs
CHANGED
@@ -5,6 +5,6 @@ public record PrivateSourceAuthenticationFailure : JobErrorBase
|
|
5
5
|
public PrivateSourceAuthenticationFailure(string[] urls)
|
6
6
|
: base("private_source_authentication_failure")
|
7
7
|
{
|
8
|
-
Details = $"({string.Join("|", urls)})";
|
8
|
+
Details["source"] = $"({string.Join("|", urls)})";
|
9
9
|
}
|
10
10
|
}
|
@@ -2,9 +2,13 @@ namespace NuGetUpdater.Core.Run.ApiModel;
|
|
2
2
|
|
3
3
|
public record UnknownError : JobErrorBase
|
4
4
|
{
|
5
|
-
public UnknownError(string
|
5
|
+
public UnknownError(Exception ex, string jobId)
|
6
6
|
: base("unknown_error")
|
7
7
|
{
|
8
|
-
Details =
|
8
|
+
Details["error-class"] = ex.GetType().Name;
|
9
|
+
Details["error-message"] = ex.Message;
|
10
|
+
Details["error-backtrace"] = ex.StackTrace ?? "<unknown>";
|
11
|
+
Details["package-manager"] = "nuget";
|
12
|
+
Details["job-id"] = jobId;
|
9
13
|
}
|
10
14
|
}
|
@@ -12,6 +12,7 @@ namespace NuGetUpdater.Core.Run;
|
|
12
12
|
|
13
13
|
public class RunWorker
|
14
14
|
{
|
15
|
+
private readonly string _jobId;
|
15
16
|
private readonly IApiHandler _apiHandler;
|
16
17
|
private readonly ILogger _logger;
|
17
18
|
private readonly IDiscoveryWorker _discoveryWorker;
|
@@ -25,8 +26,9 @@ public class RunWorker
|
|
25
26
|
Converters = { new JsonStringEnumConverter(), new RequirementConverter(), new VersionConverter() },
|
26
27
|
};
|
27
28
|
|
28
|
-
public RunWorker(IApiHandler apiHandler, IDiscoveryWorker discoverWorker, IAnalyzeWorker analyzeWorker, IUpdaterWorker updateWorker, ILogger logger)
|
29
|
+
public RunWorker(string jobId, IApiHandler apiHandler, IDiscoveryWorker discoverWorker, IAnalyzeWorker analyzeWorker, IUpdaterWorker updateWorker, ILogger logger)
|
29
30
|
{
|
31
|
+
_jobId = jobId;
|
30
32
|
_apiHandler = apiHandler;
|
31
33
|
_logger = logger;
|
32
34
|
_discoveryWorker = discoverWorker;
|
@@ -87,9 +89,13 @@ public class RunWorker
|
|
87
89
|
{
|
88
90
|
error = new PrivateSourceAuthenticationFailure(lastUsedPackageSourceUrls);
|
89
91
|
}
|
92
|
+
catch (BadRequirementException ex)
|
93
|
+
{
|
94
|
+
error = new BadRequirement(ex.Message);
|
95
|
+
}
|
90
96
|
catch (MissingFileException ex)
|
91
97
|
{
|
92
|
-
error = new DependencyFileNotFound(ex.FilePath);
|
98
|
+
error = new DependencyFileNotFound("file not found", ex.FilePath);
|
93
99
|
}
|
94
100
|
catch (UpdateNotPossibleException ex)
|
95
101
|
{
|
@@ -97,7 +103,7 @@ public class RunWorker
|
|
97
103
|
}
|
98
104
|
catch (Exception ex)
|
99
105
|
{
|
100
|
-
error = new UnknownError(ex
|
106
|
+
error = new UnknownError(ex, _jobId);
|
101
107
|
}
|
102
108
|
|
103
109
|
if (error is not null)
|
@@ -5,12 +5,13 @@ internal static class LockFileUpdater
|
|
5
5
|
public static async Task UpdateLockFileAsync(
|
6
6
|
string repoRootPath,
|
7
7
|
string projectPath,
|
8
|
+
ExperimentsManager experimentsManager,
|
8
9
|
ILogger logger)
|
9
10
|
{
|
10
11
|
var projectDirectory = Path.GetDirectoryName(projectPath)!;
|
11
|
-
await MSBuildHelper.
|
12
|
+
await MSBuildHelper.HandleGlobalJsonAsync(projectDirectory, repoRootPath, experimentsManager, async () =>
|
12
13
|
{
|
13
|
-
var (exitCode, stdout, stderr) = await ProcessEx.
|
14
|
+
var (exitCode, stdout, stderr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(["restore", "--force-evaluate", "-p:EnableWindowsTargeting=true", projectPath], projectDirectory, experimentsManager);
|
14
15
|
if (exitCode != 0)
|
15
16
|
{
|
16
17
|
logger.Error($" Lock file update failed.\nSTDOUT:\n{stdout}\nSTDERR:\n{stderr}");
|
@@ -37,17 +37,17 @@ internal static class PackageReferenceUpdater
|
|
37
37
|
// Get the set of all top-level dependencies in the current project
|
38
38
|
var topLevelDependencies = MSBuildHelper.GetTopLevelPackageDependencyInfos(buildFiles).ToArray();
|
39
39
|
|
40
|
-
if (!await DoesDependencyRequireUpdateAsync(repoRootPath, projectPath, tfms, topLevelDependencies, dependencyName, newDependencyVersion, logger))
|
40
|
+
if (!await DoesDependencyRequireUpdateAsync(repoRootPath, projectPath, tfms, topLevelDependencies, dependencyName, newDependencyVersion, experimentsManager, logger))
|
41
41
|
{
|
42
42
|
return;
|
43
43
|
}
|
44
44
|
|
45
|
-
var peerDependencies = await GetUpdatedPeerDependenciesAsync(repoRootPath, projectPath, tfms, dependencyName, newDependencyVersion, logger);
|
45
|
+
var peerDependencies = await GetUpdatedPeerDependenciesAsync(repoRootPath, projectPath, tfms, dependencyName, newDependencyVersion, experimentsManager, logger);
|
46
46
|
if (experimentsManager.UseLegacyDependencySolver)
|
47
47
|
{
|
48
48
|
if (isTransitive)
|
49
49
|
{
|
50
|
-
await UpdateTransitiveDependencyAsync(repoRootPath, projectPath, dependencyName, newDependencyVersion, buildFiles, logger);
|
50
|
+
await UpdateTransitiveDependencyAsync(repoRootPath, projectPath, dependencyName, newDependencyVersion, buildFiles, experimentsManager, logger);
|
51
51
|
}
|
52
52
|
else
|
53
53
|
{
|
@@ -56,7 +56,7 @@ internal static class PackageReferenceUpdater
|
|
56
56
|
return;
|
57
57
|
}
|
58
58
|
|
59
|
-
await UpdateTopLevelDepdendency(repoRootPath, buildFiles, tfms, dependencyName, previousDependencyVersion, newDependencyVersion, peerDependencies, logger);
|
59
|
+
await UpdateTopLevelDepdendency(repoRootPath, buildFiles, tfms, dependencyName, previousDependencyVersion, newDependencyVersion, peerDependencies, experimentsManager, logger);
|
60
60
|
}
|
61
61
|
}
|
62
62
|
else
|
@@ -66,10 +66,10 @@ internal static class PackageReferenceUpdater
|
|
66
66
|
return;
|
67
67
|
}
|
68
68
|
|
69
|
-
await UpdateDependencyWithConflictResolution(repoRootPath, buildFiles, tfms, projectPath, dependencyName, previousDependencyVersion, newDependencyVersion, isTransitive, peerDependencies, logger);
|
69
|
+
await UpdateDependencyWithConflictResolution(repoRootPath, buildFiles, tfms, projectPath, dependencyName, previousDependencyVersion, newDependencyVersion, isTransitive, peerDependencies, experimentsManager, logger);
|
70
70
|
}
|
71
71
|
|
72
|
-
if (!await AreDependenciesCoherentAsync(repoRootPath, projectPath, dependencyName,
|
72
|
+
if (!await AreDependenciesCoherentAsync(repoRootPath, projectPath, dependencyName, buildFiles, tfms, experimentsManager, logger))
|
73
73
|
{
|
74
74
|
return;
|
75
75
|
}
|
@@ -87,6 +87,7 @@ internal static class PackageReferenceUpdater
|
|
87
87
|
string newDependencyVersion,
|
88
88
|
bool isTransitive,
|
89
89
|
IDictionary<string, string> peerDependencies,
|
90
|
+
ExperimentsManager experimentsManager,
|
90
91
|
ILogger logger)
|
91
92
|
{
|
92
93
|
var topLevelDependencies = MSBuildHelper.GetTopLevelPackageDependencyInfos(buildFiles).ToArray();
|
@@ -107,7 +108,7 @@ internal static class PackageReferenceUpdater
|
|
107
108
|
{
|
108
109
|
foreach (var tfm in targetFrameworks)
|
109
110
|
{
|
110
|
-
var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRootPath, projectFile.Path, tfm, topLevelDependencies, dependenciesToUpdate, logger);
|
111
|
+
var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflicts(repoRootPath, projectFile.Path, tfm, topLevelDependencies, dependenciesToUpdate, experimentsManager, logger);
|
111
112
|
if (resolvedDependencies is null)
|
112
113
|
{
|
113
114
|
logger.Warn($" Unable to resolve dependency conflicts for {projectFile.Path}.");
|
@@ -118,7 +119,7 @@ internal static class PackageReferenceUpdater
|
|
118
119
|
if (isTransitive && !isDependencyTopLevel && isDependencyInResolutionSet)
|
119
120
|
{
|
120
121
|
// a transitive dependency had to be pinned; add it here
|
121
|
-
await UpdateTransitiveDependencyAsync(repoRootPath, projectPath, dependencyName, newDependencyVersion, buildFiles, logger);
|
122
|
+
await UpdateTransitiveDependencyAsync(repoRootPath, projectPath, dependencyName, newDependencyVersion, buildFiles, experimentsManager, logger);
|
122
123
|
}
|
123
124
|
|
124
125
|
// update all resolved dependencies that aren't the initial dependency
|
@@ -143,6 +144,7 @@ internal static class PackageReferenceUpdater
|
|
143
144
|
Dependency[] topLevelDependencies,
|
144
145
|
string dependencyName,
|
145
146
|
string newDependencyVersion,
|
147
|
+
ExperimentsManager experimentsManager,
|
146
148
|
ILogger logger)
|
147
149
|
{
|
148
150
|
var newDependencyNuGetVersion = NuGetVersion.Parse(newDependencyVersion);
|
@@ -157,6 +159,7 @@ internal static class PackageReferenceUpdater
|
|
157
159
|
projectPath,
|
158
160
|
tfm,
|
159
161
|
topLevelDependencies,
|
162
|
+
experimentsManager,
|
160
163
|
logger);
|
161
164
|
foreach (var dependency in dependencies)
|
162
165
|
{
|
@@ -203,7 +206,15 @@ internal static class PackageReferenceUpdater
|
|
203
206
|
return true;
|
204
207
|
}
|
205
208
|
|
206
|
-
private static async Task UpdateTransitiveDependencyAsync(
|
209
|
+
private static async Task UpdateTransitiveDependencyAsync(
|
210
|
+
string repoRootPath,
|
211
|
+
string projectPath,
|
212
|
+
string dependencyName,
|
213
|
+
string newDependencyVersion,
|
214
|
+
ImmutableArray<ProjectBuildFile> buildFiles,
|
215
|
+
ExperimentsManager experimentsManager,
|
216
|
+
ILogger logger
|
217
|
+
)
|
207
218
|
{
|
208
219
|
var directoryPackagesWithPinning = buildFiles.OfType<ProjectBuildFile>()
|
209
220
|
.FirstOrDefault(bf => IsCpmTransitivePinningEnabled(bf));
|
@@ -213,7 +224,7 @@ internal static class PackageReferenceUpdater
|
|
213
224
|
}
|
214
225
|
else
|
215
226
|
{
|
216
|
-
await AddTransitiveDependencyAsync(repoRootPath, projectPath, dependencyName, newDependencyVersion, logger);
|
227
|
+
await AddTransitiveDependencyAsync(repoRootPath, projectPath, dependencyName, newDependencyVersion, experimentsManager, logger);
|
217
228
|
}
|
218
229
|
}
|
219
230
|
|
@@ -302,15 +313,19 @@ internal static class PackageReferenceUpdater
|
|
302
313
|
directoryPackages.Update(updatedXml);
|
303
314
|
}
|
304
315
|
|
305
|
-
private static async Task AddTransitiveDependencyAsync(string repoRootPath, string projectPath, string dependencyName, string newDependencyVersion, ILogger logger)
|
316
|
+
private static async Task AddTransitiveDependencyAsync(string repoRootPath, string projectPath, string dependencyName, string newDependencyVersion, ExperimentsManager experimentsManager, ILogger logger)
|
306
317
|
{
|
307
318
|
var projectDirectory = Path.GetDirectoryName(projectPath)!;
|
308
|
-
await MSBuildHelper.
|
319
|
+
await MSBuildHelper.HandleGlobalJsonAsync(projectDirectory, repoRootPath, experimentsManager, async () =>
|
309
320
|
{
|
310
321
|
logger.Info($" Adding [{dependencyName}/{newDependencyVersion}] as a top-level package reference.");
|
311
322
|
|
312
323
|
// see https://learn.microsoft.com/nuget/consume-packages/install-use-packages-dotnet-cli
|
313
|
-
var (exitCode, stdout, stderr) = await ProcessEx.
|
324
|
+
var (exitCode, stdout, stderr) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(
|
325
|
+
["add", projectPath, "package", dependencyName, "--version", newDependencyVersion],
|
326
|
+
projectDirectory,
|
327
|
+
experimentsManager
|
328
|
+
);
|
314
329
|
MSBuildHelper.ThrowOnUnauthenticatedFeed(stdout);
|
315
330
|
if (exitCode != 0)
|
316
331
|
{
|
@@ -331,13 +346,14 @@ internal static class PackageReferenceUpdater
|
|
331
346
|
string[] tfms,
|
332
347
|
string dependencyName,
|
333
348
|
string newDependencyVersion,
|
349
|
+
ExperimentsManager experimentsManager,
|
334
350
|
ILogger logger)
|
335
351
|
{
|
336
352
|
var newDependency = new[] { new Dependency(dependencyName, newDependencyVersion, DependencyType.Unknown) };
|
337
353
|
var tfmsAndDependencies = new Dictionary<string, Dependency[]>();
|
338
354
|
foreach (var tfm in tfms)
|
339
355
|
{
|
340
|
-
var dependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(repoRootPath, projectPath, tfm, newDependency, logger);
|
356
|
+
var dependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(repoRootPath, projectPath, tfm, newDependency, experimentsManager, logger);
|
341
357
|
tfmsAndDependencies[tfm] = dependencies;
|
342
358
|
}
|
343
359
|
|
@@ -386,6 +402,7 @@ internal static class PackageReferenceUpdater
|
|
386
402
|
string previousDependencyVersion,
|
387
403
|
string newDependencyVersion,
|
388
404
|
IDictionary<string, string> peerDependencies,
|
405
|
+
ExperimentsManager experimentsManager,
|
389
406
|
ILogger logger)
|
390
407
|
{
|
391
408
|
// update dependencies...
|
@@ -407,7 +424,7 @@ internal static class PackageReferenceUpdater
|
|
407
424
|
{
|
408
425
|
foreach (string tfm in targetFrameworks)
|
409
426
|
{
|
410
|
-
var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflictsWithBruteForce(repoRootPath, projectFile.Path, tfm, updatedTopLevelDependencies, logger);
|
427
|
+
var resolvedDependencies = await MSBuildHelper.ResolveDependencyConflictsWithBruteForce(repoRootPath, projectFile.Path, tfm, updatedTopLevelDependencies, experimentsManager, logger);
|
411
428
|
if (resolvedDependencies is null)
|
412
429
|
{
|
413
430
|
logger.Info($" Unable to resolve dependency conflicts for {projectFile.Path}.");
|
@@ -697,13 +714,21 @@ internal static class PackageReferenceUpdater
|
|
697
714
|
?? e.GetAttributeOrSubElementValue("VersionOverride", StringComparison.OrdinalIgnoreCase)) is not null;
|
698
715
|
});
|
699
716
|
|
700
|
-
private static async Task<bool> AreDependenciesCoherentAsync(
|
717
|
+
private static async Task<bool> AreDependenciesCoherentAsync(
|
718
|
+
string repoRootPath,
|
719
|
+
string projectPath,
|
720
|
+
string dependencyName,
|
721
|
+
ImmutableArray<ProjectBuildFile> buildFiles,
|
722
|
+
string[] tfms,
|
723
|
+
ExperimentsManager experimentsManager,
|
724
|
+
ILogger logger
|
725
|
+
)
|
701
726
|
{
|
702
727
|
var updatedTopLevelDependencies = MSBuildHelper.GetTopLevelPackageDependencyInfos(buildFiles).ToArray();
|
703
728
|
foreach (var tfm in tfms)
|
704
729
|
{
|
705
|
-
var updatedPackages = await MSBuildHelper.GetAllPackageDependenciesAsync(repoRootPath, projectPath, tfm, updatedTopLevelDependencies, logger);
|
706
|
-
var dependenciesAreCoherent = await MSBuildHelper.DependenciesAreCoherentAsync(repoRootPath, projectPath, tfm, updatedPackages, logger);
|
730
|
+
var updatedPackages = await MSBuildHelper.GetAllPackageDependenciesAsync(repoRootPath, projectPath, tfm, updatedTopLevelDependencies, experimentsManager, logger);
|
731
|
+
var dependenciesAreCoherent = await MSBuildHelper.DependenciesAreCoherentAsync(repoRootPath, projectPath, tfm, updatedPackages, experimentsManager, logger);
|
707
732
|
if (!dependenciesAreCoherent)
|
708
733
|
{
|
709
734
|
logger.Warn($" Package [{dependencyName}] could not be updated in [{projectPath}] because it would cause a dependency conflict.");
|
@@ -232,7 +232,7 @@ public class UpdaterWorker : IUpdaterWorker
|
|
232
232
|
var packagesLockFullPath = additionalFiles.Where(p => Path.GetFileName(p).Equals(ProjectHelper.PackagesLockJsonFileName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
233
233
|
if (packagesLockFullPath is not null)
|
234
234
|
{
|
235
|
-
await LockFileUpdater.UpdateLockFileAsync(repoRootPath, projectPath, _logger);
|
235
|
+
await LockFileUpdater.UpdateLockFileAsync(repoRootPath, projectPath, _experimentsManager, _logger);
|
236
236
|
}
|
237
237
|
}
|
238
238
|
}
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/WebApplicationTargetsConditionPatcher.cs
CHANGED
@@ -13,7 +13,18 @@ namespace NuGetUpdater.Core.Updater
|
|
13
13
|
getContent: () => File.ReadAllText(projectFilePath),
|
14
14
|
setContent: s => File.WriteAllText(projectFilePath, s),
|
15
15
|
nodeFinder: doc => doc.Descendants()
|
16
|
-
.
|
16
|
+
.Where(e => e.Name == "Import")
|
17
|
+
.FirstOrDefault(e =>
|
18
|
+
{
|
19
|
+
var projectPath = e.GetAttributeValue("Project");
|
20
|
+
if (projectPath is not null)
|
21
|
+
{
|
22
|
+
var projectFileName = Path.GetFileName(projectPath.NormalizePathToUnix());
|
23
|
+
return projectFileName.Equals("Microsoft.WebApplication.targets", StringComparison.OrdinalIgnoreCase);
|
24
|
+
}
|
25
|
+
|
26
|
+
return false;
|
27
|
+
})
|
17
28
|
as XmlNodeSyntax,
|
18
29
|
preProcessor: n =>
|
19
30
|
{
|
@@ -395,7 +395,6 @@ public class PackageManager
|
|
395
395
|
if (await AreAllParentsCompatibleAsync(existingPackages, existingPackage, targetFramework, projectDirectory, logger) == true)
|
396
396
|
{
|
397
397
|
existingPackage.CurrentVersion = dependencyOldVersion;
|
398
|
-
string NewVersion = dependency.CurrentVersion;
|
399
398
|
existingPackage.NewVersion = dependency.CurrentVersion;
|
400
399
|
await UpdateVersion(existingPackages, existingPackage, targetFramework, projectDirectory, logger);
|
401
400
|
}
|
@@ -593,12 +592,6 @@ public class PackageManager
|
|
593
592
|
return null;
|
594
593
|
}
|
595
594
|
|
596
|
-
// If the current version of the parent is less than the current version of the dependency
|
597
|
-
else if (CurrentVersion < currentVersionDependency)
|
598
|
-
{
|
599
|
-
return currentVersionDependency;
|
600
|
-
}
|
601
|
-
|
602
595
|
// Loop from the current version to the latest version, use next patch as a limit (unless there's a limit) so it doesn't look for versions that don't exist
|
603
596
|
for (NuGetVersion version = CurrentVersion; version <= latestVersion; version = NextPatch(version, versions))
|
604
597
|
{
|