Esempio n. 1
0
        private async void PushToServerButton_Click(object sender, EventArgs e)
        {
            var controlManager = new FormControlManager(this);

            await controlManager.ToggleControlsOfType <Button>(async() =>
            {
                StatusLabel.Text = @"Publishing packages to " + ServerUrlTextBox.Text + @"...";

                if (ArtifactsListView.Items.Count == 0)
                {
                    StatusLabel.Text = @"Please select your artifacts first";
                    return;
                }

                if (string.IsNullOrEmpty(ApiKeyTextBox.Text))
                {
                    StatusLabel.Text = @"Please specify an API key";
                    return;
                }

                if (await RunNuget(@"push ""{0}.nupkg"" -Source " + ServerUrlTextBox.Text + " -ApiKey " + ApiKeyTextBox.Text + " -DisableBuffering" + "{1}", _fileNames, true))
                {
                    StatusLabel.Text = @"Packages successfully published.";
                    return;
                }

                StatusLabel.Text = @"Unable to publish all packages. Check your Internet Connection, Nuget URL and ApiKey.";
            },
                                                               new HashSet <Button> {
                CreateNuspecButton
            });
        }
Esempio n. 2
0
        private async void CreatePackageButton_Click(object sender, EventArgs e)
        {
            var controlManager = new FormControlManager(this);

            await controlManager.ToggleControlsOfType <Button>(async() =>
            {
                StatusLabel.Text = @"Generating packages...";

                if (!await RunNuget(@"spec -a ""lib\{0}.dll"" -force{1}", _fileNames))
                {
                    StatusLabel.Text = @"Error generating NuSpec file(s)";
                    return;
                }

                var options = new ParallelOptions {
                    MaxDegreeOfParallelism = Environment.ProcessorCount
                };

                Parallel.ForEach(_fileNames, options, async fileName =>
                {
                    var match = _assemblyNameRegex.Match(fileName);

                    if (!match.Success)
                    {
                        return;
                    }

                    var nuspecFile = string.Format(@"{0}\{1}.nuspec", _nugetPackagesPath, match.Groups[1].Value);

                    if (!File.Exists(nuspecFile))
                    {
                        return;
                    }

                    var fileText = File.ReadAllText(nuspecFile);

                    if (!string.IsNullOrEmpty(fileText))
                    {
                        using (var writer = File.CreateText(nuspecFile))
                        {
                            var sanitizedNuspecMarkup = _nuspecSanityRegex.Replace(fileText, string.Empty);
                            await writer.WriteAsync(sanitizedNuspecMarkup);
                        }
                    }
                });

                if (await RunNuget(@"pack ""{0}.nuspec""{1}", _fileNames))
                {
                    StatusLabel.Text = @"Package(s) generated successfully.";
                    return;
                }

                StatusLabel.Text = @"Unable to generate all packages. Check folder write permissions.";
            },
                                                               new HashSet <Button> {
                CreateNuspecButton
            });
        }