dependabot-nuget 0.257.0 → 0.259.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/Directory.Packages.props +2 -0
  3. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +2 -2
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +255 -191
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +63 -35
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +107 -14
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +9 -5
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +18 -0
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +6 -1
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.DotNetToolsJson.cs +6 -2
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +6 -2
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +11 -21
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Proj.cs +95 -0
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +204 -62
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +64 -45
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/MockNuGetPackage.cs +419 -0
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/NuGetUpdater.Core.Test.csproj +1 -0
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs +7 -2
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +77 -19
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DirsProj.cs +120 -91
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.DotNetTools.cs +132 -97
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.GlobalJson.cs +93 -75
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs +45 -42
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +1089 -956
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +1624 -1291
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +296 -293
  27. data/helpers/lib/NuGetUpdater/global.json +6 -0
  28. data/lib/dependabot/nuget/file_parser.rb +4 -5
  29. data/lib/dependabot/nuget/file_updater.rb +1 -1
  30. data/lib/dependabot/nuget/update_checker/dependency_finder.rb +7 -2
  31. data/lib/dependabot/nuget/update_checker/property_updater.rb +1 -0
  32. data/lib/dependabot/nuget/update_checker/version_finder.rb +2 -3
  33. data/lib/dependabot/nuget/update_checker.rb +1 -0
  34. metadata +8 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49b70e0b9626d157c462ca23016ba1895c80f33cdf8fc16d831b041b9681eba0
4
- data.tar.gz: b7c36d26347029a8095d71b75f7038982c39e2c2e0fe0a4c883e2fbb6dce481a
3
+ metadata.gz: 5b3b54bc45745a03ccfa6e3395c81c858989d7145fec5dec34233a2b0fda8176
4
+ data.tar.gz: 1704e36a55f4a57ad15717966fd32c032a2bd8eec6f6f9b1c496729def011f86
5
5
  SHA512:
6
- metadata.gz: e2a68947d4fa90c7f3864997e23d4019d9360e4448655d3ec91749df124a302a949b7ebd010b3faaff930f93b00d6722193fda25a9dd8a3feefc56506fac7d0b
7
- data.tar.gz: 64b02f3fd2412e3aff8c1e8d2b9c3bfdcfd01a43e5eb755fc760ff9ff1a98267a466e3657ce4dfd36a32dd25791316cedaa6a465735965a0f200529dabfc41c7
6
+ metadata.gz: aa0dfe7a2c18cc9eecb2865ffc05d7f316d231a20473d86504f8619af86944235f02ed114138b492ed7142bbfc298879cbaec49f0dfdd42c5f633ccc4af78fff
7
+ data.tar.gz: 85fc42bf59334c705b5482267d49b9a3755367f118bd6f9601049b1493ce6eb5b7bb37058d7fcae6308632f1f4ad9f364e2e1c355aaea046b4bca18d5ab6e085
@@ -13,6 +13,8 @@
13
13
  <PackageVersion Include="Microsoft.Build" Version="17.5.0" ExcludeAssets="Runtime" PrivateAssets="All" />
14
14
  <PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.5.0" ExcludeAssets="Runtime" PrivateAssets="All" />
15
15
 
16
+ <PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
17
+
16
18
  <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
17
19
 
18
20
  <PackageVersion Include="NuGet.Core" Version="2.14.0-rtm-832" Aliases="CoreV2" />
@@ -8,7 +8,7 @@ namespace NuGetUpdater.Cli.Commands;
8
8
  internal static class DiscoverCommand
