Exemple #1
0
        public bool GitCloneRepo(Action <string> clone_complated)
        {
            if (_config == null)
            {
                return(false);
            }
            var clone_path = Utils.Utilities.Temp_Repo_Path;

            var success = IOHelper.CleanOrInitDirectory(clone_path);

            if (success == false)
            {
                return(false);
            }

            var co = new CloneOptions();

            co.RepositoryOperationCompleted = new LibGit2Sharp.Handlers.RepositoryOperationCompleted((r) =>
            {
                Console.WriteLine(r.RemoteUrl);
                clone_complated?.Invoke(r.RemoteUrl);
            });
            co.CredentialsProvider = (_url, _user, _cred) =>
            {
                return(new UsernamePasswordCredentials
                {
                    Username = _config.Access_Token,
                    Password = string.Empty
                });
            };
            Repository.Clone(_config.Target_Repo, clone_path, co);
            return(true);
        }
Exemple #2
0
 public bool PublishProject()
 {
     try
     {
         ProcessHelper.RunProcess("dotnet", new[] { "publish", Utils.Utilities.Temp_Repo_Path });
         IOHelper.CleanOrInitDirectory(Utils.Utilities.Copy_Path);
         var publish_path    = Path.Combine(Utils.Utilities.Temp_Repo_Path, "bin", "Debug", "netcoreapp3.1", "publish");
         var target_zip_path = Path.Combine(Utils.Utilities.Copy_Path, "temp.zip");
         ZipFile.CreateFromDirectory(publish_path, target_zip_path);
         ZipFile.ExtractToDirectory(target_zip_path, Utils.Utilities.Copy_Path);
         File.Delete(target_zip_path);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
     return(true);
 }