dependabot-nuget 0.241.0 → 0.242.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4785ffa6c4f7a334d8c7d57932d82420af791410a4ebfe9a38f2ee73da5d271
4
- data.tar.gz: 0cfcaa2b152867cccce8907eb64d98a72d217626467ee25bfb5ea2bb1839e0c0
3
+ metadata.gz: 11b0607da6a75d27dbe0c012d5b3917a226fd3da340cbcc59bf70dc1ab49dea3
4
+ data.tar.gz: f757ea68e946791be5d44df566a91dff248f98c60be84253a25d399c24b881bd
5
5
  SHA512:
6
- metadata.gz: f3dd5df35c8cd6e2991e61c6327f9144c6c600578c477309b7a0624a0a768d356fada0d2e33e3a9d5695cb8c8271e75e639f0b5246db9795c97425d23e1ae99f
7
- data.tar.gz: b8424ae0c6d11cba9066601d4db01e16e2382d633814b091cd5ae14f38da505d6504bed7c2285eb634bf173a1353245bbefeaedeee26b8cbebf513c1188955cb
6
+ metadata.gz: cce478626cb19d1d3daec2b23b2448445ddbf02fde1ffa80cd1372600852cb9e7c5fc2026303f9dfb8de3938870db16a2b531c04b160ede96c7c473bb673b3e3
7
+ data.tar.gz: 9f084e5dfc866baa1b38cb01d2a55a9c6738b1e06703961fb33676353e4fda8095c36a951bb0a3515c503fe351582089b93d0faeac709e3e3e4f3706b158ec09
@@ -1,3 +1,3 @@
1
1
  namespace NuGetUpdater.Core;
2
2
 
3
- public sealed record Dependency(string Name, string? Version, DependencyType Type, bool IsDevDependency = false, bool IsOverride = false);
3
+ public sealed record Dependency(string Name, string? Version, DependencyType Type, bool IsDevDependency = false, bool IsOverride = false, bool IsUpdate = false);
@@ -1,4 +1,3 @@
1
- using System;
2
1
  using System.Collections.Generic;
3
2
  using System.IO;
4
3
  using System.Linq;
@@ -8,11 +7,11 @@ namespace NuGetUpdater.Core;
8
7
 
9
8
  internal sealed class DotNetToolsJsonBuildFile : JsonBuildFile
