Пример #1
0
 private void PublishNuGet(PackageInfo packageInfo, string nugetSecretKey)
 {
     Info($"Publishing NuGet {packageInfo.Version}");
     try
     {
         var program = new DotNetProgram("nuget")
         {
             Arguments =
             {
                 "push",
                 "*.nupkg",
                 "-s https://api.nuget.org/v3/index.json",
                 $"-k {nugetSecretKey}",
                 "--skip-duplicate"
             },
             WorkingDirectory = _buildFolder
         };
         program.Run();
     }
     catch (Exception ex)
     {
         var message = ex.Message.Replace(nugetSecretKey, "**********");
         Error($"Failing to push nuget package. Reason: {message}");
     }
 }
Пример #2
0
        private void BuildNuGet(PackageInfo packageInfo)
        {
            Info($"Building NuGet {packageInfo.Version}");
            var nugetPath = Path.Combine(_baseConsoleAppFolder, "bin", "Release", $"{_repo}.{packageInfo.Version}.nupkg");

            if (File.Exists(nugetPath))
            {
                File.Delete(nugetPath);
            }

            var program = new DotNetProgram("pack")
            {
                Arguments =
                {
                    "-c Release",
                },
            };

            program.WorkingDirectory = _baseConsoleAppFolder;
            program.Run();

            if (!File.Exists(nugetPath))
            {
                Error($"Unable to find generated NuGet file {nugetPath}");
                return;
            }

            File.Copy(nugetPath, Path.Combine(_buildFolder, Path.GetFileName(nugetPath)), true);
        }
Пример #3
0
        private void BuildAppx(PackageInfo packageInfo)
        {
            Info($"Building Appx {packageInfo.Version}");
            var storeAppFolder    = Path.Combine(_srcFolder, "Kalk.StoreApp");
            var storeAppBinFolder = Path.Combine(storeAppFolder, "bin", "Release");

            if (Directory.Exists(storeAppBinFolder))
            {
                Directory.Delete(storeAppBinFolder, true);
            }
            var storeAppFile = Path.Combine(storeAppBinFolder, $"kalk.{packageInfo.Version}.win-x64.appx");
            var program      = new DotNetProgram("publish")
            {
                Arguments =
                {
                    "-c Release"
                },
                WorkingDirectory = storeAppFolder
            };

            program.Run();

            if (!File.Exists(storeAppFile))
            {
                Error($"Unable to find generated Appx file {storeAppFile}");
                return;
            }

            File.Copy(storeAppFile, Path.Combine(_buildFolder, Path.GetFileName(storeAppFile)), true);
        }
Пример #4
0
        private List <PackageEntry> PackPlatform(string rid, string version, params PackageKind[] kinds)
        {
            var program = new DotNetProgram("publish")
            {
                Arguments =
                {
                    "-c Release",
                    $"-r {rid}",
                },
                Properties =
                {
                    { "PublishTrimmed",                      true   },
                    { "TrimMode",                            "Link" },
                    { "PublishSingleFile",                   true   },
                    { "SelfContained",                       true   },
                    { "CopyOutputSymbolsToPublishDirectory", false  },
                    { "SkipCopyingSymbolsToOutputDirectory", true   }
                }
            };

            var  entries          = new List <PackageEntry>();
            bool hasTargetToBuild = false;

            foreach (var kind in kinds)
            {
                string target = null;
                string ext;
                string mime;
                switch (kind)
                {
                case PackageKind.Deb:
                    target = "CreateDeb";
                    ext    = "deb";
                    mime   = "application/vnd.debian.binary-package";
                    break;

                case PackageKind.Rpm:
                    target = "CreateRpm";
                    ext    = "rpm";
                    mime   = "application/x-rpm";
                    break;

                case PackageKind.Zip:
                    target = "CreateZip";
                    ext    = "zip";
                    mime   = "application/zip";
                    break;

                case PackageKind.TarBall:
                    target = "CreateTarball";
                    ext    = "tar.gz";
                    mime   = "application/gzip";
                    break;

                default:
                    throw new ArgumentException($"Invalid kind {kind}", nameof(kind));
                }

                var file = Path.Combine(_baseConsoleNet5ReleaseFolder, rid, $"kalk.{version}.{rid}.{ext}");

                var buildFile = Path.Combine(_buildFolder, $"kalk.{version}.{rid}.{ext}");


                Info($"Building {Path.GetFileName(file)}");
                var entry = new PackageEntry()
                {
                    Kind      = kind,
                    Path      = file,
                    RuntimeId = rid,
                    Mime      = mime
                };
                entries.Add(entry);

                if (File.Exists(buildFile))
                {
                    entry.Path = buildFile;
                    continue;
                }

                program.Arguments.Add($"-t:{target}");
                hasTargetToBuild = true;
            }

            // Build only if required
            if (hasTargetToBuild)
            {
                program.WorkingDirectory = _baseConsoleAppFolder;
                program.Run();
            }

            foreach (var entry in entries)
            {
                if (!File.Exists(entry.Path))
                {
                    throw new InvalidOperationException($"Cannot find the generatd file: {entry.Path}");
                }

                // Copy the result of the build to if necessary
                var buildPath = Path.Combine(_buildFolder, Path.GetFileName(entry.Path));
                if (buildPath != entry.Path)
                {
                    File.Copy(entry.Path, buildPath);
                    entry.Path = buildPath;
                }

                if (entry.Kind == PackageKind.TarBall)
                {
                    entry.ComputeSha256();
                }
            }

            return(entries);
        }