Skip to content

Commit 98e896a

Browse files
Merging main into darc-main-35a9926e-3131-4186-9d83-b8301da616ae
2 parents 7abc5a3 + e928797 commit 98e896a

27 files changed

+225
-51
lines changed

eng/Version.Details.xml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -133,74 +133,74 @@
133133
<Uri>https://github.com/dotnet/dotnet</Uri>
134134
<Sha>954d6157c9c22c8d8b4faddef70b2b703c65e77e</Sha>
135135
</Dependency>
136-
<Dependency Name="Microsoft.Build.NuGetSdkResolver" Version="6.15.0-preview.1.45">
136+
<Dependency Name="Microsoft.Build.NuGetSdkResolver" Version="6.15.0-preview.1.47">
137137
<Uri>https://github.com/nuget/nuget.client</Uri>
138-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
138+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
139139
</Dependency>
140-
<Dependency Name="NuGet.Build.Tasks" Version="6.15.0-preview.1.45">
140+
<Dependency Name="NuGet.Build.Tasks" Version="6.15.0-preview.1.47">
141141
<Uri>https://github.com/nuget/nuget.client</Uri>
142-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
142+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
143143
<SourceBuildTarball RepoName="nuget-client" ManagedOnly="true" />
144144
</Dependency>
145-
<Dependency Name="NuGet.Build.Tasks.Console" Version="6.15.0-preview.1.45">
145+
<Dependency Name="NuGet.Build.Tasks.Console" Version="6.15.0-preview.1.47">
146146
<Uri>https://github.com/nuget/nuget.client</Uri>
147-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
147+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
148148
</Dependency>
149-
<Dependency Name="NuGet.Build.Tasks.Pack" Version="6.15.0-preview.1.45">
149+
<Dependency Name="NuGet.Build.Tasks.Pack" Version="6.15.0-preview.1.47">
150150
<Uri>https://github.com/nuget/nuget.client</Uri>
151-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
151+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
152152
</Dependency>
153-
<Dependency Name="NuGet.Commands" Version="6.15.0-preview.1.45">
153+
<Dependency Name="NuGet.Commands" Version="6.15.0-preview.1.47">
154154
<Uri>https://github.com/nuget/nuget.client</Uri>
155-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
155+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
156156
</Dependency>
157-
<Dependency Name="NuGet.CommandLine.XPlat" Version="6.15.0-preview.1.45">
157+
<Dependency Name="NuGet.CommandLine.XPlat" Version="6.15.0-preview.1.47">
158158
<Uri>https://github.com/nuget/nuget.client</Uri>
159-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
159+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
160160
</Dependency>
161-
<Dependency Name="NuGet.Common" Version="6.15.0-preview.1.45">
161+
<Dependency Name="NuGet.Common" Version="6.15.0-preview.1.47">
162162
<Uri>https://github.com/nuget/nuget.client</Uri>
163-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
163+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
164164
</Dependency>
165-
<Dependency Name="NuGet.Configuration" Version="6.15.0-preview.1.45">
165+
<Dependency Name="NuGet.Configuration" Version="6.15.0-preview.1.47">
166166
<Uri>https://github.com/nuget/nuget.client</Uri>
167-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
167+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
168168
</Dependency>
169-
<Dependency Name="NuGet.Credentials" Version="6.15.0-preview.1.45">
169+
<Dependency Name="NuGet.Credentials" Version="6.15.0-preview.1.47">
170170
<Uri>https://github.com/nuget/nuget.client</Uri>
171-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
171+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
172172
</Dependency>
173-
<Dependency Name="NuGet.DependencyResolver.Core" Version="6.15.0-preview.1.45">
173+
<Dependency Name="NuGet.DependencyResolver.Core" Version="6.15.0-preview.1.47">
174174
<Uri>https://github.com/nuget/nuget.client</Uri>
175-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
175+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
176176
</Dependency>
177-
<Dependency Name="NuGet.Frameworks" Version="6.15.0-preview.1.45">
177+
<Dependency Name="NuGet.Frameworks" Version="6.15.0-preview.1.47">
178178
<Uri>https://github.com/nuget/nuget.client</Uri>
179-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
179+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
180180
</Dependency>
181-
<Dependency Name="NuGet.LibraryModel" Version="6.15.0-preview.1.45">
181+
<Dependency Name="NuGet.LibraryModel" Version="6.15.0-preview.1.47">
182182
<Uri>https://github.com/nuget/nuget.client</Uri>
183-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
183+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
184184
</Dependency>
185-
<Dependency Name="NuGet.ProjectModel" Version="6.15.0-preview.1.45">
185+
<Dependency Name="NuGet.ProjectModel" Version="6.15.0-preview.1.47">
186186
<Uri>https://github.com/nuget/nuget.client</Uri>
187-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
187+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
188188
</Dependency>
189-
<Dependency Name="NuGet.Protocol" Version="6.15.0-preview.1.45">
189+
<Dependency Name="NuGet.Protocol" Version="6.15.0-preview.1.47">
190190
<Uri>https://github.com/nuget/nuget.client</Uri>
191-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
191+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
192192
</Dependency>
193-
<Dependency Name="NuGet.Packaging" Version="6.15.0-preview.1.45">
193+
<Dependency Name="NuGet.Packaging" Version="6.15.0-preview.1.47">
194194
<Uri>https://github.com/nuget/nuget.client</Uri>
195-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
195+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
196196
</Dependency>
197-
<Dependency Name="NuGet.Versioning" Version="6.15.0-preview.1.45">
197+
<Dependency Name="NuGet.Versioning" Version="6.15.0-preview.1.47">
198198
<Uri>https://github.com/nuget/nuget.client</Uri>
199-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
199+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
200200
</Dependency>
201-
<Dependency Name="NuGet.Localization" Version="6.15.0-preview.1.45">
201+
<Dependency Name="NuGet.Localization" Version="6.15.0-preview.1.47">
202202
<Uri>https://github.com/nuget/nuget.client</Uri>
203-
<Sha>ebbb676221eaa2a8aed9cf89e8719b7139251e10</Sha>
203+
<Sha>02b1c82c1e1855042556fdf5d205de501fd81590</Sha>
204204
</Dependency>
205205
<Dependency Name="Microsoft.NET.Test.Sdk" Version="17.15.0-preview-25257-112">
206206
<Uri>https://github.com/dotnet/dotnet</Uri>

