public void GetVersion(GetVersion task) { var versionVariables = VersionVariables.FromFile(task.VersionFile, fileSystem, log); var outputType = typeof(GetVersion); foreach (var variable in versionVariables) { outputType.GetProperty(variable.Key)?.SetValue(task, variable.Value, null); } }
public void GenerateGitVersionInformation(GenerateGitVersionInformation task) { var versionVariables = VersionVariables.FromFile(task.VersionFile, fileSystem, log); var fileWriteInfo = task.IntermediateOutputPath.GetFileWriteInfo(task.Language, task.ProjectFile, "GitVersionInformation"); task.GitVersionInformationFilePath = Path.Combine(fileWriteInfo.WorkingDirectory, fileWriteInfo.FileName); var gitVersionOptions = this.options.Value; gitVersionOptions.WorkingDirectory = fileWriteInfo.WorkingDirectory; gitVersionOutputTool.GenerateGitVersionInformation(versionVariables, fileWriteInfo); }
public void UpdateAssemblyInfo(UpdateAssemblyInfo task) { var versionVariables = VersionVariables.FromFile(task.VersionFile, fileSystem); FileHelper.DeleteTempFiles(); FileHelper.CheckForInvalidFiles(task.CompileFiles, task.ProjectFile); var fileWriteInfo = task.IntermediateOutputPath.GetFileWriteInfo(task.Language, task.ProjectFile, "AssemblyInfo"); task.AssemblyInfoTempFilePath = PathHelper.Combine(fileWriteInfo.WorkingDirectory, fileWriteInfo.FileName); var gitVersionOptions = this.options.Value; gitVersionOptions.AssemblyInfo.UpdateAssemblyInfo = true; gitVersionOptions.AssemblyInfo.EnsureAssemblyInfo = true; gitVersionOptions.WorkingDirectory = fileWriteInfo.WorkingDirectory; gitVersionOptions.AssemblyInfo.Files.Add(fileWriteInfo.FileName); gitVersionOutputTool.UpdateAssemblyInfo(versionVariables); }
public VersionVariables LoadVersionVariablesFromDiskCache(GitVersionCacheKey key) { using (log.IndentLog("Loading version variables from disk cache")) { var cacheDir = PrepareCacheDirectory(); var cacheFileName = GetCacheFileName(key, cacheDir); if (!fileSystem.Exists(cacheFileName)) { log.Info("Cache file " + cacheFileName + " not found."); return(null); } using (log.IndentLog("Deserializing version variables from cache file " + cacheFileName)) { try { var loadedVariables = VersionVariables.FromFile(cacheFileName, fileSystem); return(loadedVariables); } catch (Exception ex) { log.Warning("Unable to read cache file " + cacheFileName + ", deleting it."); log.Info(ex.ToString()); try { fileSystem.Delete(cacheFileName); } catch (Exception deleteEx) { log.Warning($"Unable to delete corrupted version cache file {cacheFileName}. Got {deleteEx.GetType().FullName} exception."); } return(null); } } } }
public void WriteVersionInfoToBuildLog(WriteVersionInfoToBuildLog task) { var versionVariables = VersionVariables.FromFile(task.VersionFile, fileSystem, log); gitVersionOutputTool.OutputVariables(versionVariables, false); }