dependabot-nuget 0.250.0 → 0.252.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/Directory.Common.props +1 -0
  3. data/helpers/lib/NuGetUpdater/Directory.Packages.props +26 -0
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +35 -0
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/NuGetUpdater.Cli.csproj +1 -1
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +4 -7
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +251 -0
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/NuGetUpdater.Cli.Test.csproj +3 -3
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Dependency.cs +56 -1
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyType.cs +1 -1
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscovery.cs +69 -0
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscoveryResult.cs +11 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +217 -0
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +30 -0
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscoveryResult.cs +10 -0
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +30 -0
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscoveryResult.cs +10 -0
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/IDiscoveryResult.cs +14 -0
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +29 -0
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs +10 -0
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +13 -0
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +127 -0
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +13 -0
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/EvaluationResult.cs +8 -0
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/EvaluationResultType.cs +9 -0
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/BuildFile.cs +6 -8
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/DotNetToolsJsonBuildFile.cs +4 -7
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/GlobalJsonBuildFile.cs +24 -17
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +2 -2
  30. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/PackagesConfigBuildFile.cs +8 -13
  31. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/ProjectBuildFile.cs +100 -19
  32. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/XmlBuildFile.cs +2 -2
  33. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/NuGetUpdater.Core.csproj +6 -6
  34. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Property.cs +6 -0
  35. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +23 -36
  36. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +5 -10
  37. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs +16 -21
  38. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +4 -19
  39. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/HashSetExtensions.cs +14 -0
  40. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ImmutableArrayExtensions.cs +18 -0
  41. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs +0 -1
  42. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +121 -67
  43. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +27 -4
  44. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +117 -0
  45. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.DotNetToolsJson.cs +91 -0
  46. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +71 -0
  47. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +59 -0
  48. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +380 -0
  49. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +306 -0
  50. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +36 -0
  51. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/DotNetToolsJsonBuildFileTests.cs +1 -2
  52. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs +2 -3
  53. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/PackagesConfigBuildFileTests.cs +4 -6
  54. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/ProjectBuildFileTests.cs +6 -5
  55. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/NuGetUpdater.Core.Test.csproj +4 -3
  56. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs +38 -6
  57. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +12 -40
  58. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +30 -0
  59. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/AssertEx.cs +272 -0
  60. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/DiffUtil.cs +266 -0
  61. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +195 -152
  62. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterHelperTests.cs +7 -11
  63. data/lib/dependabot/nuget/discovery/dependency_details.rb +95 -0
  64. data/lib/dependabot/nuget/discovery/dependency_file_discovery.rb +126 -0
  65. data/lib/dependabot/nuget/discovery/directory_packages_props_discovery.rb +43 -0
  66. data/lib/dependabot/nuget/discovery/discovery_json_reader.rb +83 -0
  67. data/lib/dependabot/nuget/discovery/evaluation_details.rb +63 -0
  68. data/lib/dependabot/nuget/discovery/project_discovery.rb +71 -0
  69. data/lib/dependabot/nuget/discovery/property_details.rb +43 -0
  70. data/lib/dependabot/nuget/discovery/workspace_discovery.rb +66 -0
  71. data/lib/dependabot/nuget/file_parser.rb +19 -128
  72. data/lib/dependabot/nuget/file_updater.rb +28 -60
  73. data/lib/dependabot/nuget/native_helpers.rb +55 -0
  74. data/lib/dependabot/nuget/update_checker/compatibility_checker.rb +3 -8
  75. data/lib/dependabot/nuget/update_checker/dependency_finder.rb +1 -0
  76. data/lib/dependabot/nuget/update_checker/property_updater.rb +1 -0
  77. data/lib/dependabot/nuget/update_checker/tfm_finder.rb +17 -152
  78. data/lib/dependabot/nuget/update_checker/version_finder.rb +1 -6
  79. data/lib/dependabot/nuget/update_checker.rb +4 -1
  80. metadata +43 -11
  81. data/lib/dependabot/nuget/file_parser/dotnet_tools_json_parser.rb +0 -71
  82. data/lib/dependabot/nuget/file_parser/global_json_parser.rb +0 -68
  83. data/lib/dependabot/nuget/file_parser/packages_config_parser.rb +0 -92
  84. data/lib/dependabot/nuget/file_parser/project_file_parser.rb +0 -620
  85. data/lib/dependabot/nuget/file_parser/property_value_finder.rb +0 -225
  86. data/lib/dependabot/nuget/file_updater/property_value_updater.rb +0 -81
