Skip to content

Commit

Permalink
[9.0.2xx] sln migrate, sln list, sln add (#45408)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcpopMSFT authored Dec 18, 2024
2 parents 4b465ef + 38d1af1 commit e0fb73c
Show file tree
Hide file tree
Showing 62 changed files with 1,703 additions and 815 deletions.
19 changes: 10 additions & 9 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<Import Project="$(RepositoryEngineeringDir)\dependabot\Packages.props" Condition="'$(RepositoryEngineeringDir)' != ''"/>
<Import Project="$(RepositoryEngineeringDir)\dependabot\Packages.props" Condition="'$(RepositoryEngineeringDir)' != ''" />
<PropertyGroup>
<!-- Using multiple feeds isn't supported by Maestro: https://github.com/dotnet/arcade/issues/14155. -->
<NoWarn>$(NoWarn);NU1507</NoWarn>
Expand All @@ -12,7 +12,7 @@
<PackageVersion Include="Microsoft.AspNetCore.DeveloperCertificates.XPlat" Version="$(MicrosoftAspNetCoreDeveloperCertificatesXPlatPackageVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.Tooling.Internal" Version="$(MicrosoftAspNetCoreMvcRazorExtensionsToolingInternalPackageVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="$(MicrosoftAspNetCoreTestHostPackageVersion)" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="$(MicrosoftBclAsyncInterfacesPackageVersion)"/>
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="$(MicrosoftBclAsyncInterfacesPackageVersion)" />
<PackageVersion Include="Microsoft.Build.NuGetSdkResolver" Version="$(MicrosoftBuildNuGetSdkResolverPackageVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis" Version="$(MicrosoftCodeAnalysisPackageVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzer.Testing" Version="$(MicrosoftCodeAnalysisAnalyzerTestingVersion)" />
Expand Down Expand Up @@ -42,7 +42,7 @@
<PackageVersion Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingVersion)" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="$(MicrosoftExtensionsLoggingAbstractionsVersion)" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsoleVersion)" />
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="$(MicrosoftExtensionsObjectPoolPackageVersion)"/>
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="$(MicrosoftExtensionsObjectPoolPackageVersion)" />
<PackageVersion Include="Microsoft.FSharp.Compiler" Version="$(MicrosoftFSharpCompilerPackageVersion)" />
<PackageVersion Include="Microsoft.Net.Compilers.Toolset.Framework" Version="$(MicrosoftNetCompilersToolsetFrameworkPackageVersion)" />
<PackageVersion Include="Microsoft.IO.Redist" Version="$(MicrosoftIORedistPackageVersion)" />
Expand All @@ -66,6 +66,7 @@
<PackageVersion Include="Microsoft.TestPlatform.CLI" Version="$(MicrosoftTestPlatformCLIPackageVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Composition" Version="17.4.16" />
<PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="$(MicrosoftVisualStudioSetupConfigurationInteropVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.SolutionPersistence" Version="1.0.26" />
<PackageVersion Include="Microsoft.Web.Deployment" Version="$(WebDeploymentPackageVersion)" />
<PackageVersion Include="Microsoft.Web.Xdt" Version="$(MicrosoftWebXdtPackageVersion)" />
<PackageVersion Include="Microsoft.Win32.SystemEvents" Version="$(MicrosoftWin32SystemEventsPackageVersion)" />
Expand Down Expand Up @@ -94,11 +95,11 @@
<PackageVersion Include="System.CommandLine" Version="$(SystemCommandLineVersion)" />
<PackageVersion Include="System.CommandLine.Rendering" Version="$(SystemCommandLineRenderingVersion)" />
<PackageVersion Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
<PackageVersion Include="System.Composition.AttributedModel" Version="$(SystemCompositionAttributedModelPackageVersion)"/>
<PackageVersion Include="System.Composition.Convention" Version="$(SystemCompositionConventionPackageVersion)"/>
<PackageVersion Include="System.Composition.Hosting" Version="$(SystemCompositionHostingPackageVersion)"/>
<PackageVersion Include="System.Composition.Runtime" Version="$(SystemCompositionRuntimePackageVersion)"/>
<PackageVersion Include="System.Composition.TypedParts" Version="$(SystemCompositionTypedPartsPackageVersion)"/>
<PackageVersion Include="System.Composition.AttributedModel" Version="$(SystemCompositionAttributedModelPackageVersion)" />
<PackageVersion Include="System.Composition.Convention" Version="$(SystemCompositionConventionPackageVersion)" />
<PackageVersion Include="System.Composition.Hosting" Version="$(SystemCompositionHostingPackageVersion)" />
<PackageVersion Include="System.Composition.Runtime" Version="$(SystemCompositionRuntimePackageVersion)" />
<PackageVersion Include="System.Composition.TypedParts" Version="$(SystemCompositionTypedPartsPackageVersion)" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="$(SystemConfigurationConfigurationManagerPackageVersion)" />
<PackageVersion Include="System.Formats.Asn1" Version="$(SystemFormatsAsn1Version)" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
Expand All @@ -118,7 +119,7 @@
<PackageVersion Include="Valleysoft.DockerCredsProvider" Version="2.2.1" />
<PackageVersion Include="xunit" Version="$(XUnitVersion)" />
<PackageVersion Include="Xunit.Combinatorial" Version="$(XunitCombinatorialVersion)" />
<PackageVersion Include="xunit.console" Version="$(XUnitVersion)"/>
<PackageVersion Include="xunit.console" Version="$(XUnitVersion)" />
</ItemGroup>

