Exemple #1
0
        public async Task <(string?MutagenVersion, string?SynthesisVersion)> GetLatestVersions(Version?dotNetVersion, bool includePrerelease)
        {
            try
            {
                if (dotNetVersion == null)
                {
                    Log.Logger.Error("Can not query for latest nuget versions as there is not dotnet SDK installed.");
                    return(null, null);
                }
                Log.Logger.Information("Querying for latest published library versions");
                var bootstrapProjectDir = new DirectoryPath(Path.Combine(Execution.Paths.WorkingDirectory, "VersionQuery"));
                bootstrapProjectDir.DeleteEntireFolder();
                bootstrapProjectDir.Create();
                var slnPath = Path.Combine(bootstrapProjectDir.Path, "VersionQuery.sln");
                SolutionInitialization.CreateSolutionFile(slnPath);
                var projPath = Path.Combine(bootstrapProjectDir.Path, "VersionQuery.csproj");
                SolutionInitialization.CreateProject(projPath, GameCategory.Skyrim, insertOldVersion: true);
                SolutionInitialization.AddProjectToSolution(slnPath, projPath);
                var ret = await DotNetCommands.QuerySynthesisVersions(projPath, current : false, includePrerelease : includePrerelease, CancellationToken.None);

                Log.Logger.Information("Latest published library versions:");
                Log.Logger.Information($"  Mutagen: {ret.MutagenVersion}");
                Log.Logger.Information($"  Synthesis: {ret.SynthesisVersion}");
                return(ret.MutagenVersion ?? this.MutagenVersion, ret.SynthesisVersion ?? this.SynthesisVersion);
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex, "Error querying for latest nuget versions");
                return(null, null);
            }
        }
 public void DeleteEntireFolder(
     DirectoryPath dir,
     bool disableReadOnly    = true,
     bool deleteFolderItself = true)
 {
     dir.DeleteEntireFolder(
         disableReadOnly: disableReadOnly,
         deleteFolderItself: deleteFolderItself,
         fileSystem: _fileSystem);
 }
Exemple #3
0
    public static void DeleteEntireFolder(
        this DirectoryInfo dir,
        bool disableReadOnly    = true,
        bool deleteFolderItself = true)
    {
        var dirPath = new DirectoryPath(dir.FullName);

        dirPath.DeleteEntireFolder(
            disableReadOnly: disableReadOnly,
            deleteFolderItself: deleteFolderItself);
    }
Exemple #4
0
        private static bool DeleteOldRepo(
            string localDir,
            GetResponse <string> remoteUrl,
            Action <string> logger)
        {
            if (!Directory.Exists(localDir))
            {
                logger("No local repository exists.  No cleaning to do.");
                return(false);
            }
            var dirInfo = new DirectoryPath(localDir);

            if (remoteUrl.Failed)
            {
                logger("No remote repository.  Deleting local.");
                dirInfo.DeleteEntireFolder();
                return(false);
            }
            try
            {
                using var repo = new Repository(localDir);
                // If it's the same remote repo, don't delete
                if (repo.Network.Remotes.FirstOrDefault()?.Url.Equals(remoteUrl.Value) ?? false)
                {
                    logger("Remote repository target matched local folder's repo.  Keeping clone.");
                    return(true);
                }
            }
            catch (RepositoryNotFoundException)
            {
                logger("Repository corrupted.  Deleting local.");
                dirInfo.DeleteEntireFolder();
                return(false);
            }

            logger("Remote address targeted a different repository.  Deleting local.");
            dirInfo.DeleteEntireFolder();
            return(false);
        }
        public static void Clean()
        {
            var dir = new DirectoryPath("Output");

            dir.DeleteEntireFolder();
        }
Exemple #6
0
 public void OneTimeCleanups()
 {
     OneTimeXmlFolder.DeleteEntireFolder();
 }