Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: dd25fb6ebd
Fetching contributors…

Cannot retrieve contributors at this time

47 lines (42 sloc) 1.381 kB
using System;
using System.IO;
using System.Linq;
using System.Xml.Linq;
public class ProjectRemover
{
XDocument xDocument;
public ProjectRemover(string projectFile)
{
new FileInfo(projectFile).IsReadOnly = false;
xDocument = XDocument.Load(projectFile);
RemoveImport();
RemoveFodyWeaversXmlContent();
xDocument.Save(projectFile);
DeleteFodyWeaversXmlFile(projectFile);
}
void RemoveFodyWeaversXmlContent()
{
xDocument.Descendants()
.Where(x => string.Equals((string)x.Attribute("Include"), "FodyWeavers.xml", StringComparison.InvariantCultureIgnoreCase))
.Remove();
}
void DeleteFodyWeaversXmlFile(string projectFile)
{
var tasksPath = Path.Combine(Path.GetDirectoryName(projectFile), "FodyWeavers.xml");
if (File.Exists(tasksPath))
{
new FileInfo(tasksPath).IsReadOnly = false;
File.Delete(tasksPath);
}
}
void RemoveImport()
{
xDocument.BuildDescendants("Import")
.Where(x =>
{
var xAttribute = x.Attribute("Project");
return xAttribute != null && xAttribute.Value.EndsWith("Fody.targets", StringComparison.InvariantCultureIgnoreCase);
})
.Remove();
}
}
Jump to Line
Something went wrong with that request. Please try again.