public bool IsDotNetFrameworkCsprojFile(string path) { var lines = _filesystem.ReadAllLines(path).Where(line => !string.IsNullOrEmpty(line)).ToArray(); if (lines.Length < 2) { _logger.Warning("Csproj found at {Path} seems malformed. {Lines}", path, lines); return(false); } var firstLineIsXmlDeclaration = lines.ElementAt(0) == "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; var secondLineIsProjectElementWithToolsVersionAttr = lines.ElementAt(1).StartsWith("<Project ToolsVersion"); return(firstLineIsXmlDeclaration && secondLineIsProjectElementWithToolsVersionAttr); }
private void UpdateLink(string linkName, string path) { (var filePath, var _) = EnsureLinkRegistryFileExists(); var lines = _filesystem.ReadAllLines(filePath); var linesCopy = new List <string>(); foreach (var line in lines) { if (line.StartsWith(linkName)) { var updatedLine = $"{linkName},{path}"; linesCopy.Add(updatedLine); } else { linesCopy.Add(line); } } _filesystem.WriteAllLines(filePath, linesCopy); }