private void AddRef(ProjectFile csproj, string refName, string hintPath) { if (testReplaces) { TestReplaces(csproj, refName); return; } XmlNode refXml; if (csproj.ContainsRef(refName, out refXml)) { if (UserChoseReplace(csproj, refXml, refName, hintPath)) { csproj.ReplaceRef(refName, hintPath); Log.Debug($"'{refName}' ref replaced"); ConsoleWriter.WriteOk("Successfully replaced " + refName); } } else { SafeAddRef(csproj, refName, hintPath); Log.Debug($"'{refName}' ref added"); ConsoleWriter.WriteOk("Successfully installed " + refName); } }
private void TestReplaces(ProjectFile csproj, string refName) { XmlNode refXml; if (csproj.ContainsRef(refName, out refXml)) { hasReplaces = true; } }
private void UpdateReference(string reference, string project) { var projectPath = Path.GetFullPath(project); var csproj = new ProjectFile(projectPath); var refName = Path.GetFileNameWithoutExtension(reference); var hintPath = Helper.GetRelativePath(Path.Combine(Helper.CurrentWorkspace, reference), Directory.GetParent(projectPath).FullName); XmlNode refXml; if (csproj.ContainsRef(refName, out refXml)) { csproj.ReplaceRef(refName, hintPath); Log.Info($"'{refName}' ref replaced to {hintPath}"); fixReferenceResult.Replaced[project].Add( $"{refName}\n\t\t{GetHintPath(refXml)} ->\n\t\t{hintPath}"); } csproj.Save(); }