@@ -0,0 +1,71 @@
1
+ using Xunit;
2
+
3
+ namespace NuGetUpdater.Core.Test.Discover;
4
+
5
+ public partial class DiscoveryWorkerTests
6
+ {
7
+ public class GlobalJson : DiscoveryWorkerTestBase
8
+ {
9
+ [Fact]
10
+ public async Task DiscoversDependencies()
11
+ {
12
+ await TestDiscoveryAsync(
13
+ workspacePath: "",
14
+ files: [
15
+ ("global.json", """
16
+ {
17
+ "sdk": {
18
+ "version": "2.2.104"
19
+ },
20
+ "msbuild-sdks": {
21
+ "Microsoft.Build.Traversal": "1.0.45"
22
+ }
23
+ }
24
+ """),
25
+ ],
26
+ expectedResult: new()
27
+ {
28
+ FilePath = "",
29
+ GlobalJson = new()
30
+ {
31
+ FilePath = "global.json",
32
+ Dependencies = [
33
+ new("Microsoft.NET.Sdk", "2.2.104", DependencyType.MSBuildSdk),
34
+ new("Microsoft.Build.Traversal", "1.0.45", DependencyType.MSBuildSdk),
35
+ ]
36
+ },
37
+ ExpectedProjectCount = 0,
38
+ });
39
+ }
40
+
41
+ [Fact]
42
+ public async Task ReportsFailure()
43
+ {
44
+ await TestDiscoveryAsync(
45
+ workspacePath: "",
46
+ files: [
47
+ ("global.json", """
48
+ {
49
+ "sdk": {
50
+ "version": "2.2.104",
51
+ },
52
+ "msbuild-sdks": {
53
+ "Microsoft.Build.Traversal": "1.0.45"
54
+ }
55
+ }
56
+ """),
57
+ ],
58
+ expectedResult: new()
59
+ {
60
+ FilePath = "",
61
+ GlobalJson = new()
62
+ {
63
+ FilePath = "global.json",
64
+ IsSuccess = false,
65
+ ExpectedDependencyCount = 0,
66
+ },
67
+ ExpectedProjectCount = 0,
68
+ });
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,59 @@
1
+ using System.Collections.Immutable;
2
+
3
+ using Xunit;
4
+
5
+ namespace NuGetUpdater.Core.Test.Discover;
6
+
7
+ public partial class DiscoveryWorkerTests
8
+ {
9
+ public class PackagesConfig : DiscoveryWorkerTestBase
10
+ {
11
+ [Fact]
12
+ public async Task DiscoversDependencies()
13
+ {
14
+ await TestDiscoveryAsync(
15
+ workspacePath: "",
16
+ files: [
17
+ ("packages.config", """
18
+ <?xml version="1.0" encoding="utf-8"?>
19
+ <packages>
20
+ <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net46" />
21
+ <package id="Microsoft.Net.Compilers" version="1.0.1" targetFramework="net46" developmentDependency="true" />
22
+ <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net46" />
23
+ <package id="Microsoft.Web.Xdt" version="2.1.1" targetFramework="net46" />
24
+ <package id="Newtonsoft.Json" version="8.0.3" allowedVersions="[8,10)" targetFramework="net46" />
25
+ <package id="NuGet.Core" version="2.11.1" targetFramework="net46" />
26
+ <package id="NuGet.Server" version="2.11.2" targetFramework="net46" />
27
+ <package id="RouteMagic" version="1.3" targetFramework="net46" />
28
+ <package id="WebActivatorEx" version="2.1.0" targetFramework="net46"></package>
29
+ </packages>
30
+ """),
31
+ ("myproj.csproj", """
32
+ <Project>
33
+ </Project>
34
+ """)
35
+ ],
36
+ expectedResult: new()
37
+ {
38
+ FilePath = "",
39
+ Projects = [
40
+ new()
41
+ {
42
+ FilePath = "myproj.csproj",
43
+ Dependencies = [
44
+ new("Microsoft.CodeDom.Providers.DotNetCompilerPlatform", "1.0.0", DependencyType.PackagesConfig, TargetFrameworks: []),
45
+ new("Microsoft.Net.Compilers", "1.0.1", DependencyType.PackagesConfig, TargetFrameworks: []),
46
+ new("Microsoft.Web.Infrastructure", "1.0.0.0", DependencyType.PackagesConfig, TargetFrameworks: []),
47
+ new("Microsoft.Web.Xdt", "2.1.1", DependencyType.PackagesConfig, TargetFrameworks: []),
48
+ new("Newtonsoft.Json", "8.0.3", DependencyType.PackagesConfig, TargetFrameworks: []),
49
+ new("NuGet.Core", "2.11.1", DependencyType.PackagesConfig, TargetFrameworks: []),
50
+ new("NuGet.Server", "2.11.2", DependencyType.PackagesConfig, TargetFrameworks: []),
51
+ new("RouteMagic", "1.3", DependencyType.PackagesConfig, TargetFrameworks: []),
52
+ new("WebActivatorEx", "2.1.0", DependencyType.PackagesConfig, TargetFrameworks: []),
53
+ ],
54
+ }
55
+ ],
56
+ });
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,380 @@
1
+ using Xunit;
2
+
3
+ namespace NuGetUpdater.Core.Test.Discover;
4
+
5
+ public partial class DiscoveryWorkerTests
6
+ {
7
+ public class Projects : DiscoveryWorkerTestBase
8
+ {
9
+ [Fact]
10
+ public async Task ReturnsPackageReferencesMissingVersions()
11
+ {
12
+ await TestDiscoveryAsync(
13
+ workspacePath: "",
14
+ files: [
15
+ ("myproj.csproj", """
16
+ <Project Sdk="Microsoft.NET.Sdk">
17
+ <PropertyGroup>
18
+ <Description>Nancy is a lightweight web framework for the .Net platform, inspired by Sinatra. Nancy aim at delivering a low ceremony approach to building light, fast web applications.</Description>
19
+ <TargetFrameworks>netstandard1.6;net462</TargetFrameworks>
20
+ </PropertyGroup>
21
+
22
+ <ItemGroup>
23
+ <EmbeddedResource Include="ErrorHandling\Resources\**\*.*;Diagnostics\Resources\**\*.*;Diagnostics\Views\**\*.*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
24
+ </ItemGroup>
25
+
26
+ <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
27
+ <PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.1.1" />
28
+ <PackageReference Include="Microsoft.AspNetCore.App" />
29
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="" />
30
+ <PackageReference Include="Microsoft.Extensions.PlatformAbstractions" version="1.1.0"></PackageReference>
31
+ <PackageReference Include="System.Collections.Specialized"><Version>4.3.0</Version></PackageReference>
32
+ </ItemGroup>
33
+
34
+ <ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
35
+ <Reference Include="System.Xml" />
36
+ </ItemGroup>
37
+ </Project>
38
+ """)
39
+ ],
40
+ expectedResult: new()
41
+ {
42
+ FilePath = "",
43
+ Projects = [
44
+ new()
45
+ {
46
+ FilePath = "myproj.csproj",
47
+ ExpectedDependencyCount = 52,
48
+ Dependencies = [
49
+ new("Microsoft.Extensions.DependencyModel", "1.1.1", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
50
+ new("Microsoft.AspNetCore.App", "", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
51
+ new("Microsoft.NET.Test.Sdk", "", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
52
+ new("Microsoft.NET.Sdk", null, DependencyType.MSBuildSdk),
53
+ new("Microsoft.Extensions.PlatformAbstractions", "1.1.0", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
54
+ new("System.Collections.Specialized", "4.3.0", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
55
+ ],
56
+ Properties = [
57
+ new("Description", "Nancy is a lightweight web framework for the .Net platform, inspired by Sinatra. Nancy aim at delivering a low ceremony approach to building light, fast web applications.", "myproj.csproj"),
58
+ new("TargetFrameworks", "netstandard1.6;net462", "myproj.csproj"),
59
+ ],
60
+ TargetFrameworks = ["net462", "netstandard1.6"],
61
+ ReferencedProjectPaths = [],
62
+ }
63
+ ],
64
+ });
65
+ }
66
+
67
+ [Fact]
68
+ public async Task WithDirectoryPackagesProps()
69
+ {
70
+ await TestDiscoveryAsync(
71
+ workspacePath: "",
72
+ files: [
73
+ ("myproj.csproj", """
74
+ <Project Sdk="Microsoft.NET.Sdk">
75
+ <PropertyGroup>
76
+ <Description>Nancy is a lightweight web framework for the .Net platform, inspired by Sinatra. Nancy aim at delivering a low ceremony approach to building light, fast web applications.</Description>
77
+ <TargetFrameworks>netstandard1.6;net462</TargetFrameworks>
78
+ </PropertyGroup>
79
+
80
+ <ItemGroup>
81
+ <EmbeddedResource Include="ErrorHandling\Resources\**\*.*;Diagnostics\Resources\**\*.*;Diagnostics\Views\**\*.*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
82
+ </ItemGroup>
83
+
84
+ <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
85
+ <PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.1.1" />
86
+ <PackageReference Include="Microsoft.AspNetCore.App" />
87
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="" />
88
+ <PackageReference Include="Microsoft.Extensions.PlatformAbstractions" version="1.1.0"></PackageReference>
89
+ <PackageReference Include="System.Collections.Specialized"><Version>4.3.0</Version></PackageReference>
90
+ </ItemGroup>
91
+
92
+ <ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
93
+ <Reference Include="System.Xml" />
94
+ </ItemGroup>
95
+ </Project>
96
+ """),
97
+ ("Directory.Packages.props", """
98
+ <Project Sdk="Microsoft.NET.Sdk">
99
+ <PropertyGroup>
100
+ <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
101
+ </PropertyGroup>
102
+ <ItemGroup>
103
+ <PackageVersion Include="System.Lycos" Version="3.23.3" />
104
+ <PackageVersion Include="System.AskJeeves" Version="2.2.2" />
105
+ <PackageVersion Include="System.Google" Version="0.1.0-beta.3" />
106
+ <PackageVersion Include="System.WebCrawler" Version="1.1.1" />
107
+ </ItemGroup>
108
+ </Project>
109
+ """),
110
+ ],
111
+ expectedResult: new()
112
+ {
113
+ FilePath = "",
114
+ Projects = [
115
+ new()
116
+ {
117
+ FilePath = "myproj.csproj",
118
+ ExpectedDependencyCount = 52,
119
+ Dependencies = [
120
+ new("Microsoft.Extensions.DependencyModel", "1.1.1", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
121
+ new("Microsoft.AspNetCore.App", "", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
122
+ new("Microsoft.NET.Test.Sdk", "", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
123
+ new("Microsoft.NET.Sdk", null, DependencyType.MSBuildSdk),
124
+ new("Microsoft.Extensions.PlatformAbstractions", "1.1.0", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
125
+ new("System.Collections.Specialized", "4.3.0", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
126
+ ],
127
+ Properties = [
128
+ new("Description", "Nancy is a lightweight web framework for the .Net platform, inspired by Sinatra. Nancy aim at delivering a low ceremony approach to building light, fast web applications.", "myproj.csproj"),
129
+ new("ManagePackageVersionsCentrally", "true", "Directory.Packages.props"),
130
+ new("TargetFrameworks", "netstandard1.6;net462", "myproj.csproj"),
131
+ ],
132
+ TargetFrameworks = ["net462", "netstandard1.6"],
133
+ },
134
+ ],
135
+ DirectoryPackagesProps = new()
136
+ {
137
+ FilePath = "Directory.Packages.props",
138
+ Dependencies = [
139
+ new("System.Lycos", "3.23.3", DependencyType.PackageVersion, IsDirect: true),
140
+ new("System.AskJeeves", "2.2.2", DependencyType.PackageVersion, IsDirect: true),
141
+ new("System.Google", "0.1.0-beta.3", DependencyType.PackageVersion, IsDirect: true),
142
+ new("System.WebCrawler", "1.1.1", DependencyType.PackageVersion, IsDirect: true),
143
+ new("Microsoft.NET.Sdk", null, DependencyType.MSBuildSdk),
144
+ ],
145
+ },
146
+ });
147
+ }
148
+
149
+ [Fact]
150
+ public async Task WithDirectoryBuildPropsAndTargets()
151
+ {
152
+ await TestDiscoveryAsync(
153
+ workspacePath: "",
154
+ files: [
155
+ ("project.csproj", """
156
+ <Project Sdk="Microsoft.NET.Sdk">
157
+
158
+ <PropertyGroup>
159
+ <OutputType>Exe</OutputType>
160
+ <TargetFramework>net6.0</TargetFramework>
161
+ <ImplicitUsings>enable</ImplicitUsings>
162
+ <Nullable>enable</Nullable>
163
+ </PropertyGroup>
164
+
165
+ </Project>
166
+ """),
167
+ ("Directory.Build.props", """
168
+ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
169
+
170
+ <ItemGroup>
171
+ <PackageReference Include="NuGet.Versioning" Version="6.1.0" />
172
+ </ItemGroup>
173
+
174
+ </Project>
175
+ """),
176
+ ("Directory.Build.targets", """
177
+ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
178
+
179
+ <ItemGroup>
180
+ <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.0">
181
+ <PrivateAssets>all</PrivateAssets>
182
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
183
+ </PackageReference>
184
+ </ItemGroup>
185
+
186
+ </Project>
187
+ """),
188
+ ],
189
+ expectedResult: new()
190
+ {
191
+ FilePath = "",
192
+ Projects = [
193
+ new()
194
+ {
195
+ FilePath = "project.csproj",
196
+ ExpectedDependencyCount = 3,
197
+ Dependencies = [
198
+ new("NuGet.Versioning", "6.1.0", DependencyType.PackageReference, TargetFrameworks: ["net6.0"], IsDirect: false),
199
+ new("Microsoft.CodeAnalysis.Analyzers", "3.3.0", DependencyType.PackageReference, TargetFrameworks: ["net6.0"], IsDirect: false),
200
+ ],
201
+ Properties = [
202
+ new("ImplicitUsings", "enable", "project.csproj"),
203
+ new("Nullable", "enable", "project.csproj"),
204
+ new("OutputType", "Exe", "project.csproj"),
205
+ new("TargetFramework", "net6.0", "project.csproj"),
206
+ ],
207
+ TargetFrameworks = ["net6.0"],
208
+ },
209
+ new()
210
+ {
211
+ FilePath = "Directory.Build.props",
212
+ ExpectedDependencyCount = 1,
213
+ Dependencies = [
214
+ new("NuGet.Versioning", "6.1.0", DependencyType.PackageReference, IsDirect: true),
215
+ ],
216
+ Properties = [],
217
+ TargetFrameworks = [],
218
+ },
219
+ new()
220
+ {
221
+ FilePath = "Directory.Build.targets",
222
+ ExpectedDependencyCount = 1,
223
+ Dependencies = [
224
+ new("Microsoft.CodeAnalysis.Analyzers", "3.3.0", DependencyType.PackageReference, IsDirect: true),
225
+ ],
226
+ Properties = [],
227
+ TargetFrameworks = [],
228
+ },
229
+ ],
230
+ });
231
+ }
232
+
233
+ [Fact]
234
+ public async Task WithPackagesProps()
235
+ {
236
+ var nugetPackagesDirectory = Environment.GetEnvironmentVariable("NUGET_PACKAGES");
237
+ var nugetHttpCacheDirectory = Environment.GetEnvironmentVariable("NUGET_HTTP_CACHE_PATH");
238
+
239
+ try
240
+ {
241
+ using var temp = new TemporaryDirectory();
242
+
243
+ // It is important to have empty NuGet caches for this test, so override them with temp directories.
244
+ var tempNuGetPackagesDirectory = Path.Combine(temp.DirectoryPath, ".nuget", "packages");
245
+ Environment.SetEnvironmentVariable("NUGET_PACKAGES", tempNuGetPackagesDirectory);
246
+ var tempNuGetHttpCacheDirectory = Path.Combine(temp.DirectoryPath, ".nuget", "v3-cache");
247
+ Environment.SetEnvironmentVariable("NUGET_HTTP_CACHE_PATH", tempNuGetHttpCacheDirectory);
248
+
249
+ await TestDiscoveryAsync(
250
+ workspacePath: "",
251
+ files: [
252
+ ("myproj.csproj", """
253
+ <Project Sdk="Microsoft.NET.Sdk">
254
+ <PropertyGroup>
255
+ <Description>Nancy is a lightweight web framework for the .Net platform, inspired by Sinatra. Nancy aim at delivering a low ceremony approach to building light, fast web applications.</Description>
256
+ <TargetFrameworks>netstandard1.6;net462</TargetFrameworks>
257
+ </PropertyGroup>
258
+
259
+ <ItemGroup>
260
+ <EmbeddedResource Include="ErrorHandling\Resources\**\*.*;Diagnostics\Resources\**\*.*;Diagnostics\Views\**\*.*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
261
+ </ItemGroup>
262
+
263
+ <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
264
+ <PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.1.1" />
265
+ <PackageReference Include="Microsoft.AspNetCore.App" />
266
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="" />
267
+ <PackageReference Include="Microsoft.Extensions.PlatformAbstractions" version="1.1.0"></PackageReference>
268
+ <PackageReference Include="System.Collections.Specialized"><Version>4.3.0</Version></PackageReference>
269
+ </ItemGroup>
270
+
271
+ <ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
272
+ <Reference Include="System.Xml" />
273
+ </ItemGroup>
274
+ </Project>
275
+ """),
276
+ ("Packages.props", """
277
+ <Project Sdk="Microsoft.NET.Sdk">
278
+ <ItemGroup>
279
+ <GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
280
+ <PackageReference Update="@(GlobalPackageReference)" PrivateAssets="Build" />
281
+ <PackageReference Update="System.Lycos" Version="3.23.3" />
282
+ <PackageReference Update="System.AskJeeves" Version="2.2.2" />
283
+ <PackageReference Update="System.Google" Version="0.1.0-beta.3" />
284
+ <PackageReference Update="System.WebCrawler" Version="1.1.1" />
285
+ </ItemGroup>
286
+ </Project>
287
+ """),
288
+ ("Directory.Build.targets", """
289
+ <Project>
290
+ <Sdk Name="Microsoft.Build.CentralPackageVersions" Version="2.1.3" />
291
+ </Project>
292
+ """),
293
+ ],
294
+ expectedResult: new()
295
+ {
296
+ FilePath = "",
297
+ ExpectedProjectCount = 3,
298
+ Projects = [
299
+ new()
300
+ {
301
+ FilePath = "myproj.csproj",
302
+ ExpectedDependencyCount = 58,
303
+ Dependencies = [
304
+ new("Microsoft.Extensions.DependencyModel", "1.1.1", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
305
+ new("Microsoft.AspNetCore.App", "", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
306
+ new("Microsoft.NET.Test.Sdk", "", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
307
+ new("Microsoft.NET.Sdk", null, DependencyType.MSBuildSdk),
308
+ new("Microsoft.Extensions.PlatformAbstractions", "1.1.0", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
309
+ new("System.Collections.Specialized", "4.3.0", DependencyType.PackageReference, TargetFrameworks: ["net462", "netstandard1.6"], IsDirect: true),
310
+ ],
311
+ Properties = [
312
+ new("Description", "Nancy is a lightweight web framework for the .Net platform, inspired by Sinatra. Nancy aim at delivering a low ceremony approach to building light, fast web applications.", "myproj.csproj"),
313
+ new("TargetFrameworks", "netstandard1.6;net462", "myproj.csproj"),
314
+ ],
315
+ TargetFrameworks = ["net462", "netstandard1.6"],
316
+ },
317
+ new()
318
+ {
319
+ FilePath = "Packages.props",
320
+ Dependencies = [
321
+ new("Microsoft.SourceLink.GitHub", "1.0.0-beta2-19367-01", DependencyType.GlobalPackageReference, IsDirect: true),
322
+ new("System.Lycos", "3.23.3", DependencyType.PackageReference, IsDirect: true, IsUpdate: true),
323
+ new("System.AskJeeves", "2.2.2", DependencyType.PackageReference, IsDirect: true, IsUpdate: true),
324
+ new("System.Google", "0.1.0-beta.3", DependencyType.PackageReference, IsDirect: true, IsUpdate: true),
325
+ new("System.WebCrawler", "1.1.1", DependencyType.PackageReference, IsDirect: true, IsUpdate: true),
326
+ new("Microsoft.NET.Sdk", null, DependencyType.MSBuildSdk),
327
+ ],
328
+ },
329
+ ],
330
+ });
331
+ }
332
+ finally
333
+ {
334
+ // Restore the NuGet caches.
335
+ Environment.SetEnvironmentVariable("NUGET_PACKAGES", nugetPackagesDirectory);
336
+ Environment.SetEnvironmentVariable("NUGET_HTTP_CACHE_PATH", nugetHttpCacheDirectory);
337
+ }
338
+ }
339
+
340
+ [Fact]
341
+ public async Task ReturnsDependenciesThatCannotBeEvaluated()
342
+ {
343
+ await TestDiscoveryAsync(
344
+ workspacePath: "",
345
+ files: [
346
+ ("myproj.csproj", """
347
+ <Project Sdk="Microsoft.NET.Sdk">
348
+ <PropertyGroup>
349
+ <TargetFramework>net8.0</TargetFramework>
350
+ </PropertyGroup>
351
+ <ItemGroup>
352
+ <PackageReference Include="Package.A" Version="1.2.3" />
353
+ <PackageReference Include="Package.B" Version="$(ThisPropertyCannotBeResolved)" />
354
+ </ItemGroup>
355
+ </Project>
356
+ """)
357
+ ],
358
+ expectedResult: new()
359
+ {
360
+ FilePath = "",
361
+ Projects = [
362
+ new()
363
+ {
364
+ FilePath = "myproj.csproj",
365
+ Dependencies = [
366
+ new("Microsoft.NET.Sdk", null, DependencyType.MSBuildSdk),
367
+ new("Package.A", "1.2.3", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true),
368
+ new("Package.B", "$(ThisPropertyCannotBeResolved)", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true),
369
+ ],
370
+ Properties = [
371
+ new("TargetFramework", "net8.0", "myproj.csproj"),
372
+ ],
373
+ TargetFrameworks = ["net8.0"],
374
+ ReferencedProjectPaths = [],
375
+ }
376
+ ],
377
+ });
378
+ }
379
+ }
380
+ }