eng/Versions.props

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,18 @@
161161
</PropertyGroup>
162162
<PropertyGroup>
163163
<!-- Dependencies from https://github.com/nuget/nuget.client -->
164-
<NuGetBuildTasksPackageVersion>6.15.0-preview.1.45</NuGetBuildTasksPackageVersion>
165-
<NuGetBuildTasksConsolePackageVersion>6.15.0-preview.1.45</NuGetBuildTasksConsolePackageVersion>
166-
<NuGetLocalizationPackageVersion>6.15.0-preview.1.45</NuGetLocalizationPackageVersion>
167-
<NuGetBuildTasksPackPackageVersion>6.15.0-preview.1.45</NuGetBuildTasksPackPackageVersion>
168-
<NuGetCommandLineXPlatPackageVersion>6.15.0-preview.1.45</NuGetCommandLineXPlatPackageVersion>
169-
<NuGetProjectModelPackageVersion>6.15.0-preview.1.45</NuGetProjectModelPackageVersion>
170-
<MicrosoftBuildNuGetSdkResolverPackageVersion>6.15.0-preview.1.45</MicrosoftBuildNuGetSdkResolverPackageVersion>
171-
<NuGetCommonPackageVersion>6.15.0-preview.1.45</NuGetCommonPackageVersion>
172-
<NuGetConfigurationPackageVersion>6.15.0-preview.1.45</NuGetConfigurationPackageVersion>
173-
<NuGetFrameworksPackageVersion>6.15.0-preview.1.45</NuGetFrameworksPackageVersion>
174-
<NuGetPackagingPackageVersion>6.15.0-preview.1.45</NuGetPackagingPackageVersion>
175-
<NuGetVersioningPackageVersion>6.15.0-preview.1.45</NuGetVersioningPackageVersion>
164+
<NuGetBuildTasksPackageVersion>6.15.0-preview.1.47</NuGetBuildTasksPackageVersion>
165+
<NuGetBuildTasksConsolePackageVersion>6.15.0-preview.1.47</NuGetBuildTasksConsolePackageVersion>
166+
<NuGetLocalizationPackageVersion>6.15.0-preview.1.47</NuGetLocalizationPackageVersion>
167+
<NuGetBuildTasksPackPackageVersion>6.15.0-preview.1.47</NuGetBuildTasksPackPackageVersion>
168+
<NuGetCommandLineXPlatPackageVersion>6.15.0-preview.1.47</NuGetCommandLineXPlatPackageVersion>
169+
<NuGetProjectModelPackageVersion>6.15.0-preview.1.47</NuGetProjectModelPackageVersion>
170+
<MicrosoftBuildNuGetSdkResolverPackageVersion>6.15.0-preview.1.47</MicrosoftBuildNuGetSdkResolverPackageVersion>
171+
<NuGetCommonPackageVersion>6.15.0-preview.1.47</NuGetCommonPackageVersion>
172+
<NuGetConfigurationPackageVersion>6.15.0-preview.1.47</NuGetConfigurationPackageVersion>
173+
<NuGetFrameworksPackageVersion>6.15.0-preview.1.47</NuGetFrameworksPackageVersion>
174+
<NuGetPackagingPackageVersion>6.15.0-preview.1.47</NuGetPackagingPackageVersion>
175+
<NuGetVersioningPackageVersion>6.15.0-preview.1.47</NuGetVersioningPackageVersion>
176176
</PropertyGroup>
177177
<PropertyGroup>
178178
<!-- Dependencies from https://github.com/Microsoft/vstest -->

src/Cli/dotnet/Commands/CliCommandStrings.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2483,4 +2483,7 @@ To display a value, specify the corresponding command-line option without provid
24832483
<data name="ZeroTestsRan" xml:space="preserve">
24842484
<value>Zero tests ran</value>
24852485
</data>
2486-
</root>
2486+
<data name="SolutionAddReferencedProjectsOptionDescription" xml:space="preserve">
2487+
<value>Recursively add projects' ReferencedProjects to solution</value>
2488+
</data>
2489+
</root>