<!-- Use different versions of Microsoft.Build.* depending on whether the output will be used in
Expand Down
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,9 @@
<SourceBuild RepoName="command-line-api" ManagedOnly="true" />
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="9.0.0-alpha.1.24510.1">
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="9.0.0-alpha.1.24611.1">
<Uri>https://github.com/dotnet/source-build-externals</Uri>
<Sha>b11ed370b79aa475535a5803856b7c7d0977235e</Sha>
<Sha>1ffe36b3379a0b7ced63d134e5daf30948c03306</Sha>
<SourceBuild RepoName="source-build-externals" ManagedOnly="true" />
</Dependency>
<!-- Intermediate is necessary for source build. -->
Expand Down
14 changes: 13 additions & 1 deletion src/Cli/dotnet/commands/dotnet-sln/LocalizableStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,16 @@
<data name="SolutionFolderHeader" xml:space="preserve">
<value>Solution Folder(s)</value>
</data>
</root>
<data name="MigrateAppFullName" xml:space="preserve">
<value>Generate a .slnx file from a .sln file.</value>
</data>
<data name="SlnxGenerated" xml:space="preserve">
<value>.slnx file {0} generated.</value>
</data>
<data name="CannotMigrateSlnx" xml:space="preserve">
<value>Only .sln files can be migrated to .slnx format.</value>
</data>
<data name="SerializerNotFound" xml:space="preserve">
<value>Could not read solution file {0}. Supported files are .sln and .slnx valid solutions.</value>
</data>
</root>
39 changes: 39 additions & 0 deletions src/Cli/dotnet/commands/dotnet-sln/SlnCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools;
using Microsoft.VisualStudio.SolutionPersistence;
using Microsoft.VisualStudio.SolutionPersistence.Serializer;
using NuGet.Packaging;
using LocalizableStrings = Microsoft.DotNet.Tools.Sln.LocalizableStrings;

Expand Down Expand Up @@ -37,10 +41,45 @@ private static CliCommand ConstructCommand()
command.Subcommands.Add(SlnAddParser.GetCommand());
command.Subcommands.Add(SlnListParser.GetCommand());
command.Subcommands.Add(SlnRemoveParser.GetCommand());
command.Subcommands.Add(SlnMigrateCommandParser.GetCommand());

command.SetAction((parseResult) => parseResult.HandleMissingCommand());

return command;
}

internal static string GetSlnFileFullPath(string slnFileOrDirectory)
{
if (File.Exists(slnFileOrDirectory))
{
return Path.GetFullPath(slnFileOrDirectory);
}
if (Directory.Exists(slnFileOrDirectory))
{
string[] files = [
..Directory.GetFiles(slnFileOrDirectory, "*.sln", SearchOption.TopDirectoryOnly),
..Directory.GetFiles(slnFileOrDirectory, "*.slnx", SearchOption.TopDirectoryOnly)];
if (files.Length == 0)
{
throw new GracefulException(CommonLocalizableStrings.CouldNotFindSolutionIn, slnFileOrDirectory);
}
if (files.Length > 1)
{
throw new GracefulException(CommonLocalizableStrings.MoreThanOneSolutionInDirectory, slnFileOrDirectory);
}
return Path.GetFullPath(files.Single());
}
throw new GracefulException(CommonLocalizableStrings.CouldNotFindSolutionOrDirectory, slnFileOrDirectory);
}

internal static ISolutionSerializer GetSolutionSerializer(string solutionFilePath)
{
ISolutionSerializer? serializer = SolutionSerializers.GetSerializerByMoniker(solutionFilePath);
if (serializer is null)
{
throw new GracefulException(LocalizableStrings.SerializerNotFound, solutionFilePath);
}
return serializer;
}
}
}
Loading

0 comments on commit e0fb73c

Please sign in to comment.