Exemple #1
0
        public void SignAndReZip(string password)
        {
            AbsolutePath nupkgFile    = ArtifactsDirectory.GlobFiles("*.nupkg").Single();
            AbsolutePath snupkgFile   = ArtifactsDirectory.GlobFiles("*.snupkg").Single();
            AbsolutePath nupkgDir     = TempDirectory / ("sign_" + Path.GetFileName(nupkgFile));
            AbsolutePath coreFxDir    = TempDirectory / ("sign_" + Path.GetFileName(CliCoreZip));
            AbsolutePath nativeZipDir = TempDirectory / ("sign_" + Path.GetFileName(CliNativeZip));

            bool signNative = FileExists(CliNativeExe);

            try
            {
                UnzipFiles(CliCoreZip, coreFxDir);
                List <string> pkgFileList = UnzipPackage(nupkgFile, nupkgDir);

                var toSign = new List <AbsolutePath>();
                toSign.AddRange(nupkgDir.GlobFiles("**/LibHac.dll"));
                toSign.Add(coreFxDir / "hactoolnet.dll");

                if (signNative)
                {
                    UnzipFiles(CliNativeZip, nativeZipDir);
                    toSign.Add(nativeZipDir / "hactoolnet.exe");
                }

                Directory.CreateDirectory(SignedArtifactsDirectory);

                SignAssemblies(password, toSign.Select(x => x.ToString()).ToArray());

                // Avoid having multiple signed versions of the same file
                File.Copy(nupkgDir / "lib" / "netcoreapp3.0" / "LibHac.dll", coreFxDir / "LibHac.dll", true);

                ZipDirectory(SignedArtifactsDirectory / Path.GetFileName(nupkgFile), nupkgDir, pkgFileList);
                ZipDirectory(SignedArtifactsDirectory / Path.GetFileName(CliCoreZip), coreFxDir);

                if (signNative)
                {
                    ZipDirectory(SignedArtifactsDirectory / Path.GetFileName(CliNativeZip), nativeZipDir);
                }

                File.Copy(snupkgFile, SignedArtifactsDirectory / Path.GetFileName(snupkgFile));

                SignNupkg(SignedArtifactsDirectory / Path.GetFileName(nupkgFile), password);
                SignNupkg(SignedArtifactsDirectory / Path.GetFileName(snupkgFile), password);
            }
            catch (Exception)
            {
                Directory.Delete(SignedArtifactsDirectory, true);
                throw;
            }
            finally
            {
                Directory.Delete(nupkgDir, true);
                Directory.Delete(coreFxDir, true);
            }
        }
Exemple #2
0
    void PushNuGetPackages(string githubPackageSource, string githubTokenVariable)
    {
        IReadOnlyCollection <AbsolutePath> packages = ArtifactsDirectory.GlobFiles("*.nupkg");

        DotNetNuGetPush(s => s
                        .SetSource(githubPackageSource)
                        .SetApiKey(Environment.GetEnvironmentVariable(githubTokenVariable))
                        .CombineWith(packages, (s, p) => s
                                     .SetTargetPath(p)));
    }