dependabot-nuget 0.240.0 → 0.241.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/build +45 -0
- data/helpers/lib/NuGetUpdater/.editorconfig +364 -0
- data/helpers/lib/NuGetUpdater/.gitignore +5 -0
- data/helpers/lib/NuGetUpdater/Directory.Build.props +10 -0
- data/helpers/lib/NuGetUpdater/Directory.Common.props +16 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/Directory.Build.props +14 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/Directory.Build.targets +7 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/Directory.Packages.props +29 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Build.Tasks/NuGet.Build.Tasks.csproj +27 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.CommandLine/AssemblyMetadataExtractor.cs +203 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.CommandLine/NuGet.CommandLine.csproj +33 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Commands/NuGet.Commands.csproj +26 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Common/NuGet.Common.csproj +21 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Config +6 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Configuration/NuGet.Configuration.csproj +24 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Credentials/NuGet.Credentials.csproj +20 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.DependencyResolver.Core/NuGet.DependencyResolver.Core.csproj +22 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Frameworks/NuGet.Frameworks.csproj +17 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.LibraryModel/NuGet.LibraryModel.csproj +17 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.PackageManagement/NuGet.PackageManagement.csproj +27 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Packaging/NuGet.Packaging.csproj +28 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.ProjectModel/NuGet.ProjectModel.csproj +20 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Protocol/NuGet.Protocol.csproj +21 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Resolver/NuGet.Resolver.csproj +20 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Versioning/NuGet.Versioning.csproj +17 -0
- data/helpers/lib/NuGetUpdater/NuGetProjects/README.md +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs +35 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs +43 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/NuGetUpdater.Cli.csproj +20 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +31 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.FrameworkCheck.cs +42 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +323 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/NuGetUpdater.Cli.Test.csproj +24 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Dependency.cs +3 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyType.cs +12 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/BuildFile.cs +97 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/DotNetToolsJsonBuildFile.cs +24 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/GlobalJsonBuildFile.cs +25 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +32 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/PackagesConfigBuildFile.cs +31 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/ProjectBuildFile.cs +94 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/XmlBuildFile.cs +14 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +39 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/FrameworkCompatibilityService.cs +73 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/SupportedFrameworks.cs +146 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/NuGetUpdater.Core.csproj +27 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +316 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectResolver.cs +87 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/ConfigurationFile.cs +3 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +66 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +48 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +172 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs +498 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdateResult.cs +7 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +105 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs +222 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/Logger.cs +24 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +443 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +15 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +69 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProcessExtensions.cs +66 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/XmlExtensions.cs +124 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/DotNetToolsJsonBuildFileTests.cs +52 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs +63 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/PackagesConfigBuildFileTests.cs +63 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/ProjectBuildFileTests.cs +154 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/CompatibilityCheckerFacts.cs +64 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/FrameworkCompatibilityServiceFacts.cs +122 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/SupportedFrameworkFacts.cs +68 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/NuGetUpdater.Core.Test.csproj +23 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs +36 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestExtensions.cs +15 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +79 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorker.DirsProj.cs +201 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +147 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +225 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +217 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +94 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +938 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +2177 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/JsonHelperTests.cs +239 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +394 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterHelperTests.cs +179 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterTests.cs +238 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.sln +152 -0
- data/helpers/lib/NuGetUpdater/xunit.runner.json +4 -0
- data/lib/dependabot/nuget/metadata_finder.rb +4 -4
- metadata +91 -5
@@ -0,0 +1,147 @@
|
|
1
|
+
using System;
|
2
|
+
using System.Collections.Generic;
|
3
|
+
using System.IO;
|
4
|
+
using System.Linq;
|
5
|
+
using System.Threading.Tasks;
|
6
|
+
|
7
|
+
using Xunit;
|
8
|
+
|
9
|
+
namespace NuGetUpdater.Core.Test.Update;
|
10
|
+
|
11
|
+
public abstract class UpdateWorkerTestBase
|
12
|
+
{
|
13
|
+
protected static Task TestNoChangeforProject(
|
14
|
+
string dependencyName,
|
15
|
+
string oldVersion,
|
16
|
+
string newVersion,
|
17
|
+
string projectContents,
|
18
|
+
bool isTransitive = false,
|
19
|
+
(string Path, string Content)[]? additionalFiles = null,
|
20
|
+
string projectFilePath = "test-project.csproj")
|
21
|
+
=> TestUpdateForProject(dependencyName, oldVersion, newVersion, (projectFilePath, projectContents), expectedProjectContents: projectContents, isTransitive, additionalFiles, additionalFilesExpected: additionalFiles);
|
22
|
+
|
23
|
+
protected static Task TestUpdateForProject(
|
24
|
+
string dependencyName,
|
25
|
+
string oldVersion,
|
26
|
+
string newVersion,
|
27
|
+
string projectContents,
|
28
|
+
string expectedProjectContents,
|
29
|
+
bool isTransitive = false,
|
30
|
+
(string Path, string Content)[]? additionalFiles = null,
|
31
|
+
(string Path, string Content)[]? additionalFilesExpected = null,
|
32
|
+
string projectFilePath = "test-project.csproj")
|
33
|
+
{
|
34
|
+
var projectFile = (Path: projectFilePath, Content: projectContents);
|
35
|
+
return TestUpdateForProject(dependencyName, oldVersion, newVersion, projectFile, expectedProjectContents, isTransitive, additionalFiles, additionalFilesExpected);
|
36
|
+
}
|
37
|
+
|
38
|
+
protected static async Task TestUpdateForProject(
|
39
|
+
string dependencyName,
|
40
|
+
string oldVersion,
|
41
|
+
string newVersion,
|
42
|
+
(string Path, string Content) projectFile,
|
43
|
+
string expectedProjectContents,
|
44
|
+
bool isTransitive = false,
|
45
|
+
(string Path, string Content)[]? additionalFiles = null,
|
46
|
+
(string Path, string Content)[]? additionalFilesExpected = null)
|
47
|
+
{
|
48
|
+
additionalFiles ??= Array.Empty<(string Path, string Content)>();
|
49
|
+
additionalFilesExpected ??= Array.Empty<(string Path, string Content)>();
|
50
|
+
|
51
|
+
var projectFilePath = projectFile.Path;
|
52
|
+
var projectName = Path.GetFileNameWithoutExtension(projectFilePath);
|
53
|
+
var slnName = "test-solution.sln";
|
54
|
+
var slnContent = $$"""
|
55
|
+
Microsoft Visual Studio Solution File, Format Version 12.00
|
56
|
+
# Visual Studio 14
|
57
|
+
VisualStudioVersion = 14.0.22705.0
|
58
|
+
MinimumVisualStudioVersion = 10.0.40219.1
|
59
|
+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "{{projectName}}", "{{projectFilePath}}", "{782E0C0A-10D3-444D-9640-263D03D2B20C}"
|
60
|
+
EndProject
|
61
|
+
Global
|
62
|
+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
63
|
+
Debug|Any CPU = Debug|Any CPU
|
64
|
+
Release|Any CPU = Release|Any CPU
|
65
|
+
EndGlobalSection
|
66
|
+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
67
|
+
{782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
68
|
+
{782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
69
|
+
{782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
70
|
+
{782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.Build.0 = Release|Any CPU
|
71
|
+
EndGlobalSection
|
72
|
+
GlobalSection(SolutionProperties) = preSolution
|
73
|
+
HideSolutionNode = FALSE
|
74
|
+
EndGlobalSection
|
75
|
+
EndGlobal
|
76
|
+
""";
|
77
|
+
var testFiles = new[] { (slnName, slnContent), projectFile }.Concat(additionalFiles).ToArray();
|
78
|
+
|
79
|
+
var actualResult = await RunUpdate(testFiles, async (temporaryDirectory) =>
|
80
|
+
{
|
81
|
+
var slnPath = Path.Combine(temporaryDirectory, slnName);
|
82
|
+
var worker = new UpdaterWorker(new Logger(verbose: true));
|
83
|
+
await worker.RunAsync(temporaryDirectory, slnPath, dependencyName, oldVersion, newVersion, isTransitive);
|
84
|
+
});
|
85
|
+
|
86
|
+
var expectedResult = additionalFilesExpected.Prepend((projectFilePath, expectedProjectContents)).ToArray();
|
87
|
+
|
88
|
+
AssertContainsFiles(expectedResult, actualResult);
|
89
|
+
}
|
90
|
+
|
91
|
+
protected static async Task<(string Path, string Content)[]> RunUpdate((string Path, string Content)[] files, Func<string, Task> action)
|
92
|
+
{
|
93
|
+
// write initial files
|
94
|
+
using var tempDir = new TemporaryDirectory();
|
95
|
+
foreach (var file in files)
|
96
|
+
{
|
97
|
+
var localPath = file.Path.StartsWith("/") ? file.Path[1..] : file.Path; // remove path rooting character
|
98
|
+
var filePath = Path.Combine(tempDir.DirectoryPath, localPath);
|
99
|
+
var directoryPath = Path.GetDirectoryName(filePath);
|
100
|
+
Directory.CreateDirectory(directoryPath!);
|
101
|
+
await File.WriteAllTextAsync(filePath, file.Content);
|
102
|
+
}
|
103
|
+
|
104
|
+
// run update
|
105
|
+
await action(tempDir.DirectoryPath);
|
106
|
+
|
107
|
+
// gather results
|
108
|
+
var expectedFiles = new HashSet<string>(files.Select(f => f.Path));
|
109
|
+
var result = new List<(string Path, string Content)>();
|
110
|
+
foreach (var file in Directory.GetFiles(tempDir.DirectoryPath, "*.*", SearchOption.AllDirectories))
|
111
|
+
{
|
112
|
+
var localPath = file.StartsWith(tempDir.DirectoryPath)
|
113
|
+
? file[tempDir.DirectoryPath.Length..]
|
114
|
+
: file; // how did this happen?
|
115
|
+
localPath = localPath.NormalizePathToUnix();
|
116
|
+
if (localPath.StartsWith('/'))
|
117
|
+
{
|
118
|
+
localPath = localPath[1..];
|
119
|
+
}
|
120
|
+
|
121
|
+
if (expectedFiles.Contains(localPath))
|
122
|
+
{
|
123
|
+
var content = await File.ReadAllTextAsync(file);
|
124
|
+
result.Add((localPath, content));
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
return result.ToArray();
|
129
|
+
}
|
130
|
+
|
131
|
+
protected static void AssertEqualFiles((string Path, string Content)[] expected, (string Path, string Content)[] actual)
|
132
|
+
{
|
133
|
+
Assert.Equal(expected.Length, actual.Length);
|
134
|
+
AssertContainsFiles(expected, actual);
|
135
|
+
}
|
136
|
+
|
137
|
+
protected static void AssertContainsFiles((string Path, string Content)[] expected, (string Path, string Content)[] actual)
|
138
|
+
{
|
139
|
+
var actualContents = actual.ToDictionary(pair => pair.Path, pair => pair.Content);
|
140
|
+
foreach (var expectedPair in expected)
|
141
|
+
{
|
142
|
+
var actualContent = actualContents[expectedPair.Path];
|
143
|
+
var expectedContent = expectedPair.Content;
|
144
|
+
Assert.Equal(expectedContent.Replace("\r", ""), actualContent.Replace("\r", "")); // normalize line endings
|
145
|
+
}
|
146
|
+
}
|
147
|
+
}
|
@@ -0,0 +1,225 @@
|
|
1
|
+
using System.Threading.Tasks;
|
2
|
+
|
3
|
+
using Xunit;
|
4
|
+
|
5
|
+
namespace NuGetUpdater.Core.Test.Update;
|
6
|
+
|
7
|
+
public partial class UpdateWorkerTests
|
8
|
+
{
|
9
|
+
public class DotNetTools : UpdateWorkerTestBase
|
10
|
+
{
|
11
|
+
public DotNetTools()
|
12
|
+
{
|
13
|
+
MSBuildHelper.RegisterMSBuild();
|
14
|
+
}
|
15
|
+
|
16
|
+
[Fact]
|
17
|
+
public async Task NoChangeWhenDotNetToolsJsonNotFound()
|
18
|
+
{
|
19
|
+
await TestNoChangeforProject("Microsoft.BotSay", "1.0.0", "1.1.0",
|
20
|
+
// initial
|
21
|
+
projectContents: """
|
22
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
23
|
+
<PropertyGroup>
|
24
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
25
|
+
</PropertyGroup>
|
26
|
+
|
27
|
+
<ItemGroup>
|
28
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
29
|
+
</ItemGroup>
|
30
|
+
</Project>
|
31
|
+
""");
|
32
|
+
}
|
33
|
+
|
34
|
+
[Fact]
|
35
|
+
public async Task NoChangeWhenDependencyNotFound()
|
36
|
+
{
|
37
|
+
await TestNoChangeforProject("Microsoft.BotSay", "1.0.0", "1.1.0",
|
38
|
+
// initial
|
39
|
+
projectContents: """
|
40
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
41
|
+
<PropertyGroup>
|
42
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
43
|
+
</PropertyGroup>
|
44
|
+
|
45
|
+
<ItemGroup>
|
46
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
47
|
+
</ItemGroup>
|
48
|
+
</Project>
|
49
|
+
""",
|
50
|
+
additionalFiles: new[]
|
51
|
+
{
|
52
|
+
(".config/dotnet-tools.json", """
|
53
|
+
{
|
54
|
+
"version": 1,
|
55
|
+
"isRoot": true,
|
56
|
+
"tools": {
|
57
|
+
"dotnetsay": {
|
58
|
+
"version": "2.1.3",
|
59
|
+
"commands": [
|
60
|
+
"dotnetsay"
|
61
|
+
]
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
""")
|
66
|
+
});
|
67
|
+
}
|
68
|
+
|
69
|
+
[Fact]
|
70
|
+
public async Task UpdateSingleDependencyInDirsProj()
|
71
|
+
{
|
72
|
+
await TestUpdateForProject("Microsoft.BotSay", "1.0.0", "1.1.0",
|
73
|
+
// initial
|
74
|
+
projectContents: """
|
75
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
76
|
+
<PropertyGroup>
|
77
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
78
|
+
</PropertyGroup>
|
79
|
+
|
80
|
+
<ItemGroup>
|
81
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
82
|
+
</ItemGroup>
|
83
|
+
</Project>
|
84
|
+
""",
|
85
|
+
additionalFiles: new[]
|
86
|
+
{
|
87
|
+
(".config/dotnet-tools.json", """
|
88
|
+
{
|
89
|
+
"version": 1,
|
90
|
+
"isRoot": true,
|
91
|
+
"tools": {
|
92
|
+
"microsoft.botsay": {
|
93
|
+
"version": "1.0.0",
|
94
|
+
"commands": [
|
95
|
+
"botsay"
|
96
|
+
]
|
97
|
+
},
|
98
|
+
"dotnetsay": {
|
99
|
+
"version": "2.1.3",
|
100
|
+
"commands": [
|
101
|
+
"dotnetsay"
|
102
|
+
]
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
""")
|
107
|
+
},
|
108
|
+
// expected
|
109
|
+
expectedProjectContents: """
|
110
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
111
|
+
<PropertyGroup>
|
112
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
113
|
+
</PropertyGroup>
|
114
|
+
|
115
|
+
<ItemGroup>
|
116
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
117
|
+
</ItemGroup>
|
118
|
+
</Project>
|
119
|
+
""",
|
120
|
+
additionalFilesExpected: new[]
|
121
|
+
{
|
122
|
+
(".config/dotnet-tools.json", """
|
123
|
+
{
|
124
|
+
"version": 1,
|
125
|
+
"isRoot": true,
|
126
|
+
"tools": {
|
127
|
+
"microsoft.botsay": {
|
128
|
+
"version": "1.1.0",
|
129
|
+
"commands": [
|
130
|
+
"botsay"
|
131
|
+
]
|
132
|
+
},
|
133
|
+
"dotnetsay": {
|
134
|
+
"version": "2.1.3",
|
135
|
+
"commands": [
|
136
|
+
"dotnetsay"
|
137
|
+
]
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
""")
|
142
|
+
});
|
143
|
+
}
|
144
|
+
|
145
|
+
[Fact]
|
146
|
+
public async Task UpdateSingleDependencyWithComments()
|
147
|
+
{
|
148
|
+
await TestUpdateForProject("Microsoft.BotSay", "1.0.0", "1.1.0",
|
149
|
+
// initial
|
150
|
+
projectContents: """
|
151
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
152
|
+
<PropertyGroup>
|
153
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
154
|
+
</PropertyGroup>
|
155
|
+
|
156
|
+
<ItemGroup>
|
157
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
158
|
+
</ItemGroup>
|
159
|
+
</Project>
|
160
|
+
""",
|
161
|
+
additionalFiles: new[]
|
162
|
+
{
|
163
|
+
(".config/dotnet-tools.json", """
|
164
|
+
{
|
165
|
+
// this is a comment
|
166
|
+
"version": 1,
|
167
|
+
"isRoot": true,
|
168
|
+
"tools": {
|
169
|
+
"microsoft.botsay": {
|
170
|
+
// this is a deep comment
|
171
|
+
"version": "1.0.0",
|
172
|
+
"commands": [
|
173
|
+
"botsay"
|
174
|
+
]
|
175
|
+
},
|
176
|
+
"dotnetsay": {
|
177
|
+
"version": "2.1.3",
|
178
|
+
"commands": [
|
179
|
+
"dotnetsay"
|
180
|
+
]
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
""")
|
185
|
+
},
|
186
|
+
// expected
|
187
|
+
expectedProjectContents: """
|
188
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
189
|
+
<PropertyGroup>
|
190
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
191
|
+
</PropertyGroup>
|
192
|
+
|
193
|
+
<ItemGroup>
|
194
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
195
|
+
</ItemGroup>
|
196
|
+
</Project>
|
197
|
+
""",
|
198
|
+
additionalFilesExpected: new[]
|
199
|
+
{
|
200
|
+
(".config/dotnet-tools.json", """
|
201
|
+
{
|
202
|
+
// this is a comment
|
203
|
+
"version": 1,
|
204
|
+
"isRoot": true,
|
205
|
+
"tools": {
|
206
|
+
"microsoft.botsay": {
|
207
|
+
// this is a deep comment
|
208
|
+
"version": "1.1.0",
|
209
|
+
"commands": [
|
210
|
+
"botsay"
|
211
|
+
]
|
212
|
+
},
|
213
|
+
"dotnetsay": {
|
214
|
+
"version": "2.1.3",
|
215
|
+
"commands": [
|
216
|
+
"dotnetsay"
|
217
|
+
]
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
221
|
+
""")
|
222
|
+
});
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}
|
@@ -0,0 +1,217 @@
|
|
1
|
+
using System.Threading.Tasks;
|
2
|
+
|
3
|
+
using Xunit;
|
4
|
+
|
5
|
+
namespace NuGetUpdater.Core.Test.Update;
|
6
|
+
|
7
|
+
public partial class UpdateWorkerTests
|
8
|
+
{
|
9
|
+
public class GlobalJson : UpdateWorkerTestBase
|
10
|
+
{
|
11
|
+
public GlobalJson()
|
12
|
+
{
|
13
|
+
MSBuildHelper.RegisterMSBuild();
|
14
|
+
}
|
15
|
+
|
16
|
+
[Fact]
|
17
|
+
public async Task NoChangeWhenGlobalJsonNotFound()
|
18
|
+
{
|
19
|
+
await TestNoChangeforProject("Microsoft.Build.Traversal", "3.2.0", "4.1.0",
|
20
|
+
// initial
|
21
|
+
projectContents: """
|
22
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
23
|
+
<PropertyGroup>
|
24
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
25
|
+
</PropertyGroup>
|
26
|
+
|
27
|
+
<ItemGroup>
|
28
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
29
|
+
</ItemGroup>
|
30
|
+
</Project>
|
31
|
+
""");
|
32
|
+
}
|
33
|
+
|
34
|
+
[Fact]
|
35
|
+
public async Task NoChangeWhenDependencyNotFound()
|
36
|
+
{
|
37
|
+
await TestNoChangeforProject("Microsoft.Build.Traversal", "3.2.0", "4.1.0",
|
38
|
+
// initial
|
39
|
+
projectContents: """
|
40
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
41
|
+
<PropertyGroup>
|
42
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
43
|
+
</PropertyGroup>
|
44
|
+
|
45
|
+
<ItemGroup>
|
46
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
47
|
+
</ItemGroup>
|
48
|
+
</Project>
|
49
|
+
""",
|
50
|
+
additionalFiles: new[]
|
51
|
+
{
|
52
|
+
("global.json", """
|
53
|
+
{
|
54
|
+
"sdk": {
|
55
|
+
"version": "6.0.405",
|
56
|
+
"rollForward": "latestPatch"
|
57
|
+
}
|
58
|
+
}
|
59
|
+
""")
|
60
|
+
});
|
61
|
+
}
|
62
|
+
|
63
|
+
[Fact]
|
64
|
+
public async Task NoChangeWhenGlobalJsonInUnexpectedLocation()
|
65
|
+
{
|
66
|
+
await TestNoChangeforProject("Microsoft.Build.Traversal", "3.2.0", "4.1.0",
|
67
|
+
// initial
|
68
|
+
projectFilePath: "src/project/project.csproj",
|
69
|
+
projectContents: """
|
70
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
71
|
+
<PropertyGroup>
|
72
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
73
|
+
</PropertyGroup>
|
74
|
+
|
75
|
+
<ItemGroup>
|
76
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
77
|
+
</ItemGroup>>
|
78
|
+
</Project>
|
79
|
+
""",
|
80
|
+
additionalFiles: new[]
|
81
|
+
{
|
82
|
+
("eng/global.json", """
|
83
|
+
{
|
84
|
+
"sdk": {
|
85
|
+
"version": "6.0.405",
|
86
|
+
"rollForward": "latestPatch"
|
87
|
+
},
|
88
|
+
"msbuild-sdks": {
|
89
|
+
"Microsoft.Build.Traversal": "3.2.0"
|
90
|
+
}
|
91
|
+
}
|
92
|
+
""")
|
93
|
+
});
|
94
|
+
}
|
95
|
+
|
96
|
+
[Fact]
|
97
|
+
public async Task UpdateSingleDependency()
|
98
|
+
{
|
99
|
+
await TestUpdateForProject("Microsoft.Build.Traversal", "3.2.0", "4.1.0",
|
100
|
+
// initial
|
101
|
+
projectFilePath: "src/project/project.csproj",
|
102
|
+
projectContents: """
|
103
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
104
|
+
<PropertyGroup>
|
105
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
106
|
+
</PropertyGroup>
|
107
|
+
|
108
|
+
<ItemGroup>
|
109
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
110
|
+
</ItemGroup>
|
111
|
+
</Project>
|
112
|
+
""",
|
113
|
+
additionalFiles: new[]
|
114
|
+
{
|
115
|
+
("src/global.json", """
|
116
|
+
{
|
117
|
+
"sdk": {
|
118
|
+
"version": "6.0.405",
|
119
|
+
"rollForward": "latestPatch"
|
120
|
+
},
|
121
|
+
"msbuild-sdks": {
|
122
|
+
"Microsoft.Build.Traversal": "3.2.0"
|
123
|
+
}
|
124
|
+
}
|
125
|
+
""")
|
126
|
+
},
|
127
|
+
// expected
|
128
|
+
expectedProjectContents: """
|
129
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
130
|
+
<PropertyGroup>
|
131
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
132
|
+
</PropertyGroup>
|
133
|
+
|
134
|
+
<ItemGroup>
|
135
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
136
|
+
</ItemGroup>
|
137
|
+
</Project>
|
138
|
+
""",
|
139
|
+
additionalFilesExpected: new[]
|
140
|
+
{
|
141
|
+
("src/global.json", """
|
142
|
+
{
|
143
|
+
"sdk": {
|
144
|
+
"version": "6.0.405",
|
145
|
+
"rollForward": "latestPatch"
|
146
|
+
},
|
147
|
+
"msbuild-sdks": {
|
148
|
+
"Microsoft.Build.Traversal": "4.1.0"
|
149
|
+
}
|
150
|
+
}
|
151
|
+
""")
|
152
|
+
});
|
153
|
+
}
|
154
|
+
|
155
|
+
[Fact]
|
156
|
+
public async Task UpdateDependencyWithComments()
|
157
|
+
{
|
158
|
+
await TestUpdateForProject("Microsoft.Build.Traversal", "3.2.0", "4.1.0",
|
159
|
+
// initial
|
160
|
+
projectContents: """
|
161
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
162
|
+
<PropertyGroup>
|
163
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
164
|
+
</PropertyGroup>
|
165
|
+
|
166
|
+
<ItemGroup>
|
167
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
168
|
+
</ItemGroup>
|
169
|
+
</Project>
|
170
|
+
""",
|
171
|
+
additionalFiles: new[]
|
172
|
+
{
|
173
|
+
("global.json", """
|
174
|
+
{
|
175
|
+
// this is a comment
|
176
|
+
"sdk": {
|
177
|
+
"version": "6.0.405",
|
178
|
+
"rollForward": "latestPatch"
|
179
|
+
},
|
180
|
+
"msbuild-sdks": {
|
181
|
+
// this is a deep comment
|
182
|
+
"Microsoft.Build.Traversal": "3.2.0"
|
183
|
+
}
|
184
|
+
}
|
185
|
+
""")
|
186
|
+
},
|
187
|
+
// expected
|
188
|
+
expectedProjectContents: """
|
189
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
190
|
+
<PropertyGroup>
|
191
|
+
<TargetFramework>netstandard2.0</TargetFramework>
|
192
|
+
</PropertyGroup>
|
193
|
+
|
194
|
+
<ItemGroup>
|
195
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
196
|
+
</ItemGroup>
|
197
|
+
</Project>
|
198
|
+
""",
|
199
|
+
additionalFilesExpected: new[]
|
200
|
+
{
|
201
|
+
("global.json", """
|
202
|
+
{
|
203
|
+
// this is a comment
|
204
|
+
"sdk": {
|
205
|
+
"version": "6.0.405",
|
206
|
+
"rollForward": "latestPatch"
|
207
|
+
},
|
208
|
+
"msbuild-sdks": {
|
209
|
+
// this is a deep comment
|
210
|
+
"Microsoft.Build.Traversal": "4.1.0"
|
211
|
+
}
|
212
|
+
}
|
213
|
+
""")
|
214
|
+
});
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
using System.Collections.Generic;
|
2
|
+
using System.Threading.Tasks;
|
3
|
+
|
4
|
+
using Xunit;
|
5
|
+
|
6
|
+
namespace NuGetUpdater.Core.Test.Update;
|
7
|
+
|
8
|
+
public partial class UpdateWorkerTests
|
9
|
+
{
|
10
|
+
public class Mixed : UpdateWorkerTestBase
|
11
|
+
{
|
12
|
+
public Mixed()
|
13
|
+
{
|
14
|
+
MSBuildHelper.RegisterMSBuild();
|
15
|
+
}
|
16
|
+
|
17
|
+
[Fact]
|
18
|
+
public async Task ForPackagesProject_UpdatePackageReference_InBuildProps()
|
19
|
+
{
|
20
|
+
// update Newtonsoft.Json from 7.0.1 to 13.0.1
|
21
|
+
await TestUpdateForProject("Newtonsoft.Json", "7.0.1", "13.0.1",
|
22
|
+
// existing
|
23
|
+
projectContents: """
|
24
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
25
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
26
|
+
<PropertyGroup>
|
27
|
+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
28
|
+
</PropertyGroup>
|
29
|
+
<ItemGroup>
|
30
|
+
<None Include="packages.config" />
|
31
|
+
</ItemGroup>
|
32
|
+
<ItemGroup>
|
33
|
+
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
34
|
+
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
35
|
+
<Private>True</Private>
|
36
|
+
</Reference>
|
37
|
+
</ItemGroup>
|
38
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
39
|
+
</Project>
|
40
|
+
""",
|
41
|
+
additionalFiles: new[]
|
42
|
+
{
|
43
|
+
("packages.config", """
|
44
|
+
<?xml version="1.0" encoding="utf-8"?>
|
45
|
+
<packages>
|
46
|
+
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net45" />
|
47
|
+
</packages>
|
48
|
+
"""),
|
49
|
+
("Directory.Build.props", """
|
50
|
+
<Project>
|
51
|
+
<ItemGroup>
|
52
|
+
<PackageReference Include="Newtonsoft.Json" Version="7.0.1" />
|
53
|
+
</ItemGroup>
|
54
|
+
</Project>
|
55
|
+
"""),
|
56
|
+
},
|
57
|
+
// expected
|
58
|
+
expectedProjectContents: """
|
59
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
60
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
61
|
+
<PropertyGroup>
|
62
|
+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
63
|
+
</PropertyGroup>
|
64
|
+
<ItemGroup>
|
65
|
+
<None Include="packages.config" />
|
66
|
+
</ItemGroup>
|
67
|
+
<ItemGroup>
|
68
|
+
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
69
|
+
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
70
|
+
<Private>True</Private>
|
71
|
+
</Reference>
|
72
|
+
</ItemGroup>
|
73
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
74
|
+
</Project>
|
75
|
+
""",
|
76
|
+
additionalFilesExpected: new[]
|
77
|
+
{
|
78
|
+
("packages.config", """
|
79
|
+
<?xml version="1.0" encoding="utf-8"?>
|
80
|
+
<packages>
|
81
|
+
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net45" />
|
82
|
+
</packages>
|
83
|
+
"""),
|
84
|
+
("Directory.Build.props", """
|
85
|
+
<Project>
|
86
|
+
<ItemGroup>
|
87
|
+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
88
|
+
</ItemGroup>
|
89
|
+
</Project>
|
90
|
+
"""),
|
91
|
+
});
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|