10
9
  {
11
- public static DotNetToolsJsonBuildFile Open(string repoRootPath, string path)
12
- => new(repoRootPath, path, File.ReadAllText(path));
10
+ public static DotNetToolsJsonBuildFile Open(string repoRootPath, string path, Logger logger)
11
+ => new(repoRootPath, path, File.ReadAllText(path), logger);
13
12
 
14
- public DotNetToolsJsonBuildFile(string repoRootPath, string path, string contents)
15
- : base(repoRootPath, path, contents)
13
+ public DotNetToolsJsonBuildFile(string repoRootPath, string path, string contents, Logger logger)
14
+ : base(repoRootPath, path, contents, logger)
16
15
  {
17
16
  }
18
17
 
@@ -7,18 +7,29 @@ namespace NuGetUpdater.Core;
7
7
 
8
8
  internal sealed class GlobalJsonBuildFile : JsonBuildFile
9
9
  {
10
- public static GlobalJsonBuildFile Open(string repoRootPath, string path)
11
- => new(repoRootPath, path, File.ReadAllText(path));
10
+ public static GlobalJsonBuildFile Open(string repoRootPath, string path, Logger logger)
11
+ => new(repoRootPath, path, File.ReadAllText(path), logger);
12
12
 
13
- public GlobalJsonBuildFile(string repoRootPath, string path, string contents)
14
- : base(repoRootPath, path, contents)
13
+ public GlobalJsonBuildFile(string repoRootPath, string path, string contents, Logger logger)
14
+ : base(repoRootPath, path, contents, logger)
15
15
  {
16
16
  }
17
17
 
18
- public JsonObject? Sdk => Node.Value?["sdk"]?.AsObject();
18
+ public JsonObject? Sdk
19
+ {
20
+ get
21
+ {
22
+ return Node.Value is JsonObject root ? root["sdk"]?.AsObject() : null;
23
+ }
24
+ }
19
25
 
20
- public JsonObject? MSBuildSdks =>
21
- Node.Value?["msbuild-sdks"]?.AsObject();
26
+ public JsonObject? MSBuildSdks
27
+ {
28
+ get
29
+ {
30
+ return Node.Value is JsonObject root ? root["msbuild-sdks"]?.AsObject() : null;
31
+ }
32
+ }
22
33
 
23
34
  public IEnumerable<Dependency> GetDependencies() => MSBuildSdks?.AsObject().Select(
24
35
  t => new Dependency(t.Key, t.Value?.GetValue<string>() ?? string.Empty, DependencyType.MSBuildSdk)) ?? Enumerable.Empty<Dependency>();
@@ -8,11 +8,13 @@ namespace NuGetUpdater.Core;
8
8
  internal abstract class JsonBuildFile : BuildFile<string>
9
9
  {
10
10
  protected Lazy<JsonNode?> Node;
11
+ private readonly Logger logger;
11
12
 
12
- public JsonBuildFile(string repoRootPath, string path, string contents)
13
+ public JsonBuildFile(string repoRootPath, string path, string contents, Logger logger)
13
14
  : base(repoRootPath, path, contents)
14
15
  {
15
16
  Node = new Lazy<JsonNode?>(() => null);
17
+ this.logger = logger;
16
18
  ResetNode();
17
19
  }
18
20
 
@@ -27,6 +29,19 @@ internal abstract class JsonBuildFile : BuildFile<string>
27
29
 
28
30
  private void ResetNode()
29
31
  {
30
- Node = new Lazy<JsonNode?>(() => JsonHelper.ParseNode(Contents));
32
+ Node = new Lazy<JsonNode?>(() =>
33
+ {
34
+ try
35
+ {
36
+ return JsonHelper.ParseNode(Contents);
37
+ }
38
+ catch (System.Text.Json.JsonException ex)
39
+ {
40
+ // We can't police that people have legal JSON files.
41
+ // If they don't, we just return null.
42
+ logger.Log($"Failed to parse JSON file: {RepoRelativePath}, got {ex}");
43
+ return null;
44
+ }
45
+ });
31
46
  }
32
47
  }
@@ -10,7 +10,7 @@ internal static partial class DotNetToolsJsonUpdater
10
10
  {
11
11
  public static async Task UpdateDependencyAsync(string repoRootPath, string dependencyName, string previousDependencyVersion, string newDependencyVersion, Logger logger)
12
12
  {
13
- var buildFiles = LoadBuildFiles(repoRootPath);
13
+ var buildFiles = LoadBuildFiles(repoRootPath, logger);
14
14
  if (buildFiles.Length == 0)
15
15
  {
16
16
  logger.Log($" No dotnet-tools.json files found.");
@@ -49,7 +49,7 @@ internal static partial class DotNetToolsJsonUpdater
49
49
  }
50
50
  }
51
51
 
52
- private static ImmutableArray<DotNetToolsJsonBuildFile> LoadBuildFiles(string repoRootPath)
52
+ private static ImmutableArray<DotNetToolsJsonBuildFile> LoadBuildFiles(string repoRootPath, Logger logger)
53
53
  {
54
54
  var options = new EnumerationOptions()
55
55
  {
@@ -60,7 +60,7 @@ internal static partial class DotNetToolsJsonUpdater
60
60
  MatchCasing = MatchCasing.CaseInsensitive,
61
61
  };
62
62
  return Directory.EnumerateFiles(repoRootPath, "dotnet-tools.json", options)
63
- .Select(path => DotNetToolsJsonBuildFile.Open(repoRootPath, path))
63
+ .Select(path => DotNetToolsJsonBuildFile.Open(repoRootPath, path, logger))
64
64
  .ToImmutableArray();
65
65
  }
66
66
  }
@@ -15,7 +15,7 @@ internal static partial class GlobalJsonUpdater
15
15
  return;
16
16
  }
17
17
 
18
- var globalJsonFile = GlobalJsonBuildFile.Open(repoRootPath, globalJsonPath);
18
+ var globalJsonFile = GlobalJsonBuildFile.Open(repoRootPath, globalJsonPath, logger);
19
19
 
20
20
  logger.Log($" Updating [{globalJsonFile.RepoRelativePath}] file.");
21
21
 
@@ -34,7 +34,7 @@ internal static partial class SdkPackageUpdater
34
34
  foreach (var tfm in tfms)
35
35
  {
36
36
  var dependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(repoRootPath, projectPath, tfm, topLevelDependencies, logger);
37
- foreach (var (packageName, packageVersion, _, _, _) in dependencies)
37
+ foreach (var (packageName, packageVersion, _, _, _, _) in dependencies)
38
38
  {
39
39
  if (packageName.Equals(dependencyName, StringComparison.OrdinalIgnoreCase))
40
40
  {
@@ -76,7 +76,7 @@ internal static partial class SdkPackageUpdater
76
76
  var packagesAndVersions = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
77
77
  foreach (var (tfm, dependencies) in tfmsAndDependencies)
78
78
  {
79
- foreach (var (packageName, packageVersion, _, _, _) in dependencies)
79
+ foreach (var (packageName, packageVersion, _, _, _, _) in dependencies)
80
80
  {
81
81
  if (packagesAndVersions.TryGetValue(packageName, out var existingVersion) &&
82
82
  existingVersion != packageVersion)
@@ -136,7 +136,7 @@ internal static partial class MSBuildHelper
136
136
 
137
137
  public static IEnumerable<Dependency> GetTopLevelPackageDependenyInfos(ImmutableArray<ProjectBuildFile> buildFiles)
138
138
  {
139
- Dictionary<string, string> packageInfo = new(StringComparer.OrdinalIgnoreCase);
139
+ Dictionary<string, (string, bool)> packageInfo = new(StringComparer.OrdinalIgnoreCase);
140
140
  Dictionary<string, string> packageVersionInfo = new(StringComparer.OrdinalIgnoreCase);
141
141
  Dictionary<string, string> propertyInfo = new(StringComparer.OrdinalIgnoreCase);
142
142
 
@@ -154,7 +154,22 @@ internal static partial class MSBuildHelper
154
154
  {
155
155
  if (!string.IsNullOrWhiteSpace(attributeValue))
156
156
  {
157
- packageInfo[attributeValue] = versionSpecification;
157
+ if (packageInfo.TryGetValue(attributeValue, out var existingInfo))
158
+ {
159
+ var existingVersion = existingInfo.Item1;
160
+ var existingUpdate = existingInfo.Item2;
161
+ // Retain the version from the Update reference since the intention
162
+ // would be to override the version of the Include reference.
163
+ var vSpec = string.IsNullOrEmpty(versionSpecification) || existingUpdate ? existingVersion : versionSpecification;
164
+
165
+ var isUpdate = existingUpdate && string.IsNullOrEmpty(packageItem.Include);
166
+ packageInfo[attributeValue] = (vSpec, isUpdate);
167
+ }
168
+ else
169
+ {
170
+ var isUpdate = !string.IsNullOrEmpty(packageItem.Update);
171
+ packageInfo[attributeValue] = (versionSpecification, isUpdate);
172
+ }
158
173
  }
159
174
  }
160
175
  }
@@ -180,8 +195,9 @@ internal static partial class MSBuildHelper
180
195
  }
181
196
  }
182
197
 
183
- foreach (var (name, version) in packageInfo)
198
+ foreach (var (name, info) in packageInfo)
184
199
  {
200
+ var (version, isUpdate) = info;
185
201
  if (version.Length != 0 || !packageVersionInfo.TryGetValue(name, out var packageVersion))
186
202
  {
187
203
  packageVersion = version;
@@ -195,8 +211,8 @@ internal static partial class MSBuildHelper
195
211
  // We don't know the version for range requirements or wildcard
196
212
  // requirements, so return "" for these.
197
213
  yield return packageVersion.Contains(',') || packageVersion.Contains('*')
198
- ? new Dependency(name, string.Empty, DependencyType.Unknown)
199
- : new Dependency(name, packageVersion, DependencyType.Unknown);
214
+ ? new Dependency(name, string.Empty, DependencyType.Unknown, IsUpdate: isUpdate)
215
+ : new Dependency(name, packageVersion, DependencyType.Unknown, IsUpdate: isUpdate);
200
216
  }
201
217
  }
202
218
 
@@ -284,7 +300,8 @@ internal static partial class MSBuildHelper
284
300
  Environment.NewLine,
285
301
  packages
286
302
  .Where(p => !string.IsNullOrWhiteSpace(p.Version)) // empty `Version` attributes will cause the temporary project to not build
287
- .Select(static p => $"<PackageReference Include=\"{p.Name}\" Version=\"[{p.Version}]\" />"));
303
+ // If all PackageReferences for a package are update-only mark it as such, otherwise it can cause package incoherence errors which do not exist in the repo.
304
+ .Select(static p => $"<PackageReference {(p.IsUpdate ? "Update" : "Include")}=\"{p.Name}\" Version=\"[{p.Version}]\" />"));
288
305
 
289
306
  var projectContents = $"""
290
307
  <Project Sdk="Microsoft.NET.Sdk">
@@ -1,6 +1,7 @@
1
1
  using System;
2
2
  using System.Diagnostics;
3
3
  using System.Text;
4
+ using System.Threading;
4
5
  using System.Threading.Tasks;
5
6
 
6
7
  namespace NuGetUpdater.Core;
@@ -11,6 +12,7 @@ public static class ProcessEx
11
12
  {
12
13
  var tcs = new TaskCompletionSource<(int, string, string)>();
13
14
 
15
+ var redirectInitiated = new ManualResetEventSlim();
14
16
  var process = new Process
15
17
  {
16
18
  StartInfo =
@@ -37,8 +39,21 @@ public static class ProcessEx
37
39
 
38
40
  process.Exited += (sender, args) =>
39
41
  {
40
- tcs.TrySetResult((process.ExitCode, stdout.ToString(), stderr.ToString()));
41
- process.Dispose();
42
+ // It is necessary to wait until we have invoked 'BeginXReadLine' for our redirected IO. Then,
43
+ // we must call WaitForExit to make sure we've received all OutputDataReceived/ErrorDataReceived calls
44
+ // or else we'll be returning a list we're still modifying. For paranoia, we'll start a task here rather
45
+ // than enter right back into the Process type and start a wait which isn't guaranteed to be safe.
46
+ Task.Run(() =>
47
+ {
48
+ redirectInitiated.Wait();
49
+ redirectInitiated.Dispose();
50
+ redirectInitiated = null;
51
+
52
+ process.WaitForExit();
53
+
54
+ tcs.TrySetResult((process.ExitCode, stdout.ToString(), stderr.ToString()));
55
+ process.Dispose();
56
+ });
42
57
  };
43
58
 
44
59
  #if DEBUG
@@ -61,6 +76,8 @@ public static class ProcessEx
61
76
  process.BeginOutputReadLine();
62
77
  process.BeginErrorReadLine();
63
78
 
79
+ redirectInitiated.Set();
80
+
64
81
  return tcs.Task;
65
82
  }
66
83
  }
@@ -32,7 +32,8 @@ public class DotnetToolsJsonBuildFileTests
32
32
  private static DotNetToolsJsonBuildFile GetBuildFile() => new(
33
33
  repoRootPath: "/",
34
34
  path: "/.config/dotnet-tools.json",
35
- contents: DotnetToolsJson);
35
+ contents: DotnetToolsJson,
36
+ logger: new Logger(verbose: true));
36
37
 
37
38
  [Fact]
38
39
  public void GetDependencies_ReturnsDependencies()
@@ -31,7 +31,24 @@ public class GlobalJsonBuildFileTests
31
31
  private static GlobalJsonBuildFile GetBuildFile(string contents) => new(
32
32
  repoRootPath: "/",
33
33
  path: "/global.json",
34
- contents: contents);
34
+ contents: contents,
35
+ logger: new Logger(verbose: true));
36
+
37
+ [Fact]
38
+ public void GlobalJson_Malformed_DoesNotThrow()
39
+ {
40
+ var buildFile = GetBuildFile("""[{ "Random": "stuff"}]""");
41
+
42
+ Assert.Null(buildFile.MSBuildSdks);
43
+ }
44
+
45
+ [Fact]
46
+ public void GlobalJson_NotJson_DoesNotThrow()
47
+ {
48
+ var buildFile = GetBuildFile("not json");
49
+
50
+ Assert.Null(buildFile.MSBuildSdks);
51
+ }
35
52
 
36
53
  [Fact]
37
54
  public void GlobalJson_GetDependencies_ReturnsDependencies()
@@ -171,6 +171,144 @@ public class MSBuildHelperTests
171
171
  Assert.Equal(expectedDependencies, actualDependencies);
172
172
  }
173
173
 
174
+ [Fact]
175
+ public async Task AllPackageDependencies_DoNotTruncateLongDependencyLists()
176
+ {
177
+ using var temp = new TemporaryDirectory();
178
+ var expectedDependencies = new Dependency[]
179
+ {
180
+ new("Castle.Core", "4.4.1", DependencyType.Unknown),
181
+ new("Microsoft.ApplicationInsights", "2.10.0", DependencyType.Unknown),
182
+ new("Microsoft.ApplicationInsights.Agent.Intercept", "2.4.0", DependencyType.Unknown),
183
+ new("Microsoft.ApplicationInsights.DependencyCollector", "2.10.0", DependencyType.Unknown),
184
+ new("Microsoft.ApplicationInsights.PerfCounterCollector", "2.10.0", DependencyType.Unknown),
185
+ new("Microsoft.ApplicationInsights.WindowsServer", "2.10.0", DependencyType.Unknown),
186
+ new("Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel", "2.10.0", DependencyType.Unknown),
187
+ new("Microsoft.AspNet.TelemetryCorrelation", "1.0.5", DependencyType.Unknown),
188
+ new("Microsoft.Bcl.AsyncInterfaces", "7.0.0", DependencyType.Unknown),
189
+ new("Microsoft.Extensions.Caching.Abstractions", "1.0.0", DependencyType.Unknown),
190
+ new("Microsoft.Extensions.Caching.Memory", "1.0.0", DependencyType.Unknown),
191
+ new("Microsoft.Extensions.DependencyInjection", "7.0.0", DependencyType.Unknown),
192
+ new("Microsoft.Extensions.DependencyInjection.Abstractions", "7.0.0", DependencyType.Unknown),
193
+ new("Microsoft.Extensions.DiagnosticAdapter", "1.1.0", DependencyType.Unknown),
194
+ new("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown),
195
+ new("Microsoft.Extensions.Logging", "7.0.0", DependencyType.Unknown),
196
+ new("Microsoft.Extensions.Logging.Abstractions", "7.0.0", DependencyType.Unknown),
197
+ new("Microsoft.Extensions.Options", "7.0.0", DependencyType.Unknown),
198
+ new("Microsoft.Extensions.PlatformAbstractions", "1.1.0", DependencyType.Unknown),
199
+ new("Microsoft.Extensions.Primitives", "7.0.0", DependencyType.Unknown),
200
+ new("Moq", "4.16.1", DependencyType.Unknown),
201
+ new("MSTest.TestFramework", "2.1.0", DependencyType.Unknown),
202
+ new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown),
203
+ new("System", "4.1.311.2", DependencyType.Unknown),
204
+ new("System.Buffers", "4.5.1", DependencyType.Unknown),
205
+ new("System.Collections.Concurrent", "4.3.0", DependencyType.Unknown),
206
+ new("System.Collections.Immutable", "1.3.0", DependencyType.Unknown),
207
+ new("System.Collections.NonGeneric", "4.3.0", DependencyType.Unknown),
208
+ new("System.Collections.Specialized", "4.3.0", DependencyType.Unknown),
209
+ new("System.ComponentModel", "4.3.0", DependencyType.Unknown),
210
+ new("System.ComponentModel.Annotations", "5.0.0", DependencyType.Unknown),
211
+ new("System.ComponentModel.Primitives", "4.3.0", DependencyType.Unknown),
212
+ new("System.ComponentModel.TypeConverter", "4.3.0", DependencyType.Unknown),
213
+ new("System.Core", "3.5.21022.801", DependencyType.Unknown),
214
+ new("System.Data.Common", "4.3.0", DependencyType.Unknown),
215
+ new("System.Diagnostics.DiagnosticSource", "7.0.0", DependencyType.Unknown),
216
+ new("System.Diagnostics.PerformanceCounter", "4.5.0", DependencyType.Unknown),
217
+ new("System.Diagnostics.StackTrace", "4.3.0", DependencyType.Unknown),
218
+ new("System.Dynamic.Runtime", "4.3.0", DependencyType.Unknown),
219
+ new("System.IO.FileSystem.Primitives", "4.3.0", DependencyType.Unknown),
220
+ new("System.Linq", "4.3.0", DependencyType.Unknown),
221
+ new("System.Linq.Expressions", "4.3.0", DependencyType.Unknown),
222
+ new("System.Memory", "4.5.5", DependencyType.Unknown),
223
+ new("System.Net.WebHeaderCollection", "4.3.0", DependencyType.Unknown),
224
+ new("System.Numerics.Vectors", "4.4.0", DependencyType.Unknown),
225
+ new("System.ObjectModel", "4.3.0", DependencyType.Unknown),
226
+ new("System.Private.DataContractSerialization", "4.3.0", DependencyType.Unknown),
227
+ new("System.Reflection.Emit", "4.3.0", DependencyType.Unknown),
228
+ new("System.Reflection.Emit.ILGeneration", "4.3.0", DependencyType.Unknown),
229
+ new("System.Reflection.Emit.Lightweight", "4.3.0", DependencyType.Unknown),
230
+ new("System.Reflection.Metadata", "1.4.1", DependencyType.Unknown),
231
+ new("System.Reflection.TypeExtensions", "4.3.0", DependencyType.Unknown),
232
+ new("System.Runtime.CompilerServices.Unsafe", "6.0.0", DependencyType.Unknown),
233
+ new("System.Runtime.InteropServices.RuntimeInformation", "4.3.0", DependencyType.Unknown),
234
+ new("System.Runtime.Numerics", "4.3.0", DependencyType.Unknown),
235
+ new("System.Runtime.Serialization.Json", "4.3.0", DependencyType.Unknown),
236
+ new("System.Runtime.Serialization.Primitives", "4.3.0", DependencyType.Unknown),
237
+ new("System.Security.Claims", "4.3.0", DependencyType.Unknown),
238
+ new("System.Security.Cryptography.OpenSsl", "4.3.0", DependencyType.Unknown),
239
+ new("System.Security.Cryptography.Primitives", "4.3.0", DependencyType.Unknown),
240
+ new("System.Security.Principal", "4.3.0", DependencyType.Unknown),
241
+ new("System.Text.RegularExpressions", "4.3.0", DependencyType.Unknown),
242
+ new("System.Threading", "4.3.0", DependencyType.Unknown),
243
+ new("System.Threading.Tasks.Extensions", "4.5.4", DependencyType.Unknown),
244
+ new("System.Threading.Thread", "4.3.0", DependencyType.Unknown),
245
+ new("System.Threading.ThreadPool", "4.3.0", DependencyType.Unknown),
246
+ new("System.Xml.ReaderWriter", "4.3.0", DependencyType.Unknown),
247
+ new("System.Xml.XDocument", "4.3.0", DependencyType.Unknown),
248
+ new("System.Xml.XmlDocument", "4.3.0", DependencyType.Unknown),
249
+ new("System.Xml.XmlSerializer", "4.3.0", DependencyType.Unknown),
250
+ new("Microsoft.ApplicationInsights.Web", "2.10.0", DependencyType.Unknown),
251
+ new("MSTest.TestAdapter", "2.1.0", DependencyType.Unknown),
252
+ new("NETStandard.Library", "2.0.3", DependencyType.Unknown),
253
+ };
254
+ var packages = new[] {
255
+ new Dependency("System", "4.1.311.2", DependencyType.Unknown),
256
+ new Dependency("System.Core", "3.5.21022.801", DependencyType.Unknown),
257
+ new Dependency("Moq", "4.16.1", DependencyType.Unknown),
258
+ new Dependency("Castle.Core", "4.4.1", DependencyType.Unknown),
259
+ new Dependency("MSTest.TestAdapter", "2.1.0", DependencyType.Unknown),
260
+ new Dependency("MSTest.TestFramework", "2.1.0", DependencyType.Unknown),
261
+ new Dependency("Microsoft.ApplicationInsights", "2.10.0", DependencyType.Unknown),
262
+ new Dependency("Microsoft.ApplicationInsights.Agent.Intercept", "2.4.0", DependencyType.Unknown),
263
+ new Dependency("Microsoft.ApplicationInsights.DependencyCollector", "2.10.0", DependencyType.Unknown),
264
+ new Dependency("Microsoft.ApplicationInsights.PerfCounterCollector", "2.10.0", DependencyType.Unknown),
265
+ new Dependency("Microsoft.ApplicationInsights.Web", "2.10.0", DependencyType.Unknown),
266
+ new Dependency("Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel", "2.10.0", DependencyType.Unknown),
267
+ new Dependency("Microsoft.ApplicationInsights.WindowsServer", "2.10.0", DependencyType.Unknown),
268
+ new Dependency("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown),
269
+ new Dependency("Newtonsoft.Json", "12.0.1", DependencyType.Unknown)
270
+ };
271
+ var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", packages);
272
+ for(int i = 0; i < actualDependencies.Length; i++)
273
+ {
274
+ var ad = actualDependencies[i];
275
+ var ed = expectedDependencies[i];
276
+ Assert.Equal(ed, ad);
277
+ }
278
+ Assert.Equal(expectedDependencies, actualDependencies);
279
+ }
280
+
281
+ [Fact]
282
+ public async Task AllPackageDependencies_DoNotIncludeUpdateOnlyPackages()
283
+ {
284
+ using var temp = new TemporaryDirectory();
285
+ var expectedDependencies = new Dependency[]
286
+ {
287
+ new("Microsoft.Bcl.AsyncInterfaces", "7.0.0", DependencyType.Unknown),
288
+ new("Microsoft.Extensions.DependencyInjection", "7.0.0", DependencyType.Unknown),
289
+ new("Microsoft.Extensions.DependencyInjection.Abstractions", "7.0.0", DependencyType.Unknown),
290
+ new("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown),
291
+ new("Microsoft.Extensions.Logging", "7.0.0", DependencyType.Unknown),
292
+ new("Microsoft.Extensions.Logging.Abstractions", "7.0.0", DependencyType.Unknown),
293
+ new("Microsoft.Extensions.Options", "7.0.0", DependencyType.Unknown),
294
+ new("Microsoft.Extensions.Primitives", "7.0.0", DependencyType.Unknown),
295
+ new("System.Buffers", "4.5.1", DependencyType.Unknown),
296
+ new("System.ComponentModel.Annotations", "5.0.0", DependencyType.Unknown),
297
+ new("System.Diagnostics.DiagnosticSource", "7.0.0", DependencyType.Unknown),
298
+ new("System.Memory", "4.5.5", DependencyType.Unknown),
299
+ new("System.Numerics.Vectors", "4.4.0", DependencyType.Unknown),
300
+ new("System.Runtime.CompilerServices.Unsafe", "6.0.0", DependencyType.Unknown),
301
+ new("System.Threading.Tasks.Extensions", "4.5.4", DependencyType.Unknown),
302
+ new("NETStandard.Library", "2.0.3", DependencyType.Unknown),
303
+ };
304
+ var packages = new[] {
305
+ new Dependency("Microsoft.Extensions.Http", "7.0.0", DependencyType.Unknown),
306
+ new Dependency("Newtonsoft.Json", "12.0.1", DependencyType.Unknown, IsUpdate: true)
307
+ };
308
+ var actualDependencies = await MSBuildHelper.GetAllPackageDependenciesAsync(temp.DirectoryPath, temp.DirectoryPath, "netstandard2.0", packages);
309
+ Assert.Equal(expectedDependencies, actualDependencies);
310
+ }
311
+
174
312
  [Fact]
175
313
  public async Task AllPackageDependenciesCanBeFoundWithNuGetConfig()
176
314
  {
@@ -349,6 +487,72 @@ public class MSBuildHelperTests
349
487
  new("Newtonsoft.Json", "12.0.1", DependencyType.Unknown)
350
488
  }
351
489
  };
490
+
491
+ // version is set in one file, used in another
492
+ yield return new object[]
493
+ {
494
+ // build file contents
495
+ new[]
496
+ {
497
+ ("Packages.props", """
498
+ <Project>
499
+ <ItemGroup>
500
+ <PackageReference Update="Azure.Identity" Version="1.6.0" />
501
+ <PackageReference Update="Microsoft.Data.SqlClient" Version="5.1.4" />
502
+ </ItemGroup>
503
+ </Project>
504
+ """),
505
+ ("project.csproj", """
506
+ <Project Sdk="Microsoft.NET.Sdk">
507
+ <PropertyGroup>
508
+ <TargetFramework>netstandard2.0</TargetFramework>
509
+ </PropertyGroup>
510
+ <ItemGroup>
511
+ <PackageReference Include="Azure.Identity" Version="1.6.1" />
512
+ </ItemGroup>
513
+ </Project>
514
+ """)
515
+ },
516
+ // expected dependencies
517
+ new Dependency[]
518
+ {
519
+ new("Azure.Identity", "1.6.0", DependencyType.Unknown),
520
+ new("Microsoft.Data.SqlClient", "5.1.4", DependencyType.Unknown, IsUpdate: true)
521
+ }
522
+ };
523
+
524
+ // version is set in one file, used in another
525
+ yield return new object[]
526
+ {
527
+ // build file contents
528
+ new[]
529
+ {
530
+ ("project.csproj", """
531
+ <Project Sdk="Microsoft.NET.Sdk">
532
+ <PropertyGroup>
533
+ <TargetFramework>netstandard2.0</TargetFramework>
534
+ </PropertyGroup>
535
+ <ItemGroup>
536
+ <PackageReference Include="Azure.Identity" />
537
+ </ItemGroup>
538
+ </Project>
539
+ """),
540
+ ("Packages.props", """
541
+ <Project>
542
+ <ItemGroup>
543
+ <PackageReference Update="Azure.Identity" Version="1.6.0" />
544
+ <PackageReference Update="Microsoft.Data.SqlClient" Version="5.1.4" />
545
+ </ItemGroup>
546
+ </Project>
547
+ """)
548
+ },
549
+ // expected dependencies
550
+ new Dependency[]
551
+ {
552
+ new("Azure.Identity", "1.6.0", DependencyType.Unknown),
553
+ new("Microsoft.Data.SqlClient", "5.1.4", DependencyType.Unknown, IsUpdate: true)
554
+ }
555
+ };
352
556
  }
353
557
 
354
558
  public static IEnumerable<object[]> SolutionProjectPathTestData()
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-nuget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.241.0
4
+ version: 0.242.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-18 00:00:00.000000000 Z
11
+ date: 2024-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.241.0
19
+ version: 0.242.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.241.0
26
+ version: 0.242.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubyzip
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -369,7 +369,7 @@ licenses:
369
369
  - Nonstandard
370
370
  metadata:
371
371
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
372
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.241.0
372
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.242.0
373
373
  post_install_message:
374
374
  rdoc_options: []
375
375
  require_paths: