diff --git a/appveyor.yml b/appveyor.yml
index a01cf3a..42bb570 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -7,7 +7,6 @@ os: Visual Studio 2022
environment:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
- TARGET_BUILD_VERSION: '1.0.0'
NUGET_DEPLOY_KEY:
secure: bfIsyEMzYM9AJCFQwxLjAC48zi8/pNgUokbWcEcEo4hzLvrGCKEN6pNYkQIx/w2J
@@ -19,10 +18,10 @@ before_build:
- dotnet restore .\src\DotNetSortRefs.sln
build_script:
-- dotnet build .\src\DotNetSortRefs.sln --configuration Release /p:Version=%TARGET_BUILD_VERSION%
+- dotnet build .\src\DotNetSortRefs.sln --configuration Release
after_test:
- - dotnet pack .\src\DotNetSortRefs --configuration Release /p:Version=%TARGET_BUILD_VERSION%
+ - dotnet pack .\src\DotNetSortRefs --configuration Release
artifacts:
- path: '**\dotnet-sort-refs.*.*nupkg' # find all NuGet packages recursively
diff --git a/src/DotNetSortRefs/DotNetSortRefs.csproj b/src/DotNetSortRefs/DotNetSortRefs.csproj
index ebffc58..4f3de7e 100644
--- a/src/DotNetSortRefs/DotNetSortRefs.csproj
+++ b/src/DotNetSortRefs/DotNetSortRefs.csproj
@@ -1,7 +1,7 @@
A .NET Core global tool to alphabetically sort package references in csproj or fsproj
- 1.0.0
+ 1.0.1
Babu Annamalai
Exe
netcoreapp3.1;net5.0;net6.0
@@ -19,7 +19,7 @@
-
+
diff --git a/src/DotNetSortRefs/Program.cs b/src/DotNetSortRefs/Program.cs
index afce728..af70559 100644
--- a/src/DotNetSortRefs/Program.cs
+++ b/src/DotNetSortRefs/Program.cs
@@ -31,30 +31,28 @@ public Program(IFileSystem fileSystem, IReporter reporter)
static int Main(string[] args)
{
- using (var services = new ServiceCollection()
- .AddSingleton()
- .AddSingleton(provider => new ConsoleReporter(provider.GetService()))
+ using var services = new ServiceCollection()
+ .AddSingleton(PhysicalConsole.Singleton)
+ .AddSingleton(provider => new ConsoleReporter(provider.GetService()!))
.AddSingleton()
- .BuildServiceProvider())
+ .BuildServiceProvider();
+ var app = new CommandLineApplication
{
- var app = new CommandLineApplication
- {
- UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.Throw
- };
+ UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.Throw
+ };
- app.Conventions
- .UseDefaultConventions()
- .UseConstructorInjection(services);
+ app.Conventions
+ .UseDefaultConventions()
+ .UseConstructorInjection(services);
- try
- {
- return app.Execute(args);
- }
- catch (UnrecognizedCommandParsingException)
- {
- app.ShowHelp();
- return 1;
- }
+ try
+ {
+ return app.Execute(args);
+ }
+ catch (UnrecognizedCommandParsingException)
+ {
+ app.ShowHelp();
+ return 1;
}
}
@@ -69,7 +67,7 @@ static int Main(string[] args)
private static string GetVersion() => typeof(Program)
.Assembly
.GetCustomAttribute()
- .InformationalVersion;
+ ?.InformationalVersion;
private async Task OnExecute(CommandLineApplication app, IConsole console)
{
@@ -118,7 +116,7 @@ private async Task OnExecute(CommandLineApplication app, IConsole console)
}
catch (Exception e)
{
- _reporter.Error(e.StackTrace);
+ _reporter.Error(e.StackTrace!);
return 1;
}
}
@@ -181,12 +179,10 @@ private async Task SortReferences(IEnumerable projFiles)
{
_reporter.Output($"ยป {proj}");
- using (var sw = new StringWriter())
- {
- var doc = XDocument.Parse(System.IO.File.ReadAllText(proj));
- xslt.Transform(doc.CreateNavigator(), null, sw);
- File.WriteAllText(proj, sw.ToString());
- }
+ await using var sw = new StringWriter();
+ var doc = XDocument.Parse(await System.IO.File.ReadAllTextAsync(proj));
+ xslt.Transform(doc.CreateNavigator(), null, sw);
+ await File.WriteAllTextAsync(proj, sw.ToString());
}
return await Task.FromResult(0);
@@ -195,13 +191,11 @@ private async Task SortReferences(IEnumerable projFiles)
private static XslCompiledTransform GetXslTransform()
{
var assembly = Assembly.GetExecutingAssembly();
- using (var stream = assembly.GetManifestResourceStream("DotNetSortRefs.Sort.xsl"))
- using (var reader = XmlReader.Create(stream))
- {
- var xslt = new XslCompiledTransform();
- xslt.Load(reader);
- return xslt;
- }
+ using var stream = assembly.GetManifestResourceStream("DotNetSortRefs.Sort.xsl");
+ using var reader = XmlReader.Create(stream!);
+ var xslt = new XslCompiledTransform();
+ xslt.Load(reader);
+ return xslt;
}
}
}