dotnet-installer/build_projects/dotnet-cli-build/NuGetUtil.cs
Eric Erhardt 78e34c6eb7 Move PullNupkgFilesFromBlob into FinalizeBuild.
Also, update dotnet/versions for the DotNetHost and NetCore.App packages.

Fix #3031
2016-05-21 23:18:13 -05:00

32 lines
997 B
C#

using System.IO;
using System.Reflection;
using Microsoft.DotNet.Cli.Build.Framework;
using NugetProgram = NuGet.CommandLine.XPlat.Program;
namespace Microsoft.DotNet.Cli.Build
{
public static class NuGetUtil
{
public static void PushPackages(string packagesPath, string destinationUrl, string apiKey)
{
int result = RunNuGetCommand(
"push",
"-s", destinationUrl,
"-k", apiKey,
Path.Combine(packagesPath, "*.nupkg"));
if (result != 0)
{
throw new BuildFailureException($"NuGet Push failed with exit code '{result}'.");
}
}
private static int RunNuGetCommand(params string[] nugetArgs)
{
var nugetAssembly = typeof(NugetProgram).GetTypeInfo().Assembly;
var mainMethod = nugetAssembly.EntryPoint;
return (int)mainMethod.Invoke(null, new object[] { nugetArgs });
}
}
}