Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/nbgv/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -347,16 +361,16 @@ private static int OnInstallCommand(string path, string version, IReadOnlyList<s
return (int)ExitCodes.OK;
}

private static int OnGetVersionCommand(string project, IReadOnlyList<string> metadata, string format, string variable, string commitIsh)
private static int OnGetVersionCommand(string project, IReadOnlyList<string> 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);
Expand All @@ -368,9 +382,9 @@ private static int OnGetVersionCommand(string project, IReadOnlyList<string> 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;
}

Expand Down Expand Up @@ -759,7 +773,7 @@ private static async Task<string> GetLatestPackageVersionAsync(string packageId,
var providers = new List<Lazy<INuGetResourceProvider>>();
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
Expand Down
5 changes: 2 additions & 3 deletions src/nbgv/nbgv.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NuGet.PackageManagement" Version="4.9.3" NoWarn="NU1701" />
<PackageReference Include="NuGet.Resolver" Version="4.9.3" />
<PackageReference Include="NuGet.PackageManagement" Version="5.11.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20574.7" />
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="3.4.173-alpha" PrivateAssets="all" />
<PackageReference Include="System.Diagnostics.Tools" Version="4.3.0" />
<PackageReference Include="Microsoft.Build" Version="15.9.20" />
<PackageReference Include="Microsoft.Build" Version="16.9.0" />
</ItemGroup>

<ItemGroup>
Expand Down