dependabot-nuget 0.279.0 → 0.281.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/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +4 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +4 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs +4 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/RunCommand.cs +4 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs +3 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +7 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.FrameworkCheck.cs +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Run.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +3 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +17 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/CompatabilityChecker.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyFinder.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/NuGetContext.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +5 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscovery.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +10 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ErrorType.cs +2 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/DotNetToolsJsonBuildFile.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/GlobalJsonBuildFile.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/NativeResult.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/JobErrorBase.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/UpdateNotPossible.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +9 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/UpdateNotPossibleException.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +5 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +4 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs +12 -12
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +29 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ConsoleLogger.cs +9 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +14 -16
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ILogger.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +22 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTestBase.cs +6 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/CompatibilityCheckerTests.cs +7 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +6 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/DotNetToolsJsonBuildFileTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/CompatibilityCheckerFacts.cs +4 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestLogger.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/ExpectedUpdateOperationResult.cs +8 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +15 -12
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DirsProj.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +223 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +16 -16
- data/lib/dependabot/nuget/file_updater.rb +1 -0
- data/lib/dependabot/nuget/native_helpers.rb +15 -19
- metadata +13 -8
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/Logger.cs +0 -21
@@ -739,7 +739,7 @@ public partial class AnalyzeWorkerTests : AnalyzeWorkerTestBase
|
|
739
739
|
ErrorDetails = "<some package feed>",
|
740
740
|
UpdatedVersion = "",
|
741
741
|
UpdatedDependencies = [],
|
742
|
-
}, new
|
742
|
+
}, new TestLogger());
|
743
743
|
var discoveryContents = await File.ReadAllTextAsync(Path.Combine(temporaryDirectory.DirectoryPath, "Some.Dependency.json"));
|
744
744
|
|
745
745
|
// raw result file should look like this:
|
@@ -30,7 +30,7 @@ public class CompatibilityCheckerTests
|
|
30
30
|
projectFrameworks,
|
31
31
|
isDevDependency,
|
32
32
|
packageFrameworks,
|
33
|
-
new
|
33
|
+
new TestLogger());
|
34
34
|
|
35
35
|
Assert.True(result);
|
36
36
|
}
|
@@ -53,7 +53,7 @@ public class CompatibilityCheckerTests
|
|
53
53
|
projectFrameworks,
|
54
54
|
isDevDependency,
|
55
55
|
packageFrameworks,
|
56
|
-
new
|
56
|
+
new TestLogger());
|
57
57
|
|
58
58
|
Assert.False(result);
|
59
59
|
}
|
@@ -76,7 +76,7 @@ public class CompatibilityCheckerTests
|
|
76
76
|
projectFrameworks,
|
77
77
|
isDevDependency,
|
78
78
|
packageFrameworks,
|
79
|
-
new
|
79
|
+
new TestLogger());
|
80
80
|
|
81
81
|
Assert.False(result);
|
82
82
|
}
|
@@ -97,7 +97,7 @@ public class CompatibilityCheckerTests
|
|
97
97
|
projectFrameworks,
|
98
98
|
isDevDependency,
|
99
99
|
packageFrameworks,
|
100
|
-
new
|
100
|
+
new TestLogger());
|
101
101
|
|
102
102
|
Assert.True(result);
|
103
103
|
}
|
@@ -118,7 +118,7 @@ public class CompatibilityCheckerTests
|
|
118
118
|
projectFrameworks,
|
119
119
|
isDevDependency,
|
120
120
|
packageFrameworks,
|
121
|
-
new
|
121
|
+
new TestLogger());
|
122
122
|
|
123
123
|
Assert.False(result);
|
124
124
|
}
|
@@ -138,7 +138,7 @@ public class CompatibilityCheckerTests
|
|
138
138
|
projectFrameworks,
|
139
139
|
isDevDependency,
|
140
140
|
packageFrameworks,
|
141
|
-
new
|
141
|
+
new TestLogger());
|
142
142
|
|
143
143
|
Assert.False(result);
|
144
144
|
}
|
@@ -161,7 +161,7 @@ public class CompatibilityCheckerTests
|
|
161
161
|
projectFrameworks,
|
162
162
|
isDevDependency,
|
163
163
|
packageFrameworks,
|
164
|
-
new
|
164
|
+
new TestLogger());
|
165
165
|
|
166
166
|
Assert.True(result);
|
167
167
|
}
|
@@ -24,8 +24,9 @@ public class DiscoveryWorkerTestBase
|
|
24
24
|
{
|
25
25
|
await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(packages, directoryPath);
|
26
26
|
|
27
|
-
var worker = new DiscoveryWorker(new
|
28
|
-
await worker.
|
27
|
+
var worker = new DiscoveryWorker(new TestLogger());
|
28
|
+
var result = await worker.RunWithErrorHandlingAsync(directoryPath, workspacePath);
|
29
|
+
return result;
|
29
30
|
});
|
30
31
|
|
31
32
|
ValidateWorkspaceResult(expectedResult, actualResult);
|
@@ -108,18 +109,14 @@ public class DiscoveryWorkerTestBase
|
|
108
109
|
}
|
109
110
|
}
|
110
111
|
|
111
|
-
protected static async Task<WorkspaceDiscoveryResult> RunDiscoveryAsync(TestFile[] files, Func<string, Task
|
112
|
+
protected static async Task<WorkspaceDiscoveryResult> RunDiscoveryAsync(TestFile[] files, Func<string, Task<WorkspaceDiscoveryResult>> action)
|
112
113
|
{
|
113
114
|
// write initial files
|
114
115
|
using var temporaryDirectory = await TemporaryDirectory.CreateWithContentsAsync(files);
|
115
116
|
|
116
117
|
// run discovery
|
117
|
-
await action(temporaryDirectory.DirectoryPath);
|
118
|
-
|
119
|
-
// gather results
|
120
|
-
var resultPath = Path.Join(temporaryDirectory.DirectoryPath, DiscoveryWorker.DiscoveryResultFileName);
|
121
|
-
var resultJson = await File.ReadAllTextAsync(resultPath);
|
122
|
-
return JsonSerializer.Deserialize<WorkspaceDiscoveryResult>(resultJson, DiscoveryWorker.SerializerOptions)!;
|
118
|
+
var result = await action(temporaryDirectory.DirectoryPath);
|
119
|
+
return result;
|
123
120
|
}
|
124
121
|
|
125
122
|
internal class PropertyComparer : IEqualityComparer<Property>
|
@@ -32,7 +32,7 @@ public class DotnetToolsJsonBuildFileTests
|
|
32
32
|
basePath: "/",
|
33
33
|
path: "/.config/dotnet-tools.json",
|
34
34
|
contents: DotnetToolsJson,
|
35
|
-
logger: new
|
35
|
+
logger: new TestLogger());
|
36
36
|
|
37
37
|
[Fact]
|
38
38
|
public void GetDependencies_ReturnsDependencies()
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/FrameworkChecker/CompatibilityCheckerFacts.cs
CHANGED
@@ -20,7 +20,7 @@ public class CompatibilityCheckerFacts
|
|
20
20
|
[InlineData("net4.8", "netstandard1.3")]
|
21
21
|
public void PackageContainsCompatibleFramework(string projectTfm, string packageTfm)
|
22
22
|
{
|
23
|
-
var result = CompatibilityChecker.IsCompatible([projectTfm], [packageTfm], new
|
23
|
+
var result = CompatibilityChecker.IsCompatible([projectTfm], [packageTfm], new TestLogger());
|
24
24
|
|
25
25
|
Assert.True(result);
|
26
26
|
}
|
@@ -37,7 +37,7 @@ public class CompatibilityCheckerFacts
|
|
37
37
|
[InlineData("net7.0", "net48")]
|
38
38
|
public void PackageContainsIncompatibleFramework(string projectTfm, string packageTfm)
|
39
39
|
{
|
40
|
-
var result = CompatibilityChecker.IsCompatible([projectTfm], [packageTfm], new
|
40
|
+
var result = CompatibilityChecker.IsCompatible([projectTfm], [packageTfm], new TestLogger());
|
41
41
|
|
42
42
|
Assert.False(result);
|
43
43
|
}
|
@@ -48,7 +48,7 @@ public class CompatibilityCheckerFacts
|
|
48
48
|
[InlineData(new[] { "net6.0", "net6.0-windows10.0.19041" }, new[] { "net6.0", ".NETStandard2.0" })]
|
49
49
|
public void PackageContainsCompatibleFrameworks(string[] projectTfms, string[] packageTfms)
|
50
50
|
{
|
51
|
-
var result = CompatibilityChecker.IsCompatible(projectTfms, packageTfms, new
|
51
|
+
var result = CompatibilityChecker.IsCompatible(projectTfms, packageTfms, new TestLogger());
|
52
52
|
|
53
53
|
Assert.True(result);
|
54
54
|
}
|
@@ -57,7 +57,7 @@ public class CompatibilityCheckerFacts
|
|
57
57
|
[InlineData(new[] { "net7.0", "net472" }, new[] { "net5.0" })]
|
58
58
|
public void PackageContainsIncompatibleFrameworks(string[] projectTfms, string[] packageTfms)
|
59
59
|
{
|
60
|
-
var result = CompatibilityChecker.IsCompatible(projectTfms, packageTfms, new
|
60
|
+
var result = CompatibilityChecker.IsCompatible(projectTfms, packageTfms, new TestLogger());
|
61
61
|
|
62
62
|
Assert.False(result);
|
63
63
|
}
|
@@ -276,7 +276,7 @@ public class RunWorkerTests
|
|
276
276
|
|
277
277
|
// act
|
278
278
|
var testApiHandler = new TestApiHandler();
|
279
|
-
var worker = new RunWorker(testApiHandler, new
|
279
|
+
var worker = new RunWorker(testApiHandler, new TestLogger());
|
280
280
|
var repoContentsPath = new DirectoryInfo(tempDirectory.DirectoryPath);
|
281
281
|
var actualResult = await worker.RunAsync(job, repoContentsPath, "TEST-COMMIT-SHA");
|
282
282
|
var actualApiMessages = testApiHandler.ReceivedMessages.ToArray();
|
@@ -1,5 +1,4 @@
|
|
1
|
-
using
|
2
|
-
|
1
|
+
using NuGetUpdater.Core.Test.Updater;
|
3
2
|
using NuGetUpdater.Core.Updater;
|
4
3
|
|
5
4
|
using Xunit;
|
@@ -93,7 +92,7 @@ public abstract class UpdateWorkerTestBase : TestBase
|
|
93
92
|
TestFile[]? additionalFilesExpected = null,
|
94
93
|
MockNuGetPackage[]? packages = null,
|
95
94
|
string projectFilePath = "test-project.csproj",
|
96
|
-
|
95
|
+
ExpectedUpdateOperationResult? expectedResult = null)
|
97
96
|
=> TestUpdateForProject(
|
98
97
|
dependencyName,
|
99
98
|
oldVersion,
|
@@ -116,7 +115,7 @@ public abstract class UpdateWorkerTestBase : TestBase
|
|
116
115
|
TestFile[]? additionalFiles = null,
|
117
116
|
TestFile[]? additionalFilesExpected = null,
|
118
117
|
MockNuGetPackage[]? packages = null,
|
119
|
-
|
118
|
+
ExpectedUpdateOperationResult? expectedResult = null)
|
120
119
|
{
|
121
120
|
additionalFiles ??= [];
|
122
121
|
additionalFilesExpected ??= [];
|
@@ -135,12 +134,9 @@ public abstract class UpdateWorkerTestBase : TestBase
|
|
135
134
|
await MockNuGetPackagesInDirectory(packages, temporaryDirectory);
|
136
135
|
|
137
136
|
// run update
|
138
|
-
var worker = new UpdaterWorker(new
|
137
|
+
var worker = new UpdaterWorker(new TestLogger());
|
139
138
|
var projectPath = placeFilesInSrc ? $"src/{projectFilePath}" : projectFilePath;
|
140
|
-
var
|
141
|
-
await worker.RunAsync(temporaryDirectory, projectPath, dependencyName, oldVersion, newVersion, isTransitive, updateResultFile);
|
142
|
-
var actualResultContents = await File.ReadAllTextAsync(updateResultFile);
|
143
|
-
var actualResult = JsonSerializer.Deserialize<UpdateOperationResult>(actualResultContents, UpdaterWorker.SerializerOptions);
|
139
|
+
var actualResult = await worker.RunWithErrorHandlingAsync(temporaryDirectory, projectPath, dependencyName, oldVersion, newVersion, isTransitive);
|
144
140
|
if (expectedResult is { })
|
145
141
|
{
|
146
142
|
ValidateUpdateOperationResult(expectedResult, actualResult!);
|
@@ -156,10 +152,17 @@ public abstract class UpdateWorkerTestBase : TestBase
|
|
156
152
|
AssertContainsFiles(expectedResultFiles, actualResult);
|
157
153
|
}
|
158
154
|
|
159
|
-
protected static void ValidateUpdateOperationResult(
|
155
|
+
protected static void ValidateUpdateOperationResult(ExpectedUpdateOperationResult expectedResult, UpdateOperationResult actualResult)
|
160
156
|
{
|
161
157
|
Assert.Equal(expectedResult.ErrorType, actualResult.ErrorType);
|
162
|
-
|
158
|
+
if (expectedResult.ErrorDetailsRegex is not null && actualResult.ErrorDetails is string errorDetails)
|
159
|
+
{
|
160
|
+
Assert.Matches(expectedResult.ErrorDetailsRegex, errorDetails);
|
161
|
+
}
|
162
|
+
else
|
163
|
+
{
|
164
|
+
Assert.Equivalent(expectedResult.ErrorDetails, actualResult.ErrorDetails);
|
165
|
+
}
|
163
166
|
}
|
164
167
|
|
165
168
|
protected static Task TestNoChangeforSolution(
|
@@ -234,7 +237,7 @@ public abstract class UpdateWorkerTestBase : TestBase
|
|
234
237
|
await MockNuGetPackagesInDirectory(packages, temporaryDirectory);
|
235
238
|
|
236
239
|
var slnPath = Path.Combine(temporaryDirectory, slnName);
|
237
|
-
var worker = new UpdaterWorker(new
|
240
|
+
var worker = new UpdaterWorker(new TestLogger());
|
238
241
|
await worker.RunAsync(temporaryDirectory, slnPath, dependencyName, oldVersion, newVersion, isTransitive);
|
239
242
|
});
|
240
243
|
|
@@ -364,7 +364,7 @@ public partial class UpdateWorkerTests
|
|
364
364
|
await MockNuGetPackagesInDirectory(packages, temporaryDirectory);
|
365
365
|
|
366
366
|
var projectPath = Path.Combine(temporaryDirectory, projectFileName);
|
367
|
-
var worker = new UpdaterWorker(new
|
367
|
+
var worker = new UpdaterWorker(new TestLogger());
|
368
368
|
await worker.RunAsync(temporaryDirectory, projectPath, dependencyName, oldVersion, newVersion, isTransitive);
|
369
369
|
});
|
370
370
|
|
@@ -20,7 +20,7 @@ public partial class UpdateWorkerTests
|
|
20
20
|
ErrorDetails = "<some package feed>",
|
21
21
|
};
|
22
22
|
var resultFilePath = Path.Combine(temporaryDirectory.DirectoryPath, "update-result.json");
|
23
|
-
await UpdaterWorker.WriteResultFile(result, resultFilePath, new
|
23
|
+
await UpdaterWorker.WriteResultFile(result, resultFilePath, new TestLogger());
|
24
24
|
var resultContent = await File.ReadAllTextAsync(resultFilePath);
|
25
25
|
|
26
26
|
// raw result file should look like this:
|
data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs
CHANGED
@@ -4,6 +4,7 @@ using System.Text.Json;
|
|
4
4
|
|
5
5
|
using NuGet;
|
6
6
|
|
7
|
+
using NuGetUpdater.Core.Test.Updater;
|
7
8
|
using NuGetUpdater.Core.Updater;
|
8
9
|
|
9
10
|
using Xunit;
|
@@ -603,8 +604,12 @@ public partial class UpdateWorkerTests
|
|
603
604
|
);
|
604
605
|
}
|
605
606
|
|
606
|
-
|
607
|
-
|
607
|
+
// the xml can take various shapes and they're all formatted, so we need very specific values here
|
608
|
+
[Theory]
|
609
|
+
[InlineData("<Content Include=\"web.config\" />")]
|
610
|
+
[InlineData("<Content Include=\"web.config\">\n </Content>")]
|
611
|
+
[InlineData("<Content Include=\"web.config\">\n <SubType>Designer</SubType>\n </Content>")]
|
612
|
+
public async Task UpdateBindingRedirectInWebConfig(string webConfigXml)
|
608
613
|
{
|
609
614
|
await TestUpdateForProject("Some.Package", "7.0.1", "13.0.1",
|
610
615
|
packages:
|
@@ -612,7 +617,7 @@ public partial class UpdateWorkerTests
|
|
612
617
|
MockNuGetPackage.CreatePackageWithAssembly("Some.Package", "7.0.1", "net45", "7.0.0.0"),
|
613
618
|
MockNuGetPackage.CreatePackageWithAssembly("Some.Package", "13.0.1", "net45", "13.0.0.0"),
|
614
619
|
],
|
615
|
-
projectContents: """
|
620
|
+
projectContents: $$"""
|
616
621
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
617
622
|
<PropertyGroup>
|
618
623
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
@@ -669,7 +674,7 @@ public partial class UpdateWorkerTests
|
|
669
674
|
</ItemGroup>
|
670
675
|
<ItemGroup>
|
671
676
|
<None Include="packages.config" />
|
672
|
-
|
677
|
+
{{webConfigXml}}
|
673
678
|
<Content Include="web.Debug.config">
|
674
679
|
<DependentUpon>web.config</DependentUpon>
|
675
680
|
</Content>
|
@@ -711,7 +716,7 @@ public partial class UpdateWorkerTests
|
|
711
716
|
</configuration>
|
712
717
|
""")
|
713
718
|
],
|
714
|
-
expectedProjectContents: """
|
719
|
+
expectedProjectContents: $$"""
|
715
720
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
716
721
|
<PropertyGroup>
|
717
722
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
@@ -768,7 +773,7 @@ public partial class UpdateWorkerTests
|
|
768
773
|
</ItemGroup>
|
769
774
|
<ItemGroup>
|
770
775
|
<None Include="packages.config" />
|
771
|
-
|
776
|
+
{{webConfigXml}}
|
772
777
|
<Content Include="web.Debug.config">
|
773
778
|
<DependentUpon>web.config</DependentUpon>
|
774
779
|
</Content>
|
@@ -2100,13 +2105,13 @@ public partial class UpdateWorkerTests
|
|
2100
2105
|
await MockNuGetPackagesInDirectory(packages, Path.Combine(temporaryDirectory.DirectoryPath, "packages"));
|
2101
2106
|
var resultOutputPath = Path.Combine(temporaryDirectory.DirectoryPath, "result.json");
|
2102
2107
|
|
2103
|
-
var worker = new UpdaterWorker(new
|
2108
|
+
var worker = new UpdaterWorker(new TestLogger());
|
2104
2109
|
await worker.RunAsync(temporaryDirectory.DirectoryPath, "project.csproj", "Some.Package", "1.0.0", "1.1.0", isTransitive: false, resultOutputPath: resultOutputPath);
|
2105
2110
|
|
2106
2111
|
var resultContents = await File.ReadAllTextAsync(resultOutputPath);
|
2107
2112
|
var result = JsonSerializer.Deserialize<UpdateOperationResult>(resultContents, UpdaterWorker.SerializerOptions)!;
|
2108
2113
|
Assert.Equal(ErrorType.MissingFile, result.ErrorType);
|
2109
|
-
Assert.Equal(Path.Combine(temporaryDirectory.DirectoryPath, "this.file.does.not.exist.targets"), result.ErrorDetails);
|
2114
|
+
Assert.Equal(Path.Combine(temporaryDirectory.DirectoryPath, "this.file.does.not.exist.targets"), result.ErrorDetails.ToString());
|
2110
2115
|
}
|
2111
2116
|
|
2112
2117
|
[Fact]
|
@@ -2190,6 +2195,215 @@ public partial class UpdateWorkerTests
|
|
2190
2195
|
);
|
2191
2196
|
}
|
2192
2197
|
|
2198
|
+
[Fact]
|
2199
|
+
public async Task ReportsUnexpectedResponseFromNuGetServer()
|
2200
|
+
{
|
2201
|
+
static (int, string) TestHttpHandler(string uriString)
|
2202
|
+
{
|
2203
|
+
var uri = new Uri(uriString, UriKind.Absolute);
|
2204
|
+
var baseUrl = $"{uri.Scheme}://{uri.Host}:{uri.Port}";
|
2205
|
+
return uri.PathAndQuery switch
|
2206
|
+
{
|
2207
|
+
// initial and search query are good, update should be possible...
|
2208
|
+
"/index.json" => (200, $$"""
|
2209
|
+
{
|
2210
|
+
"version": "3.0.0",
|
2211
|
+
"resources": [
|
2212
|
+
{
|
2213
|
+
"@id": "{{baseUrl}}/download",
|
2214
|
+
"@type": "PackageBaseAddress/3.0.0"
|
2215
|
+
},
|
2216
|
+
{
|
2217
|
+
"@id": "{{baseUrl}}/query",
|
2218
|
+
"@type": "SearchQueryService"
|
2219
|
+
},
|
2220
|
+
{
|
2221
|
+
"@id": "{{baseUrl}}/registrations",
|
2222
|
+
"@type": "RegistrationsBaseUrl"
|
2223
|
+
}
|
2224
|
+
]
|
2225
|
+
}
|
2226
|
+
"""),
|
2227
|
+
"/registrations/some.package/index.json" => (200, $$"""
|
2228
|
+
{
|
2229
|
+
"count": 1,
|
2230
|
+
"items": [
|
2231
|
+
{
|
2232
|
+
"lower": "1.0.0",
|
2233
|
+
"upper": "1.1.0",
|
2234
|
+
"items": [
|
2235
|
+
{
|
2236
|
+
"catalogEntry": {
|
2237
|
+
"id": "Some.Package",
|
2238
|
+
"listed": true,
|
2239
|
+
"version": "1.0.0"
|
2240
|
+
},
|
2241
|
+
"packageContent": "{{baseUrl}}/download/some.package/1.0.0/some.package.1.0.0.nupkg",
|
2242
|
+
},
|
2243
|
+
{
|
2244
|
+
"catalogEntry": {
|
2245
|
+
"id": "Some.Package",
|
2246
|
+
"listed": true,
|
2247
|
+
"version": "1.1.0"
|
2248
|
+
},
|
2249
|
+
"packageContent": "{{baseUrl}}/download/some.package/1.1.0/some.package.1.1.0.nupkg",
|
2250
|
+
}
|
2251
|
+
]
|
2252
|
+
}
|
2253
|
+
]
|
2254
|
+
}
|
2255
|
+
"""),
|
2256
|
+
// ...but all other calls to the server fail
|
2257
|
+
_ => (500, "{}"),
|
2258
|
+
};
|
2259
|
+
}
|
2260
|
+
using var http = TestHttpServer.CreateTestStringServer(TestHttpHandler);
|
2261
|
+
await TestUpdateForProject("Some.Package", "1.0.0", "1.1.0",
|
2262
|
+
// existing
|
2263
|
+
projectContents: """
|
2264
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
2265
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
2266
|
+
<PropertyGroup>
|
2267
|
+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
2268
|
+
</PropertyGroup>
|
2269
|
+
<ItemGroup>
|
2270
|
+
<None Include="packages.config" />
|
2271
|
+
</ItemGroup>
|
2272
|
+
<ItemGroup>
|
2273
|
+
<Reference Include="Some.Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
2274
|
+
<HintPath>packages\Some.Package.1.0.0\lib\net45\Some.Package.dll</HintPath>
|
2275
|
+
<Private>True</Private>
|
2276
|
+
</Reference>
|
2277
|
+
</ItemGroup>
|
2278
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
2279
|
+
</Project>
|
2280
|
+
""",
|
2281
|
+
packagesConfigContents: """
|
2282
|
+
<packages>
|
2283
|
+
<package id="Some.Package" version="1.0.0" targetFramework="net45" />
|
2284
|
+
</packages>
|
2285
|
+
""",
|
2286
|
+
additionalFiles:
|
2287
|
+
[
|
2288
|
+
("NuGet.Config", $"""
|
2289
|
+
<configuration>
|
2290
|
+
<packageSources>
|
2291
|
+
<clear />
|
2292
|
+
<add key="private_feed" value="{http.BaseUrl.TrimEnd('/')}/index.json" allowInsecureConnections="true" />
|
2293
|
+
</packageSources>
|
2294
|
+
</configuration>
|
2295
|
+
""")
|
2296
|
+
],
|
2297
|
+
// expected
|
2298
|
+
expectedProjectContents: """
|
2299
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
2300
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
2301
|
+
<PropertyGroup>
|
2302
|
+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
2303
|
+
</PropertyGroup>
|
2304
|
+
<ItemGroup>
|
2305
|
+
<None Include="packages.config" />
|
2306
|
+
</ItemGroup>
|
2307
|
+
<ItemGroup>
|
2308
|
+
<Reference Include="Some.Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
2309
|
+
<HintPath>packages\Some.Package.1.0.0\lib\net45\Some.Package.dll</HintPath>
|
2310
|
+
<Private>True</Private>
|
2311
|
+
</Reference>
|
2312
|
+
</ItemGroup>
|
2313
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
2314
|
+
</Project>
|
2315
|
+
""",
|
2316
|
+
expectedPackagesConfigContents: """
|
2317
|
+
<packages>
|
2318
|
+
<package id="Some.Package" version="1.0.0" targetFramework="net45" />
|
2319
|
+
</packages>
|
2320
|
+
""",
|
2321
|
+
expectedResult: new()
|
2322
|
+
{
|
2323
|
+
ErrorType = ErrorType.Unknown,
|
2324
|
+
ErrorDetailsRegex = "Response status code does not indicate success",
|
2325
|
+
}
|
2326
|
+
);
|
2327
|
+
}
|
2328
|
+
|
2329
|
+
[Fact]
|
2330
|
+
public async Task MissingDependencyErrorIsReported()
|
2331
|
+
{
|
2332
|
+
// trying to update Some.Package from 1.0.1 to 1.0.2, but another package isn't available; update fails
|
2333
|
+
await TestUpdateForProject("Some.Package", "1.0.1", "1.0.2",
|
2334
|
+
packages:
|
2335
|
+
[
|
2336
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.1", "net45"),
|
2337
|
+
MockNuGetPackage.CreateSimplePackage("Some.Package", "1.0.2", "net45"),
|
2338
|
+
|
2339
|
+
// the package `Unrelated.Package/1.0.0` is missing and will cause the update to fail
|
2340
|
+
],
|
2341
|
+
// existing
|
2342
|
+
projectContents: """
|
2343
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
2344
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
2345
|
+
<PropertyGroup>
|
2346
|
+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
2347
|
+
</PropertyGroup>
|
2348
|
+
<ItemGroup>
|
2349
|
+
<None Include="packages.config" />
|
2350
|
+
</ItemGroup>
|
2351
|
+
<ItemGroup>
|
2352
|
+
<Reference Include="Some.Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
2353
|
+
<HintPath>packages\Some.Package.1.0.1\lib\net45\Some.Package.dll</HintPath>
|
2354
|
+
<Private>True</Private>
|
2355
|
+
</Reference>
|
2356
|
+
<Reference Include="Unrelated.Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
2357
|
+
<HintPath>packages\Unrelated.Package.1.0.0\lib\net45\Unrelated.Package.dll</HintPath>
|
2358
|
+
<Private>True</Private>
|
2359
|
+
</Reference>
|
2360
|
+
</ItemGroup>
|
2361
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
2362
|
+
</Project>
|
2363
|
+
""",
|
2364
|
+
packagesConfigContents: """
|
2365
|
+
<packages>
|
2366
|
+
<package id="Some.Package" version="1.0.1" targetFramework="net45" />
|
2367
|
+
<package id="Unrelated.Package" version="1.0.0" targetFramework="net45" />
|
2368
|
+
</packages>
|
2369
|
+
""",
|
2370
|
+
// expected
|
2371
|
+
expectedProjectContents: """
|
2372
|
+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
2373
|
+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
2374
|
+
<PropertyGroup>
|
2375
|
+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
2376
|
+
</PropertyGroup>
|
2377
|
+
<ItemGroup>
|
2378
|
+
<None Include="packages.config" />
|
2379
|
+
</ItemGroup>
|
2380
|
+
<ItemGroup>
|
2381
|
+
<Reference Include="Some.Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
2382
|
+
<HintPath>packages\Some.Package.1.0.1\lib\net45\Some.Package.dll</HintPath>
|
2383
|
+
<Private>True</Private>
|
2384
|
+
</Reference>
|
2385
|
+
<Reference Include="Unrelated.Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
|
2386
|
+
<HintPath>packages\Unrelated.Package.1.0.0\lib\net45\Unrelated.Package.dll</HintPath>
|
2387
|
+
<Private>True</Private>
|
2388
|
+
</Reference>
|
2389
|
+
</ItemGroup>
|
2390
|
+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
2391
|
+
</Project>
|
2392
|
+
""",
|
2393
|
+
expectedPackagesConfigContents: """
|
2394
|
+
<packages>
|
2395
|
+
<package id="Some.Package" version="1.0.1" targetFramework="net45" />
|
2396
|
+
<package id="Unrelated.Package" version="1.0.0" targetFramework="net45" />
|
2397
|
+
</packages>
|
2398
|
+
""",
|
2399
|
+
expectedResult: new()
|
2400
|
+
{
|
2401
|
+
ErrorType = ErrorType.UpdateNotPossible,
|
2402
|
+
ErrorDetails = new[] { "Unrelated.Package.1.0.0" },
|
2403
|
+
}
|
2404
|
+
);
|
2405
|
+
}
|
2406
|
+
|
2193
2407
|
protected static Task TestUpdateForProject(
|
2194
2408
|
string dependencyName,
|
2195
2409
|
string oldVersion,
|
@@ -2201,7 +2415,7 @@ public partial class UpdateWorkerTests
|
|
2201
2415
|
(string Path, string Content)[]? additionalFiles = null,
|
2202
2416
|
(string Path, string Content)[]? additionalFilesExpected = null,
|
2203
2417
|
MockNuGetPackage[]? packages = null,
|
2204
|
-
|
2418
|
+
ExpectedUpdateOperationResult? expectedResult = null)
|
2205
2419
|
{
|
2206
2420
|
var realizedAdditionalFiles = new List<(string Path, string Content)>
|
2207
2421
|
{
|
@@ -454,7 +454,7 @@ public partial class UpdateWorkerTests
|
|
454
454
|
//
|
455
455
|
// do the update
|
456
456
|
//
|
457
|
-
UpdaterWorker worker = new(new(
|
457
|
+
UpdaterWorker worker = new(new TestLogger());
|
458
458
|
await worker.RunAsync(tempDirectory.DirectoryPath, projectPath, "Some.Package", "1.0.0", "1.1.0", isTransitive: false);
|
459
459
|
|
460
460
|
//
|