public void Generate() { var filePath = Path.Combine(directory, fileName); string originalFileContents = null; if (File.Exists(filePath)) { originalFileContents = fileSystem.ReadAllText(filePath); } var fileExtension = Path.GetExtension(filePath); var template = templateManager.GetTemplateFor(fileExtension); var addFormat = templateManager.GetAddFormatFor(fileExtension); var members = string.Join(Environment.NewLine, variables.Select(v => string.Format(" " + addFormat, v.Key, v.Value))); var fileContents = string.Format(template, members); if (fileContents != originalFileContents) { fileSystem.WriteAllText(filePath, fileContents); } }
static KeyValuePair <string, string>[] GetEnvironmentalVariables(VersionVariables variables) { return(variables .Select(v => new KeyValuePair <string, string>("GitVersion_" + v.Key, v.Value)) .ToArray()); }