@@ -215,9 +215,23 @@ private static Parser BuildCommandLine()
215215 }
216216 }
217217 } , ( MiddlewareOrder ) ( - 3000 ) ) // MiddlewareOrderInternal.ExceptionHandler so [parse] directive is accurate.
218+ . UseExceptionHandler ( ( ex , context ) => PrintException ( ex , context ) )
218219 . Build ( ) ;
219220 }
220221
222+ private static void PrintException ( Exception ex , InvocationContext context )
223+ {
224+ try
225+ {
226+ Console . Error . WriteLine ( "Unhandled exception: {0}" , ex ) ;
227+ }
228+ catch ( Exception ex2 )
229+ {
230+ Console . Error . WriteLine ( "Unhandled exception: {0}" , ex . Message ) ;
231+ Console . Error . WriteLine ( "Unhandled exception while trying to print string version of the above exception: {0}" , ex2 ) ;
232+ }
233+ }
234+
221235 private static int MainInner ( string [ ] args )
222236 {
223237 try
@@ -347,16 +361,16 @@ private static int OnInstallCommand(string path, string version, IReadOnlyList<s
347361 return ( int ) ExitCodes . OK ;
348362 }
349363
350- private static int OnGetVersionCommand ( string project , IReadOnlyList < string > metadata , string format , string variable , string commitIsh )
364+ private static int OnGetVersionCommand ( string project , IReadOnlyList < string > metadata , string format , string variable , string commitish )
351365 {
352366 if ( string . IsNullOrEmpty ( format ) )
353367 {
354368 format = DefaultOutputFormat ;
355369 }
356370
357- if ( string . IsNullOrEmpty ( commitIsh ) )
371+ if ( string . IsNullOrEmpty ( commitish ) )
358372 {
359- commitIsh = DefaultRef ;
373+ commitish = DefaultRef ;
360374 }
361375
362376 string searchPath = GetSpecifiedOrCurrentDirectoryPath ( project ) ;
@@ -368,9 +382,9 @@ private static int OnGetVersionCommand(string project, IReadOnlyList<string> met
368382 return ( int ) ExitCodes . NoGitRepo ;
369383 }
370384
371- if ( ! context . TrySelectCommit ( commitIsh ) )
385+ if ( ! context . TrySelectCommit ( commitish ) )
372386 {
373- Console . Error . WriteLine ( "rev-parse produced no commit for {0}" , commitIsh ) ;
387+ Console . Error . WriteLine ( "rev-parse produced no commit for {0}" , commitish ) ;
374388 return ( int ) ExitCodes . BadGitRef ;
375389 }
376390
@@ -759,7 +773,7 @@ private static async Task<string> GetLatestPackageVersionAsync(string packageId,
759773 var providers = new List < Lazy < INuGetResourceProvider > > ( ) ;
760774 providers . AddRange ( Repository . Provider . GetCoreV3 ( ) ) ; // Add v3 API support
761775
762- var sourceRepositoryProvider = new SourceRepositoryProvider ( settings , providers ) ;
776+ var sourceRepositoryProvider = new SourceRepositoryProvider ( new PackageSourceProvider ( settings ) , providers ) ;
763777
764778 // Select package sources based on NuGet.Config files or given options, as 'nuget.exe restore' command does
765779 // See also 'DownloadCommandBase.GetPackageSources(ISettings)' at https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Clients/NuGet.CommandLine/Commands/DownloadCommandBase.cs
0 commit comments