more cli commands
This commit is contained in:
@@ -3,7 +3,7 @@ using Spectre.Console.Cli;
|
||||
|
||||
namespace DotNetSolutionTools.CLI.Commands;
|
||||
|
||||
public class UpdateProjectToNet80Command : Command<UpdateProjectToNet80Command.Settings>
|
||||
public class UpdateProjectToNet80Command : AsyncCommand<UpdateProjectToNet80Command.Settings>
|
||||
{
|
||||
public sealed class Settings : CommandSettings
|
||||
{
|
||||
@@ -11,16 +11,15 @@ public class UpdateProjectToNet80Command : Command<UpdateProjectToNet80Command.S
|
||||
public required string CsprojFilePath { get; set; }
|
||||
}
|
||||
|
||||
public override int Execute(CommandContext context, Settings settings)
|
||||
public override async Task<int> ExecuteAsync(CommandContext context, Settings settings)
|
||||
{
|
||||
// validate a real folder path was passed in
|
||||
if (!Directory.Exists(settings.CsprojFilePath))
|
||||
{
|
||||
Console.WriteLine("Invalid folder path");
|
||||
Console.WriteLine("Invalid file path. Please pass in a valid file path to a .csproj file.");
|
||||
return 1;
|
||||
}
|
||||
Console.WriteLine("Deleting bin, obj, and node_modules folders");
|
||||
CleanFolder.DeleteBinObjAndNodeModulesFoldersInFolder(settings.CsprojFilePath);
|
||||
Console.WriteLine("Upgrading project to .NET 8.0");
|
||||
await DotNetUpgrade.UpdateProjectAtPathToNet80(settings.CsprojFilePath);
|
||||
|
||||
Console.WriteLine("==================================================");
|
||||
Console.WriteLine("Done!");
|
||||
|
||||
28
DotNetSolutionTools.CLI/Commands/UpdateSlnToNet80Command.cs
Normal file
28
DotNetSolutionTools.CLI/Commands/UpdateSlnToNet80Command.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using DotNetSolutionTools.Core;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
namespace DotNetSolutionTools.CLI.Commands;
|
||||
|
||||
public class UpdateSlnToNet80Command : AsyncCommand<UpdateSlnToNet80Command.Settings>
|
||||
{
|
||||
public sealed class Settings : CommandSettings
|
||||
{
|
||||
[CommandArgument(1, "<SolutionFilePath>")]
|
||||
public required string SolutionFilePath { get; set; }
|
||||
}
|
||||
|
||||
public override async Task<int> ExecuteAsync(CommandContext context, Settings settings)
|
||||
{
|
||||
if (!File.Exists(settings.SolutionFilePath))
|
||||
{
|
||||
Console.WriteLine("Invalid file path. Please pass in a valid file path to a .csproj file.");
|
||||
return 1;
|
||||
}
|
||||
Console.WriteLine("Upgrading project to .NET 8.0");
|
||||
await DotNetUpgrade.UpdateProjectsInSolutionToNet80(settings.SolutionFilePath);
|
||||
|
||||
Console.WriteLine("==================================================");
|
||||
Console.WriteLine("Done!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ app.Configure(config =>
|
||||
config.AddCommand<FormatCsprojCommand>("format-csproj");
|
||||
config.AddCommand<TreatWarningsAsErrorsCommand>("warnings-as-errors");
|
||||
config.AddCommand<ClearBinObjCommand>("clear-bin-obj");
|
||||
config.AddCommand<UpdateProjectToNet80Command>("update-csproj-net80");
|
||||
config.AddCommand<UpdateSlnToNet80Command>("update-sln-net80");
|
||||
});
|
||||
|
||||
var instance = MSBuildLocator.QueryVisualStudioInstances().OrderByDescending(instance => instance.Version).First();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Various tools to manage a C# solution.
|
||||
|
||||
✨ Update a solution to .NET 8 - updates csproj target versions and all Microsoft Nuget Packages
|
||||
✨ Update a solution to .NET 8 - updates csproj target versions and all Microsoft Nuget Packages. Ensure you update the global.json to use the latest SDK version, as this is not done for you.
|
||||
|
||||
## App
|
||||
The app feels quite self explanatory :)
|
||||
@@ -31,6 +31,6 @@ _options_
|
||||
|
||||
**clear-bin-obj** `<SolutionFolderPath>` Deletes all bin and obj folders, and node_modules folders in the solution folder.
|
||||
|
||||
**update-sln-net80** `<SolutionFilePath>` **NOT IMPLEMENTED IN CLI YET** Updates all projects and Microsoft NuGet packages in sln to .NET 8.0.
|
||||
**update-sln-net80** `<SolutionFilePath>` Updates all projects and Microsoft NuGet packages in sln to .NET 8.0.
|
||||
|
||||
**update-csproj-net80** `<SolutionFilePath>` **NOT IMPLEMENTED IN CLI YET** Updates project and Microsoft NuGet packages to .NET 8.0.
|
||||
**update-csproj-net80** `<CsprojFilePath>` Updates project and Microsoft NuGet packages to .NET 8.0.
|
||||
|
||||
Reference in New Issue
Block a user