From 336ecc0e8946ee968bf3398accc4000d9f472f10 Mon Sep 17 00:00:00 2001 From: PiotrP Date: Fri, 26 Aug 2016 17:23:33 -0700 Subject: [PATCH] Merge Nuget changes Fix pack Move dotnet-nuget to NuGetForwardingApp [tests will need to be fixed] --- .../dotnet-restore => }/NuGetForwardingApp.cs | 2 +- .../dotnet-nuget/INuGetCommandRunner.cs | 9 --- .../commands/dotnet-nuget/NuGetCommand.cs | 73 ------------------- src/dotnet/commands/dotnet-nuget/Program.cs | 24 ++++++ .../commands/dotnet-pack/PackageGenerator.cs | 4 +- src/dotnet/commands/dotnet-restore/NuGet3.cs | 1 + src/dotnet/commands/dotnet-restore/Program.cs | 2 - 7 files changed, 28 insertions(+), 87 deletions(-) rename src/dotnet/{commands/dotnet-restore => }/NuGetForwardingApp.cs (96%) delete mode 100644 src/dotnet/commands/dotnet-nuget/INuGetCommandRunner.cs delete mode 100644 src/dotnet/commands/dotnet-nuget/NuGetCommand.cs create mode 100644 src/dotnet/commands/dotnet-nuget/Program.cs diff --git a/src/dotnet/commands/dotnet-restore/NuGetForwardingApp.cs b/src/dotnet/NuGetForwardingApp.cs similarity index 96% rename from src/dotnet/commands/dotnet-restore/NuGetForwardingApp.cs rename to src/dotnet/NuGetForwardingApp.cs index e12bb2b8a..04e86623a 100644 --- a/src/dotnet/commands/dotnet-restore/NuGetForwardingApp.cs +++ b/src/dotnet/NuGetForwardingApp.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.IO; using Microsoft.DotNet.Cli; -namespace Microsoft.DotNet.Tools.Restore +namespace Microsoft.DotNet.Tools { public class NuGetForwardingApp { diff --git a/src/dotnet/commands/dotnet-nuget/INuGetCommandRunner.cs b/src/dotnet/commands/dotnet-nuget/INuGetCommandRunner.cs deleted file mode 100644 index 0b5e738bc..000000000 --- a/src/dotnet/commands/dotnet-nuget/INuGetCommandRunner.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.DotNet.Tools.NuGet -{ - public interface INuGetCommandRunner - { - int Run(string[] commandArgs); - } -} diff --git a/src/dotnet/commands/dotnet-nuget/NuGetCommand.cs b/src/dotnet/commands/dotnet-nuget/NuGetCommand.cs deleted file mode 100644 index 8a8acb79c..000000000 --- a/src/dotnet/commands/dotnet-nuget/NuGetCommand.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using Microsoft.DotNet.Cli.CommandLine; -using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.InternalAbstractions; -using NugetProgram = NuGet.CommandLine.XPlat.Program; - -namespace Microsoft.DotNet.Tools.NuGet -{ - public class NuGetCommand - { - public static int Run(string[] args) - { - DebugHelper.HandleDebugSwitch(ref args); - - var app = new CommandLineApplication(false) - { - Name = "dotnet nuget", - FullName = ".NET NuGet command runner", - Description = "For running NuGet commands (\"dotnet nuget --help\" for specifics)" - }; - - app.OnExecute(() => - { - try - { - return RunCommand(args, new NuGetCommandRunner()); - } - catch (InvalidOperationException e) - { - Console.WriteLine(e.Message); - - return -1; - } - catch (Exception e) - { - Console.WriteLine(e.Message); - - return -2; - } - }); - - return app.Execute(args); - } - - public static int RunCommand(IEnumerable args, INuGetCommandRunner commandRunner) - { - Debug.Assert(commandRunner != null, "A command runner must be passed to RunCommand"); - if (commandRunner == null) - { - throw new InvalidOperationException("No command runner supplied to RunCommand"); - } - - return commandRunner.Run(args.ToArray()); - } - - private class NuGetCommandRunner : INuGetCommandRunner - { - public int Run(string[] commandArgs) - { - var nugetAsm = typeof(NugetProgram).GetTypeInfo().Assembly; - var mainMethod = nugetAsm.EntryPoint; - return (int)mainMethod.Invoke(null, new object[] { commandArgs }); - } - } - } -} diff --git a/src/dotnet/commands/dotnet-nuget/Program.cs b/src/dotnet/commands/dotnet-nuget/Program.cs new file mode 100644 index 000000000..0eb3d8c14 --- /dev/null +++ b/src/dotnet/commands/dotnet-nuget/Program.cs @@ -0,0 +1,24 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Linq; +using Microsoft.DotNet.Cli.CommandLine; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.InternalAbstractions; +using Microsoft.DotNet.Tools; + +namespace Microsoft.DotNet.Tools.Restore +{ + public partial class NuGetCommand + { + public static int Run(string[] args) + { + DebugHelper.HandleDebugSwitch(ref args); + + var nugetApp = new NuGetForwardingApp(args); + + return nugetApp.Execute(); + } + } +} diff --git a/src/dotnet/commands/dotnet-pack/PackageGenerator.cs b/src/dotnet/commands/dotnet-pack/PackageGenerator.cs index 69013e921..1edf880ea 100644 --- a/src/dotnet/commands/dotnet-pack/PackageGenerator.cs +++ b/src/dotnet/commands/dotnet-pack/PackageGenerator.cs @@ -18,8 +18,8 @@ using NuGet.Legacy; using NuGet.Frameworks; using NuGet.Packaging.Core; using NuGet.Versioning; -using PackageBuilder = NuGet.PackageBuilder; -using NuGetConstants = NuGet.Constants; +using PackageBuilder = NuGet.Legacy.PackageBuilder; +using NuGetConstants = NuGet.Legacy.Constants; namespace Microsoft.DotNet.Tools.Compiler { diff --git a/src/dotnet/commands/dotnet-restore/NuGet3.cs b/src/dotnet/commands/dotnet-restore/NuGet3.cs index 0ccc4018a..17cb4a70f 100644 --- a/src/dotnet/commands/dotnet-restore/NuGet3.cs +++ b/src/dotnet/commands/dotnet-restore/NuGet3.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Microsoft.DotNet.Tools; namespace Microsoft.DotNet.Tools.Restore { diff --git a/src/dotnet/commands/dotnet-restore/Program.cs b/src/dotnet/commands/dotnet-restore/Program.cs index c2ecf5205..d55e781ed 100644 --- a/src/dotnet/commands/dotnet-restore/Program.cs +++ b/src/dotnet/commands/dotnet-restore/Program.cs @@ -11,8 +11,6 @@ namespace Microsoft.DotNet.Tools.Restore { public partial class RestoreCommand { - private static readonly string DefaultRid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); - public static int Run(string[] args) { DebugHelper.HandleDebugSwitch(ref args);