9
9
  {
10
10
  internal static readonly Option<DirectoryInfo> RepoRootOption = new("--repo-root", () => new DirectoryInfo(Environment.CurrentDirectory)) { IsRequired = false };
11
- internal static readonly Option<FileSystemInfo> WorkspaceOption = new("--workspace") { IsRequired = true };
11
+ internal static readonly Option<string> WorkspaceOption = new("--workspace") { IsRequired = true };
12
12
  internal static readonly Option<string> OutputOption = new("--output", () => DiscoveryWorker.DiscoveryResultFileName) { IsRequired = false };
13
13
  internal static readonly Option<bool> VerboseOption = new("--verbose", getDefaultValue: () => false);
14
14
 
@@ -27,7 +27,7 @@ internal static class DiscoverCommand
27
27
  command.SetHandler(async (repoRoot, workspace, outputPath, verbose) =>
28
28
  {
29
29
  var worker = new DiscoveryWorker(new Logger(verbose));
30
- await worker.RunAsync(repoRoot.FullName, workspace.FullName, outputPath);
30
+ await worker.RunAsync(repoRoot.FullName, workspace, outputPath);
31
31
  }, RepoRootOption, WorkspaceOption, OutputOption, VerboseOption);
32
32
 
33
33
  return command;
@@ -1,8 +1,9 @@
1
- using System.Collections.Immutable;
2
1
  using System.Text;
3
2
 
4
3
  using NuGetUpdater.Core;
4
+ using NuGetUpdater.Core.Test;
5
5
  using NuGetUpdater.Core.Test.Discover;
6
+ using NuGetUpdater.Core.Test.Update;
6
7
 
7
8
  using Xunit;
8
9
 
@@ -14,145 +15,202 @@ public partial class EntryPointTests
14
15
  {
15
16
  public class Discover : DiscoveryWorkerTestBase
16
17
  {
18
+ [Fact]
19
+ public async Task PathWithSpaces()
20
+ {
21
+ await RunAsync(path =>
22
+ [
23
+ "discover",
24
+ "--repo-root",
25
+ path,
26
+ "--workspace",
27
+ "path/to/some directory with spaces",
28
+ ],
29
+ packages: [],
30
+ initialFiles:
31
+ [
32
+ ("path/to/some directory with spaces/project.csproj", """
33
+ <Project Sdk="Microsoft.NETSdk">
34
+ <PropertyGroup>
35
+ <TargetFramework>net8.0</TargetFramework>
36
+ </PropertyGroup>
37
+ <ItemGroup>
38
+ <PackageReference Include="Some.Package" Version="1.2.3" />
39
+ </ItemGroup>
40
+ </Project>
41
+ """)
42
+ ],
43
+ expectedResult: new()
44
+ {
45
+ FilePath = "path/to/some directory with spaces",
46
+ Projects = [
47
+ new()
48
+ {
49
+ FilePath = "project.csproj",
50
+ TargetFrameworks = ["net8.0"],
51
+ ReferencedProjectPaths = [],
52
+ ExpectedDependencyCount = 2,
53
+ Dependencies = [
54
+ new("Some.Package", "1.2.3", DependencyType.PackageReference, TargetFrameworks: ["net8.0"], IsDirect: true),
55
+ ],
56
+ Properties = [
57
+ new("TargetFramework", "net8.0", "path/to/some directory with spaces/project.csproj"),
58
+ ],
59
+ }
60
+ ]
61
+ }
62
+ );
63
+ }
64
+
17
65
  [Fact]
18
66
  public async Task WithSolution()
19
67
  {
20
- string solutionPath = "path/to/solution.sln";
21
68
  await RunAsync(path =>
22
- [
23
- "discover",
24
- "--repo-root",
25
- path,
26
- "--workspace",
27
- path,
28
- ],
29
- new[]
30
- {
31
- (solutionPath, """
32
- Microsoft Visual Studio Solution File, Format Version 12.00
33
- # Visual Studio 14
34
- VisualStudioVersion = 14.0.22705.0
35
- MinimumVisualStudioVersion = 10.0.40219.1
36
- Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "my", "my.csproj", "{782E0C0A-10D3-444D-9640-263D03D2B20C}"
37
- EndProject
38
- Global
39
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
40
- Debug|Any CPU = Debug|Any CPU
41
- Release|Any CPU = Release|Any CPU
42
- EndGlobalSection
43
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
44
- {782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45
- {782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.Build.0 = Debug|Any CPU
46
- {782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.ActiveCfg = Release|Any CPU
47
- {782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.Build.0 = Release|Any CPU
48
- EndGlobalSection
49
- GlobalSection(SolutionProperties) = preSolution
50
- HideSolutionNode = FALSE
51
- EndGlobalSection
52
- EndGlobal
53
- """),
54
- ("path/to/my.csproj", """
55
- <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
56
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
57
- <PropertyGroup>
58
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
59
- </PropertyGroup>
60
- <ItemGroup>
61
- <None Include="packages.config" />
62
- </ItemGroup>
63
- <ItemGroup>
64
- <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
65
- <HintPath>packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
66
- <Private>True</Private>
67
- </Reference>
68
- </ItemGroup>
69
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
70
- </Project>
71
- """),
72
- ("path/to/packages.config", """
73
- <packages>
74
- <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
75
- </packages>
76
- """)
77
- },
78
- expectedResult: new()
79
- {
80
- FilePath = "",
81
- Projects = [
82
- new()
83
- {
84
- FilePath = "path/to/my.csproj",
85
- TargetFrameworks = ["net45"],
86
- ReferencedProjectPaths = [],
87
- ExpectedDependencyCount = 2, // Should we ignore Microsoft.NET.ReferenceAssemblies?
88
- Dependencies = [
89
- new("Newtonsoft.Json", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"]),
90
- ],
91
- Properties = [
92
- new("TargetFrameworkVersion", "v4.5", "path/to/my.csproj"),
93
- ],
94
- }
95
- ]
96
- });
69
+ [
70
+ "discover",
71
+ "--repo-root",
72
+ path,
73
+ "--workspace",
74
+ "/",
75
+ ],
76
+ packages:
77
+ [
78
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net45"),
79
+ ],
80
+ initialFiles:
81
+ new[]
82
+ {
83
+ ("solution.sln", """
84
+ Microsoft Visual Studio Solution File, Format Version 12.00
85
+ # Visual Studio 14
86
+ VisualStudioVersion = 14.0.22705.0
87
+ MinimumVisualStudioVersion = 10.0.40219.1
88
+ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "my", "path/to/my.csproj", "{782E0C0A-10D3-444D-9640-263D03D2B20C}"
89
+ EndProject
90
+ Global
91
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
92
+ Debug|Any CPU = Debug|Any CPU
93
+ Release|Any CPU = Release|Any CPU
94
+ EndGlobalSection
95
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
96
+ {782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
97
+ {782E0C0A-10D3-444D-9640-263D03D2B20C}.Debug|Any CPU.Build.0 = Debug|Any CPU
98
+ {782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.ActiveCfg = Release|Any CPU
99
+ {782E0C0A-10D3-444D-9640-263D03D2B20C}.Release|Any CPU.Build.0 = Release|Any CPU
100
+ EndGlobalSection
101
+ GlobalSection(SolutionProperties) = preSolution
102
+ HideSolutionNode = FALSE
103
+ EndGlobalSection
104
+ EndGlobal
105
+ """),
106
+ ("path/to/my.csproj", """
107
+ <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
108
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
109
+ <PropertyGroup>
110
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
111
+ </PropertyGroup>
112
+ <ItemGroup>
113
+ <None Include="packages.config" />
114
+ </ItemGroup>
115
+ <ItemGroup>
116
+ <Reference Include="Some.Package">
117
+ <HintPath>packages\Some.Package.7.0.1\lib\net45\Some.Package.dll</HintPath>
118
+ <Private>True</Private>
119
+ </Reference>
120
+ </ItemGroup>
121
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
122
+ </Project>
123
+ """),
124
+ ("path/to/packages.config", """
125
+ <packages>
126
+ <package id="Some.Package" version="7.0.1" targetFramework="net45" />
127
+ </packages>
128
+ """)
129
+ },
130
+ expectedResult: new()
131
+ {
132
+ FilePath = "",
133
+ Projects = [
134
+ new()
135
+ {
136
+ FilePath = "path/to/my.csproj",
137
+ TargetFrameworks = ["net45"],
138
+ ReferencedProjectPaths = [],
139
+ ExpectedDependencyCount = 2,
140
+ Dependencies = [
141
+ new("Some.Package", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"]),
142
+ ],
143
+ Properties = [
144
+ new("TargetFrameworkVersion", "v4.5", "path/to/my.csproj"),
145
+ ],
146
+ }
147
+ ]
148
+ }
149
+ );
97
150
  }
98
151
 
99
152
  [Fact]
100
153
  public async Task WithProject()
101
154
  {
102
- var projectPath = "path/to/my.csproj";
103
155
  await RunAsync(path =>
104
- [
105
- "discover",
106
- "--repo-root",
107
- path,
108
- "--workspace",
109
- path,
110
- ],
111
- new[]
112
- {
113
- (projectPath, """
114
- <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
115
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
116
- <PropertyGroup>
117
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
118
- </PropertyGroup>
119
- <ItemGroup>
120
- <None Include="packages.config" />
121
- </ItemGroup>
122
- <ItemGroup>
123
- <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
124
- <HintPath>packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
125
- <Private>True</Private>
126
- </Reference>
127
- </ItemGroup>
128
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
129
- </Project>
130
- """),
131
- ("path/to/packages.config", """
132
- <packages>
133
- <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
134
- </packages>
135
- """)
136
- },
137
- expectedResult: new()
138
- {
139
- FilePath = "",
140
- Projects = [
141
- new()
142
- {
143
- FilePath = projectPath,
144
- TargetFrameworks = ["net45"],
145
- ReferencedProjectPaths = [],
146
- ExpectedDependencyCount = 2, // Should we ignore Microsoft.NET.ReferenceAssemblies?
147
- Dependencies = [
148
- new("Newtonsoft.Json", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"])
149
- ],
150
- Properties = [
151
- new("TargetFrameworkVersion", "v4.5", "path/to/my.csproj"),
152
- ],
153
- }
154
- ]
155
- });
156
+ [
157
+ "discover",
158
+ "--repo-root",
159
+ path,
160
+ "--workspace",
161
+ "path/to",
162
+ ],
163
+ packages:
164
+ [
165
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net45"),
166
+ ],
167
+ initialFiles:
168
+ new[]
169
+ {
170
+ ("path/to/my.csproj", """
171
+ <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
172
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
173
+ <PropertyGroup>
174
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
175
+ </PropertyGroup>
176
+ <ItemGroup>
177
+ <None Include="packages.config" />
178
+ </ItemGroup>
179
+ <ItemGroup>
180
+ <Reference Include="Some.Package">
181
+ <HintPath>packages\Some.Package.7.0.1\lib\net45\Some.Package.dll</HintPath>
182
+ <Private>True</Private>
183
+ </Reference>
184
+ </ItemGroup>
185
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
186
+ </Project>
187
+ """),
188
+ ("path/to/packages.config", """
189
+ <packages>
190
+ <package id="Some.Package" version="7.0.1" targetFramework="net45" />
191
+ </packages>
192
+ """)
193
+ },
194
+ expectedResult: new()
195
+ {
196
+ FilePath = "path/to",
197
+ Projects = [
198
+ new()
199
+ {
200
+ FilePath = "my.csproj",
201
+ TargetFrameworks = ["net45"],
202
+ ReferencedProjectPaths = [],
203
+ ExpectedDependencyCount = 2,
204
+ Dependencies = [
205
+ new("Some.Package", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"])
206
+ ],
207
+ Properties = [
208
+ new("TargetFrameworkVersion", "v4.5", "path/to/my.csproj"),
209
+ ],
210
+ }
211
+ ]
212
+ }
213
+ );
156
214
  }
157
215
 
158
216
  [Fact]
@@ -160,76 +218,80 @@ public partial class EntryPointTests
160
218
  {
161
219
  var workspacePath = "path/to/";
162
220
  await RunAsync(path =>
163
- [
164
- "discover",
165
- "--repo-root",
166
- path,
167
- "--workspace",
168
- Path.Combine(path, workspacePath),
169
- ],
170
- new[]
171
- {
172
- ("path/to/my.csproj", """
173
- <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
174
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
175
- <PropertyGroup>
176
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
177
- </PropertyGroup>
178
- <ItemGroup>
179
- <None Include="packages.config" />
180
- </ItemGroup>
181
- <ItemGroup>
182
- <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
183
- <HintPath>packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
184
- <Private>True</Private>
185
- </Reference>
186
- </ItemGroup>
187
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
188
- </Project>
189
- """),
190
- ("path/to/packages.config", """
191
- <packages>
192
- <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
193
- </packages>
194
- """)
195
- },
196
- expectedResult: new()
197
- {
198
- FilePath = workspacePath,
199
- Projects = [
200
- new()
201
- {
202
- FilePath = "my.csproj",
203
- TargetFrameworks = ["net45"],
204
- ReferencedProjectPaths = [],
205
- ExpectedDependencyCount = 2, // Should we ignore Microsoft.NET.ReferenceAssemblies?
206
- Dependencies = [
207
- new("Newtonsoft.Json", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"])
208
- ],
209
- Properties = [
210
- new("TargetFrameworkVersion", "v4.5", "path/to/my.csproj"),
211
- ],
212
- }
213
- ]
214
- });
221
+ [
222
+ "discover",
223
+ "--repo-root",
224
+ path,
225
+ "--workspace",
226
+ workspacePath,
227
+ ],
228
+ packages:
229
+ [
230
+ MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net45"),
231
+ ],
232
+ initialFiles:
233
+ new[]
234
+ {
235
+ ("path/to/my.csproj", """
236
+ <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
237
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
238
+ <PropertyGroup>
239
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
240
+ </PropertyGroup>
241
+ <ItemGroup>
242
+ <None Include="packages.config" />
243
+ </ItemGroup>
244
+ <ItemGroup>
245
+ <Reference Include="Some.Package">
246
+ <HintPath>packages\Some.Package.7.0.1\lib\net45\Some.Package.dll</HintPath>
247
+ <Private>True</Private>
248
+ </Reference>
249
+ </ItemGroup>
250
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
251
+ </Project>
252
+ """),
253
+ ("path/to/packages.config", """
254
+ <packages>
255
+ <package id="Some.Package" version="7.0.1" targetFramework="net45" />
256
+ </packages>
257
+ """)
258
+ },
259
+ expectedResult: new()
260
+ {
261
+ FilePath = workspacePath,
262
+ Projects = [
263
+ new()
264
+ {
265
+ FilePath = "my.csproj",
266
+ TargetFrameworks = ["net45"],
267
+ ReferencedProjectPaths = [],
268
+ ExpectedDependencyCount = 2,
269
+ Dependencies = [
270
+ new("Some.Package", "7.0.1", DependencyType.PackagesConfig, TargetFrameworks: ["net45"])
271
+ ],
272
+ Properties = [
273
+ new("TargetFrameworkVersion", "v4.5", "path/to/my.csproj"),
274
+ ],
275
+ }
276
+ ]
277
+ }
278
+ );
215
279
  }
216
280
 
217
281
  [Fact]
218
282
  public async Task WithDuplicateDependenciesOfDifferentTypes()
219
283
  {
220
- var projectPath = "path/to/my.csproj";
221
- var directoryBuildPropsPath = "path/Directory.Build.props";
222
284
  await RunAsync(path =>
223
285
  [
224
286
  "discover",
225
287
  "--repo-root",
226
288
  path,
227
289
  "--workspace",
228
- path,
290
+ "path/to",
229
291
  ],
230
292
  new[]
231
293
  {
232
- (projectPath, """
294
+ ("path/to/my.csproj", """
233
295
  <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
234
296
  <PropertyGroup>
235
297
  <TargetFramework>net8.0</TargetFramework>
@@ -240,7 +302,7 @@ public partial class EntryPointTests
240
302
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
241
303
  </Project>
242
304
  """),
243
- (directoryBuildPropsPath, """
305
+ ("path/Directory.Build.props", """
244
306
  <Project>
245
307
  <ItemGroup Condition="'$(ManagePackageVersionsCentrally)' == 'true'">
246
308
  <GlobalPackageReference Include="System.Text.Json" Version="8.0.3" />
@@ -253,11 +315,11 @@ public partial class EntryPointTests
253
315
  },
254
316
  expectedResult: new()
255
317
  {
256
- FilePath = "",
318
+ FilePath = "path/to",
257
319
  Projects = [
258
320
  new()
259
321
  {
260
- FilePath = projectPath,
322
+ FilePath = "my.csproj",
261
323
  TargetFrameworks = ["net8.0"],
262
324
  ReferencedProjectPaths = [],
263
325
  ExpectedDependencyCount = 2,
@@ -272,7 +334,7 @@ public partial class EntryPointTests
272
334
  },
273
335
  new()
274
336
  {
275
- FilePath = directoryBuildPropsPath,
337
+ FilePath = "../Directory.Build.props",
276
338
  ReferencedProjectPaths = [],
277
339
  ExpectedDependencyCount = 2,
278
340
  Dependencies = [
@@ -288,7 +350,8 @@ public partial class EntryPointTests
288
350
  private static async Task RunAsync(
289
351
  Func<string, string[]> getArgs,
290
352
  TestFile[] initialFiles,
291
- ExpectedWorkspaceDiscoveryResult expectedResult)
353
+ ExpectedWorkspaceDiscoveryResult expectedResult,
354
+ MockNuGetPackage[]? packages = null)
292
355
  {
293
356
  var actualResult = await RunDiscoveryAsync(initialFiles, async path =>
294
357
  {
@@ -302,6 +365,7 @@ public partial class EntryPointTests
302
365
 
303
366
  try
304
367
  {
368
+ await UpdateWorkerTestBase.MockNuGetPackagesInDirectory(packages, path);
305
369
  var args = getArgs(path);
306
370
  var result = await Program.Main(args);
307
371
  if (result != 0)