src/Cli/dotnet/Commands/Solution/Add/SolutionAddCommand.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ internal class SolutionAddCommand : CommandBase
2222
private readonly IReadOnlyCollection<string> _projects;
2323
private readonly string? _solutionFolderPath;
2424
private string _solutionFileFullPath = string.Empty;
25+
private bool _includeReferences;
2526

2627
private static string GetSolutionFolderPathWithForwardSlashes(string path)
2728
{
@@ -43,6 +44,7 @@ public SolutionAddCommand(ParseResult parseResult) : base(parseResult)
4344
_projects = (IReadOnlyCollection<string>)(parseResult.GetValue(SolutionAddCommandParser.ProjectPathArgument) ?? []);
4445
_inRoot = parseResult.GetValue(SolutionAddCommandParser.InRootOption);
4546
_solutionFolderPath = parseResult.GetValue(SolutionAddCommandParser.SolutionFolderOption);
47+
_includeReferences = parseResult.GetValue(SolutionAddCommandParser.IncludeReferencesOption);
4648
SolutionArgumentValidator.ParseAndValidateArguments(_fileOrDirectory, _projects, SolutionArgumentValidator.CommandType.Add, _inRoot, _solutionFolderPath);
4749
_solutionFileFullPath = SlnFileFactory.GetSolutionFileFullPath(_fileOrDirectory);
4850
}
@@ -138,7 +140,7 @@ private async Task AddProjectsToSolutionAsync(IEnumerable<string> projectPaths,
138140
await serializer.SaveAsync(_solutionFileFullPath, solution, cancellationToken);
139141
}
140142

141-
private void AddProject(SolutionModel solution, string fullProjectPath, ISolutionSerializer serializer = null)
143+
private void AddProject(SolutionModel solution, string fullProjectPath, ISolutionSerializer serializer = null, bool showMessageOnDuplicate = true)
142144
{
143145
string solutionRelativeProjectPath = Path.GetRelativePath(Path.GetDirectoryName(_solutionFileFullPath), fullProjectPath);
144146

@@ -175,7 +177,10 @@ private void AddProject(SolutionModel solution, string fullProjectPath, ISolutio
175177
}
176178
catch (SolutionArgumentException ex) when (ex.Type == SolutionErrorType.DuplicateProjectName || solution.FindProject(solutionRelativeProjectPath) is not null)
177179
{
178-
Reporter.Output.WriteLine(CliStrings.SolutionAlreadyContainsProject, _solutionFileFullPath, solutionRelativeProjectPath);
180+
if (showMessageOnDuplicate)
181+
{
182+
Reporter.Output.WriteLine(CliStrings.SolutionAlreadyContainsProject, _solutionFileFullPath, solutionRelativeProjectPath);
183+
}
179184
return;
180185
}
181186

@@ -205,5 +210,17 @@ private void AddProject(SolutionModel solution, string fullProjectPath, ISolutio
205210
}
206211

207212
Reporter.Output.WriteLine(CliStrings.ProjectAddedToTheSolution, solutionRelativeProjectPath);
213+
214+
// Get referencedprojects from the project instance
215+
var referencedProjectsFullPaths = projectInstance.GetItems("ProjectReference")
216+
.Select(item => Path.GetFullPath(item.EvaluatedInclude, Path.GetDirectoryName(fullProjectPath)));
217+
218+
if (_includeReferences)
219+
{
220+
foreach (var referencedProjectFullPath in referencedProjectsFullPaths)
221+
{
222+
AddProject(solution, referencedProjectFullPath, serializer, showMessageOnDuplicate: false);
223+
}
224+
}
208225
}
209226
}

src/Cli/dotnet/Commands/Solution/Add/SolutionAddCommandParser.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#nullable disable
55

66
using System.CommandLine;
7+
using System.CommandLine.Parsing;
78

89
namespace Microsoft.DotNet.Cli.Commands.Solution.Add;
910

@@ -26,6 +27,12 @@ public static class SolutionAddCommandParser
2627
Description = CliCommandStrings.AddProjectSolutionFolderArgumentDescription
2728
};
2829

30+
public static readonly Option<bool> IncludeReferencesOption = new("--include-references")
31+
{
32+
Description = CliCommandStrings.SolutionAddReferencedProjectsOptionDescription,
33+
DefaultValueFactory = (_) => true,
34+
};
35+
2936
private static readonly Command Command = ConstructCommand();
3037

3138
public static Command GetCommand()
@@ -40,6 +47,7 @@ private static Command ConstructCommand()
4047
command.Arguments.Add(ProjectPathArgument);
4148
command.Options.Add(InRootOption);
4249
command.Options.Add(SolutionFolderOption);
50+
command.Options.Add(IncludeReferencesOption);
4351

4452
command.SetAction((parseResult) => new SolutionAddCommand(parseResult).Execute());
4553

src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)