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

SpecPackageAsync() public method

public SpecPackageAsync ( string packageName, string packageDir ) : Task
packageName string
packageDir string
return Task
        public async Task<ProcessResult> SpecPackageAsync(string packageName, string packageDir)
        {
            var arguments = new List<string>
            {
                SpecCommandString, packageName
            };
            return await InvokeNugetProcess(arguments, packageDir);
        }

Usage Example

Example #1
0
        /// <summary>
        /// Creates a Nuspec file given the Package Name.
        /// </summary>
        /// <param name="packageName"></param>
        /// <param name="version"></param>
        /// <param name="minClientVersion"></param>
        /// <param name="title"></param>
        /// <param name="tags"></param>
        /// <param name="description"></param>
        /// <param name="licenseUrl"></param>
        /// <param name="dependencies"></param>
        /// <returns></returns>
        public async Task <string> CreateDefaultNuspecFile(string packageName, string version = "1.0.0", string minClientVersion = null, string title = null, string tags = null, string description = null, string licenseUrl = null, string dependencies = null)
        {
            string packageDir = Path.Combine(Environment.CurrentDirectory, packageName);

            if (Directory.Exists(packageDir))
            {
                Directory.Delete(packageDir, true);
            }

            Directory.CreateDirectory(packageDir);

            var commandlineHelper = new CommandlineHelper(TestOutputHelper);
            await commandlineHelper.SpecPackageAsync(packageName, packageDir);

            string filePath = Path.Combine(packageDir, packageName + ".nuspec");

            RemoveSampleNuspecValues(filePath);
            UpdateNuspecFile(filePath, "1.0.0", version);
            UpdateNuspecFile(filePath, "Package description", "This is a test package created by the NuGet team.");
            // Apply the minClientVersion to the spec only if it's defined.
            if (minClientVersion != null)
            {
                UpdateNuspecFile(filePath, "<metadata>", String.Format("<metadata minClientVersion=\"{0}\">", minClientVersion));
            }
            if (title != null)
            {
                UpdateNuspecFile(filePath, "</metadata>", String.Format("<title>{0}</title></metadata>", title));
            }
            if (tags != null)
            {
                UpdateNuspecFile(filePath, "Tag1 Tag2", tags);
            }
            if (description != null)
            {
                UpdateNuspecFile(filePath, "This is a test package created by the NuGet team.", description);
            }
            if (licenseUrl != null)
            {
                UpdateNuspecFile(filePath, "</metadata>", String.Format("<licenseUrl>{0}</licenseUrl></metadata>", licenseUrl));
            }
            if (dependencies != null)
            {
                UpdateNuspecFile(filePath, "</dependencies>", String.Format("{0}</dependencies>", dependencies));
            }
            return(filePath);
        }
All Usage Examples Of NuGetGallery.FunctionalTests.CommandlineHelper::SpecPackageAsync