dependabot-nuget 0.251.0 → 0.253.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/Directory.Common.props +1 -0
- data/helpers/lib/NuGetUpdater/Directory.Packages.props +26 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +35 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/NuGetUpdater.Cli.csproj +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +4 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +251 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +27 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/NuGetUpdater.Cli.Test.csproj +3 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Dependency.cs +56 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyType.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscovery.cs +69 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscoveryResult.cs +11 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +217 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +30 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscoveryResult.cs +10 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +30 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscoveryResult.cs +10 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/IDiscoveryResult.cs +14 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +29 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs +10 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +13 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +128 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +13 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/EvaluationResult.cs +8 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/EvaluationResultType.cs +9 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/BuildFile.cs +6 -8
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/DotNetToolsJsonBuildFile.cs +4 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/GlobalJsonBuildFile.cs +24 -17
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/PackagesConfigBuildFile.cs +8 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/ProjectBuildFile.cs +100 -19
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/XmlBuildFile.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/NuGetUpdater.Core.csproj +6 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Property.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +23 -36
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +5 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs +59 -26
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +5 -20
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/HashSetExtensions.cs +14 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ImmutableArrayExtensions.cs +18 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +281 -140
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +27 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +18 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +135 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.DotNetToolsJson.cs +91 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +71 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +67 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +405 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +306 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +36 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/DotNetToolsJsonBuildFileTests.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs +2 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/PackagesConfigBuildFileTests.cs +4 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/ProjectBuildFileTests.cs +6 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/NuGetUpdater.Core.Test.csproj +4 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs +38 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestBase.cs +10 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackagesConfigUpdaterTests.cs +1 -8
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +13 -41
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DirsProj.cs +0 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +0 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +0 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +0 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +0 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +30 -23
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/AssertEx.cs +272 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/DiffUtil.cs +266 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +239 -161
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterHelperTests.cs +7 -11
- data/lib/dependabot/nuget/discovery/dependency_details.rb +95 -0
- data/lib/dependabot/nuget/discovery/dependency_file_discovery.rb +126 -0
- data/lib/dependabot/nuget/discovery/directory_packages_props_discovery.rb +43 -0
- data/lib/dependabot/nuget/discovery/discovery_json_reader.rb +83 -0
- data/lib/dependabot/nuget/discovery/evaluation_details.rb +63 -0
- data/lib/dependabot/nuget/discovery/project_discovery.rb +71 -0
- data/lib/dependabot/nuget/discovery/property_details.rb +43 -0
- data/lib/dependabot/nuget/discovery/workspace_discovery.rb +66 -0
- data/lib/dependabot/nuget/file_parser.rb +19 -128
- data/lib/dependabot/nuget/file_updater.rb +28 -60
- data/lib/dependabot/nuget/native_helpers.rb +55 -0
- data/lib/dependabot/nuget/update_checker/compatibility_checker.rb +3 -8
- data/lib/dependabot/nuget/update_checker/dependency_finder.rb +1 -0
- data/lib/dependabot/nuget/update_checker/property_updater.rb +1 -0
- data/lib/dependabot/nuget/update_checker/tfm_finder.rb +17 -152
- data/lib/dependabot/nuget/update_checker/version_finder.rb +1 -6
- data/lib/dependabot/nuget/update_checker.rb +4 -1
- metadata +44 -25
- data/lib/dependabot/nuget/file_parser/dotnet_tools_json_parser.rb +0 -71
- data/lib/dependabot/nuget/file_parser/global_json_parser.rb +0 -68
- data/lib/dependabot/nuget/file_parser/packages_config_parser.rb +0 -92
- data/lib/dependabot/nuget/file_parser/project_file_parser.rb +0 -620
- data/lib/dependabot/nuget/file_parser/property_value_finder.rb +0 -225
- data/lib/dependabot/nuget/file_updater/property_value_updater.rb +0 -81
@@ -0,0 +1,405 @@
|
|
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
|
+
[Fact]
|
381
|
+
|
382
|
+
public async Task NoDependenciesReturnedIfNoTargetFrameworkCanBeResolved()
|
383
|
+
{
|
384
|
+
await TestDiscoveryAsync(
|
385
|
+
workspacePath: "",
|
386
|
+
files: [
|
387
|
+
("myproj.csproj", """
|
388
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
389
|
+
<PropertyGroup>
|
390
|
+
<TargetFramework>$(SomeCommonTfmThatCannotBeResolved)</TargetFramework>
|
391
|
+
</PropertyGroup>
|
392
|
+
<ItemGroup>
|
393
|
+
<PackageReference Include="Some.Package" Version="1.2.3" />
|
394
|
+
</ItemGroup>
|
395
|
+
</Project>
|
396
|
+
""")
|
397
|
+
],
|
398
|
+
expectedResult: new()
|
399
|
+
{
|
400
|
+
FilePath = "",
|
401
|
+
Projects = []
|
402
|
+
});
|
403
|
+
}
|
404
|
+
}
|
405
|
+
}
|