Пример #1
0
        private static void CreateNuspec(
            string id,
            Version version,
            string description,
            IEnumerable <File> fileList,
            IEnumerable <Dependency> dependencyList,
            IEnumerable <string> tags)
        {
            var nuspec =
                N("package").Append(
                    N("metadata").Append(
                        N("id", id),
                        N("version", version.ToString()),
                        N("authors", Config.Authors),
                        N("owners", Config.Owners),
                        N("licenseUrl", "https://github.com/sergey-shandar/getboost/blob/master/LICENSE"),
                        N("projectUrl", "https://github.com/sergey-shandar/getboost"),
                        N("requireLicenseAcceptance", "false"),
                        N("description", description),
                        N("dependencies").Append(
                            dependencyList.Select(
                                d =>
                                N(
                                    "dependency",
                                    Xml.A("id", d.Id),
                                    Xml.A("version", d.Version)
                                    )
                                )
                            ),
                        N("tags", string.Join(" ", tags))
                        ),
                    N("files").Append(fileList.Select(f => f.N))
                    );
            var nuspecFile = id + ".nuspec";

            nuspec.CreateDocument().Save(nuspecFile);
            Process.Start(
                new ProcessStartInfo(
                    @"..\..\..\packages\NuGet.CommandLine.5.10.0\tools\nuget.exe",
                    "pack " + nuspecFile)
            {
                UseShellExecute = false,
            }).WaitForExit();
            var nupkgFile = id + "." + version + ".nupkg";

            Console.WriteLine("uploading: " + nupkgFile);
            {
                var p = Process.Start(
                    new ProcessStartInfo(
                        @"..\..\..\packages\NuGet.CommandLine.5.10.0\tools\nuget.exe",
                        "push " + nupkgFile + " -Source https://api.nuget.org/v3/index.json -ApiKey _")
                {
                    UseShellExecute = false,
                });
                p.WaitForExit();
                if (p.ExitCode != 0)
                {
                    Environment.Exit(p.ExitCode);
                }
            }
        }