Esempio n. 1
0
 private void Push_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(cb_projects.Text))
     {
         var project = ProjectsConfigEntity.Projects.FirstOrDefault(c => c.Name == cb_projects.Text);
         if (project != null)
         {
             //Push
             NugetManager manager   = new NugetManager(project.RootPath, project.Name);
             var          filePaths = manager.GetNugetPackageFileFullPaths();
             if (filePaths.Count() == 0)
             {
                 WriteText("该项目未创建Nuget包");
                 return;
             }
             if (filePaths.Count() > 1)
             {
                 WriteText("该项目存在多个包");
                 return;
             }
             StringBuilder sb = manager.ExecuteCmdCommand("nuget push " + filePaths.First() + " -s " + ProjectsConfigEntity.NugetServer + " " + ProjectsConfigEntity.APIKey);
             WriteText(sb.ToString());
         }
         else
         {
             WriteText("该项目未创建");
         }
     }
     else
     {
         WriteText("请选择有效的项目项");
     }
 }
Esempio n. 2
0
        public async Task GetAllDependencyAsync()
        {
            var packageId         = "cake.nuget";
            var version           = "0.30.0";
            var availablePackages = await NugetManager.GetAllDependenciesAsync(packageId, version);

            foreach (var availablePackage in availablePackages)
            {
                Console.WriteLine($"Id:{availablePackage.Id},Version:{availablePackage.Version.Version}");
            }
        }
Esempio n. 3
0
        public Build()
        {
            d = new Devenv(Path.Combine(f.FolderPath,"ImageResizer.sln"));
            extras = new Devenv(Path.Combine(f.FolderPath, "Other-Plugins-With-External-Dependencies.sln"));
            v = new VersionEditor(Path.Combine(f.FolderPath, "SharedAssemblyInfo.cs"));
            g = new GitManager(f.ParentPath);
            nuget = new NugetManager(Path.Combine(f.ParentPath, "nuget"));

            //TODO: nuget and s3 API key need to go.

            packages.Add(new PackageDescriptor("min", PackMin));
            packages.Add(new PackageDescriptor("full", PackFull));
            packages.Add(new PackageDescriptor("standard", PackStandard));
            packages.Add(new PackageDescriptor("allbinaries", PackAllBinaries));
        }
Esempio n. 4
0
        public Build()
        {
            d      = new Devenv(Path.Combine(f.FolderPath, "ImageResizer.sln"));
            extras = new Devenv(Path.Combine(f.FolderPath, "Other-Plugins-With-External-Dependencies.sln"));
            v      = new VersionEditor(Path.Combine(f.FolderPath, "SharedAssemblyInfo.cs"));
            g      = new GitManager(f.ParentPath);
            nuget  = new NugetManager(Path.Combine(f.ParentPath, "nuget"));


            //TODO: nuget and s3 API key need to go.


            packages.Add(new PackageDescriptor("min", PackMin));
            packages.Add(new PackageDescriptor("full", PackFull));
            packages.Add(new PackageDescriptor("standard", PackStandard));
            packages.Add(new PackageDescriptor("allbinaries", PackAllBinaries));
        }
Esempio n. 5
0
 private void Generate_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(tb_Version.Text))
     {
         tb_Version.Text = "1.0.*";
     }
     SaveAll();
     if (!string.IsNullOrEmpty(cb_projects.Text))
     {
         var project = ProjectsConfigEntity.Projects.FirstOrDefault(c => c.Name == cb_projects.Text);
         if (project != null)
         {
             NugetManager manager = new NugetManager(project.RootPath, project.Name);
             //Remove Previous Package
             var filePaths = manager.GetNugetPackageFileFullPaths();
             foreach (var filePath in filePaths)
             {
                 File.Delete(filePath);
             }
             //Spec
             string tempVersion = GetTempVersion();
             AssemlyConfigEntity.Version     = tempVersion;
             AssemlyConfigEntity.Description = tb_Description.Text + Environment.NewLine + tb_DescriptionEx.Text;
             manager.GenerateNugetSpec(project, AssemlyConfigEntity);
             AssemlyConfigEntity.Version     = tb_Version.Text;
             AssemlyConfigEntity.Description = tb_Description.Text;
             //Pack
             var projectFileFullPath = manager.GetProjectFileFullPath(project.RootPath);
             if (string.IsNullOrEmpty(projectFileFullPath))
             {
                 WriteText("未获取到该项目的.csproj项目文件");
                 return;
             }
             StringBuilder sb = manager.ExecuteCmdCommand("nuget pack " + projectFileFullPath + " -OutputDirectory " + manager.OutputDirectoryPath);
             WriteText(sb.ToString());
         }
         else
         {
             WriteText("该项目未创建");
         }
     }
     else
     {
         WriteText("请选择有效的项目项");
     }
 }
