public override void Run(BuildContext context)
        {
            var settings = new DotNetCoreNuGetPushSettings
            {
                SkipDuplicate = true,
            };

            if (context.EnableNuGetPackage)
            {
                context.Log.Information("Publish to NuGet.");

                string nugetToken = context.EnvironmentVariable("NUGET_AUTH_TOKEN", "");

                if (nugetToken is "")
                {
                    throw new Exception("No NUGET_AUTH_TOKEN environment variable setted.");
                }

                settings.ApiKey = nugetToken;
                settings.Source = "https://api.nuget.org/v3/index.json";

                DeployTo(context, settings);
            }
            else
            {
                context.Log.Information("Publish to Azure.");

                string nugetToken = context.EnvironmentVariable("AZ_AUTH_TOKEN", "");

                if (nugetToken is "")
                {
                    throw new Exception("No AZ_AUTH_TOKEN environment variable setted.");
                }

                try
                {
                    context.DotNetCoreNuGetAddSource(RestoreTask.CustomSourceName, new Cake.Common.Tools.DotNetCore.NuGet.Source.DotNetCoreNuGetSourceSettings
                    {
                        Source = "https://sparkshine.pkgs.visualstudio.com/StardustDL/_packaging/feed/nuget/v3/index.json",
                    });
                }
                catch (Exception ex)
                {
                    context.Log.Error(ex.Message);
                }

                context.DotNetCoreNuGetUpdateSource(RestoreTask.CustomSourceName, new Cake.Common.Tools.DotNetCore.NuGet.Source.DotNetCoreNuGetSourceSettings
                {
                    Source   = "https://sparkshine.pkgs.visualstudio.com/StardustDL/_packaging/feed/nuget/v3/index.json",
                    UserName = "******",
                    StorePasswordInClearText = true,
                    Password = nugetToken,
                });

                settings.ApiKey = "az";
                settings.Source = RestoreTask.CustomSourceName;

                DeployTo(context, settings);
            }
        }
Beispiel #2
0
        static void DoDeploy(BuildContext context, string apiKey, string sourceUrl)
        {
            var settings = new DotNetCoreNuGetPushSettings
            {
                ApiKey        = apiKey,
                Source        = sourceUrl,
                SkipDuplicate = true
            };

            // delete symbols for now
            context.DeleteFiles("src/**/*.symbols.nupkg");

            var packages = context.GetFiles("src/**/*.nupkg");

            foreach (var package in packages)
            {
                try
                {
                    context.DotNetCoreNuGetPush(package.FullPath, settings);
                }
                catch (Exception ex)
                {
                    if (context.AllowNugetUploadFailures)
                    {
                        context.Error($"Error Upload: {package.FullPath} - Exception: {ex}");
                    }
                    else
                    {
                        throw; // break build
                    }
                }
            }
        }
Beispiel #3
0
        public override void Run(BuildContext context)
        {
            var settings = new DotNetCoreNuGetPushSettings
            {
                ApiKey        = context.NugetApiKey,
                Source        = MainNuget,
                SkipDuplicate = true
            };

            var packages = context.GetFiles("src/**/*.nupkg");

            foreach (var package in packages)
            {
                try
                {
                    context.DotNetCoreNuGetPush(package.FullPath, settings);
                }
                catch (Exception ex)
                {
                    if (context.AllowNugetUploadFailures)
                    {
                        context.Error($"Error Upload: {package.FullPath} - Exception: {ex}");
                    }
                    else
                    {
                        throw; // break build
                    }
                }
            }
        }
        public override void Run(DotNetCoreContext context)
        {
            var nugetSettings = new DotNetCoreNuGetPushSettings
            {
                ApiKey    = context.NugetDefaultPushSourceApiKey,
                Source    = context.NugetDefaultPushSourceUrl,
                Verbosity = context.GetVerbosity()
            };

            foreach (var package in context.GetFiles(context.Artifacts.FullPath + "/*.nupkg"))
            {
                context.DotNetCoreNuGetPush(package.FullPath, nugetSettings);
            }
        }
Beispiel #5
0
        public override void Run(DotNetCoreContext context)
        {
            var nugetSettings = new DotNetCoreNuGetPushSettings
            {
                ApiKey = context.NugetDefaultPushSourceApiKey,
                Source = context.NugetDefaultPushSourceUrl
            };

            if (string.IsNullOrEmpty(nugetSettings.ApiKey))
            {
                throw new CakeException("NugetDefaultPushSourceApiKey was not set!");
            }

            context.DotNetCoreNuGetPush(".\\artifacts\\*.nupkg", nugetSettings);
        }
Beispiel #6
0
        public static void DotNetCoreNuGetPush(this ICakeContext context, string packageName, DotNetCoreNuGetPushSettings settings)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (settings == null)
            {
                settings = new DotNetCoreNuGetPushSettings();
            }

            var restorer = new DotNetCoreNuGetPusher(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools);
            restorer.Push(packageName, settings);
        }
Beispiel #7
0
        public override void Run(BuildContext context)
        {
            if (!context.Branch.FriendlyName.Equals("preview") && !context.IsMainBranch)
            {
                return;
            }

            var settings = new DotNetCoreNuGetPushSettings
            {
                ApiKey        = context.NugetApiKey,
                Source        = "https://api.nuget.org/v3/index.json",
                SkipDuplicate = true
            };
            var packages = context.GetFiles("../src/**/*.nupkg");

            foreach (var package in packages)
            {
                context.DotNetCoreNuGetPush(package.FullPath, settings);
            }
        }
Beispiel #8
0
        void DeployTo(BuildContext context, DotNetCoreNuGetPushSettings settings)
        {
            List <string> packageList = new List <string>();

            switch (context.Solution)
            {
            case SolutionType.All:
                break;
            }

            foreach (var pkgName in packageList)
            {
                var file = context.Globber.GetFiles(Paths.Dist.Packages.CombineWithFilePath(pkgName + context.BuildVersion).FullPath + "*.nupkg").FirstOrDefault();
                if (file is null)
                {
                    context.Log.Warning($"No package {pkgName} found.");
                    continue;
                }
                context.DotNetCoreNuGetPush(file.FullPath, settings);
            }
        }
Beispiel #9
0
        private void PushAeroCakeTestSupport(MyContext context, VersionModel versionModel, DotNetCoreNuGetPushSettings defaultSettings)
        {
            var path = new FilePath($"{context.ProjectsPath}/{Projects.AeroCakeTestSupport}/bin/{context.BuildConfiguration}/{Projects.AeroCakeTestSupport}.{versionModel.NuGetFileName}.nupkg");

            _dotNetCore.NuGetPush(path.FullPath, defaultSettings);
        }
Beispiel #10
0
 public void NuGetPush(string packageName, DotNetCoreNuGetPushSettings settings)
 {
     AeroContext.DotNetCoreNuGetPush(packageName, settings);
 }