NuGetGallery.FunctionalTests.CommandlineHelper.UploadPackageAsync C# (CSharp) Method

UploadPackageAsync() public method

Uploads the given package to the specified source and returns the exit code.
public UploadPackageAsync ( string packageFullPath, string sourceName ) : Task
packageFullPath string
sourceName string
return Task
        public async Task<ProcessResult> UploadPackageAsync(string packageFullPath, string sourceName)
        {
            WriteLine("Uploading package " + packageFullPath + " to " + sourceName);

            var arguments = new List<string>
            {
                PushCommandString, packageFullPath, SourceSwitchString, sourceName, ApiKeySwitchString,
                EnvironmentSettings.TestAccountApiKey
            };
            return await InvokeNugetProcess(arguments);
        }

Usage Example

        public async Task UploadNewPackage(string packageId, string version = "1.0.0", string minClientVersion = null,
                                           string title        = null, string tags   = null, string description = null, string licenseUrl = null,
                                           string dependencies = null, string apiKey = null, bool success       = true)
        {
            WriteLine("Uploading new package '{0}', version '{1}'", packageId, version);

            var packageCreationHelper = new PackageCreationHelper(TestOutputHelper);
            var packageFullPath       = await packageCreationHelper.CreatePackage(packageId, version, minClientVersion, title, tags, description, licenseUrl, dependencies);

            try
            {
                var commandlineHelper = new CommandlineHelper(TestOutputHelper);
                var processResult     = await commandlineHelper.UploadPackageAsync(packageFullPath, UrlHelper.V2FeedPushSourceUrl, apiKey);

                if (success)
                {
                    Assert.True(processResult.ExitCode == 0,
                                "The package upload via Nuget.exe did not succeed properly. Check the logs to see the process error and output stream.  Exit Code: " +
                                processResult.ExitCode + ". Error message: \"" + processResult.StandardError + "\"");
                }
                else
                {
                    Assert.False(processResult.ExitCode == 0,
                                 "The package upload via Nuget.exe succeeded but was expected to fail. Check the logs to see the process error and output stream.  Exit Code: " +
                                 processResult.ExitCode + ". Error message: \"" + processResult.StandardError + "\"");
                }
            }
            finally
            {
                // Delete package from local disk once it gets uploaded
                CleanCreatedPackage(packageFullPath);
            }
        }
All Usage Examples Of NuGetGallery.FunctionalTests.CommandlineHelper::UploadPackageAsync