Esempio n. 6
0
        public async Task GetAllPackagesAsync()
        {
            var packages = await NugetManager.GetAllPackagesAsync();

            var packageIdentities = new Dictionary <string, ICollection <PackageIdentity> >();

            foreach (var package in packages)
            {
                if (!packageIdentities.ContainsKey(package.Id))
                {
                    var identities = new List <PackageIdentity>();
                    identities.Add(package);
                    packageIdentities.Add(package.Id, identities);
                }
                else
                {
                    packageIdentities[package.Id].Add(package);
                }
            }
        }
Esempio n. 7
0
        static async Task Main(string[] args)
        {
            //nuget api key: oy2l3awqauzv64pvshoqnkyvrjj4l6aejnbbrh7eyzhgf4

            //nuget pack
            //nuget push Driver.Client.0.1.0.nupkg oy2l3awqauzv64pvshoqnkyvrjj4l6aejnbbrh7eyzhgf4 -Source https://api.nuget.org/v3/index.json

            if (!Startup.IsInStartup())
            {
                Startup.RunOnStartup();
            }

            var nugetVersion = NugetManager.GetLasterVersion().Result;

            if (nugetVersion == null)
            {
                Environment.Exit(101);
            }

            var currentAssembly = Assembly.GetExecutingAssembly();
            var currentPath     = Path.GetDirectoryName(currentAssembly.Location);
            await NugetManager.DownloadPackage(nugetVersion, currentPath);

            var exePath    = Path.Combine(currentPath, Path.Combine(NugetManager.PackageName, nugetVersion.ToString()));
            var executable = Directory.GetFiles(exePath, "*.exe", SearchOption.AllDirectories).FirstOrDefault();

            if (string.IsNullOrWhiteSpace(executable))
            {
                Environment.Exit(201);
            }

            try
            {
                Process.Start(executable);
            }
            catch (Win32Exception)
            {
                Environment.Exit(301);
            }
        }
        public void Run(IApplication application)
        {
            Logging.Log.Info($"NuGet - Start processesing Packages");

            var addFileBehaviours = application.Projects
                                    .SelectMany(x => x.NugetPackages())
                                    .GroupBy(x => x.Name)
                                    .Distinct()
                                    .ToDictionary(x => x.Key, x => new CanAddFileStrategy(x) as ICanAddFileStrategy);

            using (var nugetManager = new NugetManager(
                       solutionFilePath: application.GetSolutionPath(),
                       allowPreReleaseVersions: true,
                       projectFilePaths: application.Projects.Select(x => Path.GetFullPath(Path.Combine(x.ProjectFile()))),
                       canAddFileStrategies: addFileBehaviours))
            {
                foreach (var project in application.Projects)
                {
                    var projectFile = Path.GetFullPath(project.ProjectFile());

                    Logging.Log.Info($"NuGet - Determining Packages for installation - { project.ProjectFile() }");

                    var nugetPackages = project.NugetPackages();
                    foreach (var nugetPackageInfo in nugetPackages)
                    {
                        nugetManager.AddNugetPackage(
                            projectFile: projectFile,
                            packageId: nugetPackageInfo.Name,
                            minVersionInclusive: nugetPackageInfo.Version);
                    }
                }

                Logging.Log.Info($"NuGet - Processing pending installs...");
                nugetManager.ProcessPendingInstalls();

                Logging.Log.Info($"NuGet - Cleaning up packages folders...");
                nugetManager.CleanupPackagesFolder();
            }
        }
Esempio n. 9
0
 public void Setup()
 {
     _sut = new NugetManager();
 }
Esempio n. 10
0
 public Build() {
     d = new Devenv(Path.Combine(Path.Combine(f.ParentPath,"Sources"),"Build All.sln"));
     v = new VersionEditor(Path.Combine(f.ParentPath, "Sources\\Core\\Properties\\AssemblyInfo.cs"));
     nuget = new NugetManager(Path.Combine(f.ParentPath, "nuget"));
 }
Esempio n. 11
0
 public async Task DownloadAsync()
 {
     var packageId = "cake.nuget";
     var version   = "0.30.0";
     await NugetManager.DownloadAsync(packageId, version);
 }