Beispiel #1
0
        private static string CreatePackageWithTargetFrameworkInternal(ref string standardOutput, ref string standardError, string nuspecFileFullPath, string frameworkVersion)
        {
            string nuspecDir = Path.GetDirectoryName(nuspecFileFullPath);

            AddContent(nuspecDir, frameworkVersion);
            AddLib(nuspecDir, frameworkVersion);
            CmdLineHelper.InvokeNugetProcess(string.Join(string.Empty, new string[] { CmdLineHelper.PackCommandString, @"""" + nuspecFileFullPath + @"""", CmdLineHelper.OutputDirectorySwitchString, @"""" + nuspecDir + @"""" }), out standardError, out standardOutput, Path.GetFullPath(Path.GetDirectoryName(nuspecFileFullPath)));
            string[] nupkgFiles = Directory.GetFiles(nuspecDir, "*.nupkg").ToArray();
            if (nupkgFiles == null || nupkgFiles.Length == 0)
            {
                return(null);
            }
            else
            {
                return(nupkgFiles[0]);
            }
        }
        /// <summary>
        /// Creates a Nuspec file given the Package Name.
        /// </summary>
        /// <param name="packageName"></param>
        /// <returns></returns>
        public static 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 standardOutput = string.Empty;
            string standardError  = string.Empty;
            string packageDir     = Path.Combine(Environment.CurrentDirectory, packageName);

            if (Directory.Exists(packageDir))
            {
                Directory.Delete(packageDir, true);
            }
            Directory.CreateDirectory(packageDir);
            CmdLineHelper.InvokeNugetProcess(string.Join(string.Empty, new string[] { CmdLineHelper.SpecCommandString, packageName }), out standardError, out standardOutput, 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);
        }
        /// <summary>
        /// Creates a Nuspec file given the Package Name.
        /// </summary>
        /// <param name="packageName"></param>
        /// <returns></returns>
        public static string CreateDefaultNuspecFile(string packageName, string version = "1.0.0", string minClientVersion = null)
        {
            string standardOutput = string.Empty;
            string standardError  = string.Empty;
            string packageDir     = Path.Combine(Environment.CurrentDirectory, packageName);

            if (Directory.Exists(packageDir))
            {
                Directory.Delete(packageDir, true);
            }
            Directory.CreateDirectory(packageDir);
            CmdLineHelper.InvokeNugetProcess(string.Join(string.Empty, new string[] { CmdLineHelper.SpecCommandString, packageName }), out standardError, out standardOutput, packageDir);
            string filePath = Path.Combine(packageDir, packageName + ".nuspec");

            RemoveSampleNuspecValues(filePath);
            UpdateNuspecFile(filePath, "1.0.0", version);

            // Apply the minClientVersion to the spec only if it's defined.
            if (minClientVersion != null)
            {
                UpdateNuspecFile(filePath, "<metadata>", String.Format("<metadata minClientVersion=\"{0}\">", minClientVersion));
            }
            return(filePath);
        }