public void DefaultPublishPaths()
        {
            NugetExec nugEx = new NugetExec();

            Assert.Equal("https://www.nuget.org/api/v2/package/", nugEx.PublishToPath);
            Assert.Equal("https://nuget.smbsrc.net", nugEx.PublishSymbolToPath);
        }
Example #2
0
        private List <NugetPublishStatus> ExecPublishCommand()
        {
            NugetExec nug = null;
            Tuple <string, string> nupkgs = GetNugetPkgs(NugetPackageName);

            if (string.IsNullOrEmpty(NugetExePath))
            {
                nug = new NugetExec();
            }
            else
            {
                nug = new NugetExec(NugetExePath);
            }

            nug.PublishToPath         = PublishNugetToPath;
            nug.SkipPublishingNuget   = SkipNugetPublishing;
            nug.SkipPublishingSymbols = SkipSymbolPublishing;
            nug.ApiKey = ApiKey;

            if (SkipNugetPublishing == true && SkipSymbolPublishing == true)
            {
                throw new ApplicationException("Requested to skip Publishing Nuget and Symbols");
            }

            List <NugetPublishStatus> publishStatusList = nug.Publish(nupkgs);

            return(publishStatusList);
        }
        /// <summary>
        /// Deletes packages from known nuget cache location
        /// </summary>
        /// <returns></returns>
        public override bool Execute()
        {
            base.Execute();

            if (WhatIf)
            {
                WhatIfAction();
            }
            else
            {
                packagesToBeCleaned?.AddRange(PackageReferences);

                TaskLogger.LogInfo(MessageImportance.Low, packagesToBeCleaned, "Pacakges to be deleted....");

                List <string> localCacheLocations = new NugetExec().GetRestoreCacheLocation();

                if (RestoreCacheLocations != null)
                {
                    localCacheLocations.AddRange(RestoreCacheLocations);
                }

                if (!string.IsNullOrEmpty(PackageDirSearchPattern))
                {
                    packagesToBeCleaned.Add(PackageDirSearchPattern);
                }

                if (localCacheLocations.Any <string>())
                {
                    Task[] delTsks  = new Task[localCacheLocations.Count];
                    int    tskCount = 0;

                    localCacheLocations.ForEach((cl) =>
                    {
                        //TaskLogger.LogDebugInfo("Checking {0}", cl);
                        delTsks[tskCount] = Task.Run(async() => await CleanRestoredPackagesAsync(cl));
                        tskCount++;
                    });

                    Task.WaitAll(delTsks);

                    TaskLogger.LogInfo("Cleaning of Packages completed.....");
                }

                //DeleteNupkgOutputDir();
            }
            return(TaskLogger.TaskSucceededWithNoErrorsLogged);
        }