From c13d166c4ef191f34a2048196ad2cdf80fa0e6e3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Sep 2021 20:36:40 -0600 Subject: [PATCH 1/4] Update nbgv to ship MSBuild 16.9 This is the latest version that still supports netcoreapp3.1. This should fix the problem of parsing msbuild project files with metadata as xml attributes. --- src/nbgv/nbgv.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nbgv/nbgv.csproj b/src/nbgv/nbgv.csproj index 63465683..3529a9c4 100644 --- a/src/nbgv/nbgv.csproj +++ b/src/nbgv/nbgv.csproj @@ -15,7 +15,7 @@ - + From 496c3592312faf23363554baf773cb837dd054d6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Sep 2021 20:37:02 -0600 Subject: [PATCH 2/4] Fix capitalization in nbgv source code --- src/nbgv/Program.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/nbgv/Program.cs b/src/nbgv/Program.cs index e9ae5d75..8691e2c7 100644 --- a/src/nbgv/Program.cs +++ b/src/nbgv/Program.cs @@ -347,16 +347,16 @@ private static int OnInstallCommand(string path, string version, IReadOnlyList metadata, string format, string variable, string commitIsh) + private static int OnGetVersionCommand(string project, IReadOnlyList metadata, string format, string variable, string commitish) { if (string.IsNullOrEmpty(format)) { format = DefaultOutputFormat; } - if (string.IsNullOrEmpty(commitIsh)) + if (string.IsNullOrEmpty(commitish)) { - commitIsh = DefaultRef; + commitish = DefaultRef; } string searchPath = GetSpecifiedOrCurrentDirectoryPath(project); @@ -368,9 +368,9 @@ private static int OnGetVersionCommand(string project, IReadOnlyList met return (int)ExitCodes.NoGitRepo; } - if (!context.TrySelectCommit(commitIsh)) + if (!context.TrySelectCommit(commitish)) { - Console.Error.WriteLine("rev-parse produced no commit for {0}", commitIsh); + Console.Error.WriteLine("rev-parse produced no commit for {0}", commitish); return (int)ExitCodes.BadGitRef; } From 5e7a00ed24415bc6a76fe076ae76f7d5f10d9df8 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Sep 2021 20:48:49 -0600 Subject: [PATCH 3/4] Defend against losing the first exception's message when Exception.ToString() throws --- src/nbgv/Program.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/nbgv/Program.cs b/src/nbgv/Program.cs index 8691e2c7..a85abf6b 100644 --- a/src/nbgv/Program.cs +++ b/src/nbgv/Program.cs @@ -215,9 +215,23 @@ private static Parser BuildCommandLine() } } }, (MiddlewareOrder)(-3000)) // MiddlewareOrderInternal.ExceptionHandler so [parse] directive is accurate. + .UseExceptionHandler((ex, context) => PrintException(ex, context)) .Build(); } + private static void PrintException(Exception ex, InvocationContext context) + { + try + { + Console.Error.WriteLine("Unhandled exception: {0}", ex); + } + catch (Exception ex2) + { + Console.Error.WriteLine("Unhandled exception: {0}", ex.Message); + Console.Error.WriteLine("Unhandled exception while trying to print string version of the above exception: {0}", ex2); + } + } + private static int MainInner(string[] args) { try From 2b80c11d91883b91a02cb16fed824e198b20f951 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Sep 2021 20:58:58 -0600 Subject: [PATCH 4/4] Update nbgv's NuGet dependency to 5.11.0 Fixes #588 --- src/nbgv/Program.cs | 2 +- src/nbgv/nbgv.csproj | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/nbgv/Program.cs b/src/nbgv/Program.cs index a85abf6b..aad07d3f 100644 --- a/src/nbgv/Program.cs +++ b/src/nbgv/Program.cs @@ -773,7 +773,7 @@ private static async Task GetLatestPackageVersionAsync(string packageId, var providers = new List>(); providers.AddRange(Repository.Provider.GetCoreV3()); // Add v3 API support - var sourceRepositoryProvider = new SourceRepositoryProvider(settings, providers); + var sourceRepositoryProvider = new SourceRepositoryProvider(new PackageSourceProvider(settings), providers); // Select package sources based on NuGet.Config files or given options, as 'nuget.exe restore' command does // See also 'DownloadCommandBase.GetPackageSources(ISettings)' at https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Clients/NuGet.CommandLine/Commands/DownloadCommandBase.cs diff --git a/src/nbgv/nbgv.csproj b/src/nbgv/nbgv.csproj index 3529a9c4..031878f0 100644 --- a/src/nbgv/nbgv.csproj +++ b/src/nbgv/nbgv.csproj @@ -10,8 +10,7 @@ - - +