Ejemplo n.º 1
0
    XElement GetOrCreateAfterBuildTarget()
    {
        var target = xDocument.BuildDescendants("Target")
                     .FirstOrDefault(x => string.Equals((string)x.Attribute("Name"), "AfterBuild", StringComparison.InvariantCultureIgnoreCase));

        if (target == null)
        {
            target = new XElement(XDocumentExtensions.BuildNamespace + "Target", new XAttribute("Name", "AfterBuild"));
            xDocument.Root.Add(target);
        }
        return(target);
    }
Ejemplo n.º 2
0
 void GetFrameworkVersion(XDocument xDocument)
 {
     FrameworkVersionAsString = xDocument.BuildDescendants("TargetFrameworkVersion")
                                .Select(c => c.Value)
                                .First();
     FrameworkVersionAsNumber = Single.Parse(FrameworkVersionAsString.Remove(0, 1), CultureInfo.InvariantCulture);
 }
Ejemplo n.º 3
0
    static bool GetIsSilverlight(XDocument xDocument)
    {
        var targetFrameworkIdentifier = xDocument.BuildDescendants("TargetFrameworkIdentifier")
                                        .Select(c => c.Value)
                                        .FirstOrDefault();

        return(string.Equals(targetFrameworkIdentifier, "Silverlight", StringComparison.OrdinalIgnoreCase));
    }
Ejemplo n.º 4
0
    void InjectWeavingTask()
    {
        var buildDescendants = xDocument.BuildDescendants("NotifyPropertyWeaverMsBuildTask.WeavingTask").ToList();

        if (buildDescendants != null)
        {
            foreach (var element in buildDescendants)
            {
                element.Remove();
            }
        }

        var target = GetOrCreateTarget(Target);

        var xElement = BuildWeavingTaskElement();

        target.Add(xElement);
    }
Ejemplo n.º 5
0
 void RemoveImport()
 {
     xDocument.BuildDescendants("Import")
     .Where(x =>
     {
         var xAttribute = x.Attribute("Project");
         return(xAttribute != null && xAttribute.Value.EndsWith("Fody.targets"));
     })
     .Remove();
 }
Ejemplo n.º 6
0
    void GetTargetFrameworkIdentifier(XDocument xDocument)
    {
        var targetFrameworkIdentifier = xDocument.BuildDescendants("TargetFrameworkIdentifier")
                                        .Select(c => c.Value)
                                        .FirstOrDefault();

        if (string.Equals(targetFrameworkIdentifier, "Silverlight", StringComparison.InvariantCultureIgnoreCase))
        {
            IsSilverlight = true;
        }
    }
Ejemplo n.º 7
0
 public bool Check(XDocument xDocument)
 {
     try
     {
         if (xDocument.BuildDescendants("Fody.WeavingTask").Any())
         {
             return(true);
         }
         return(xDocument.BuildDescendants("Import")
                .Any(x =>
         {
             var xAttribute = x.Attribute("Project");
             return xAttribute != null && xAttribute.Value.EndsWith("Fody.targets");
         }));
     }
     catch (Exception exception)
     {
         throw new Exception("Could not check project for weaving task.", exception);
     }
 }
Ejemplo n.º 8
0
 static bool ContainsWeavingTask(XDocument xDocument)
 {
     try
     {
         return(xDocument.BuildDescendants("NotifyPropertyWeaverMsBuildTask.WeavingTask").Any());
     }
     catch (Exception exception)
     {
         throw new Exception("Could not check project for weaving task.", exception);
     }
 }
Ejemplo n.º 9
0
 static bool ContainsEmbedTask(XDocument xDocument)
 {
     try
     {
         return(xDocument.BuildDescendants("Costura.EmbedTask").Any());
     }
     catch (Exception exception)
     {
         throw new Exception("Could not check project for Costura.EmbedTask", exception);
     }
 }
Ejemplo n.º 10
0
    void InjectWeaversContent()
    {
        var exists = xDocument.Descendants()
                     .Any(x =>
        {
            var xAttribute = x.Attribute("Include");
            return(xAttribute != null && xAttribute.Value == "FodyWeavers.xml");
        });

        if (exists)
        {
            return;
        }

        var itemGroup = xDocument.BuildDescendants("ItemGroup").FirstOrDefault();

        if (itemGroup == null)
        {
            itemGroup = new XElement(MsBuildXmlExtensions.BuildNamespace + "ItemGroup");
            xDocument.Root.Add(itemGroup);
        }
        itemGroup.Add(new XElement(MsBuildXmlExtensions.BuildNamespace + "None", new XAttribute("Include", "FodyWeavers.xml")));
    }
Ejemplo n.º 11
0
 void RemoveUsingTask()
 {
     xDocument.BuildDescendants("UsingTask")
     .Where(x => (string)x.Attribute("TaskName") == "NotifyPropertyWeaverMsBuildTask.WeavingTask")
     .Remove();
 }
Ejemplo n.º 12
0
 void GetTargetFrameworkProfile(XDocument xDocument)
 {
     TargetFrameworkProfile = xDocument.BuildDescendants("TargetFrameworkProfile")
                              .Select(c => c.Value)
                              .FirstOrDefault();
 }
Ejemplo n.º 13
0
 static string GetTargetFrameworkProfile(XDocument xDocument)
 {
     return(xDocument.BuildDescendants("TargetFrameworkProfile")
            .Select(c => c.Value)
            .FirstOrDefault());
 }
Ejemplo n.º 14
0
 void RemoveEmbedTask()
 {
     xDocument.BuildDescendants("Target")
     .Where(x => string.Equals((string)x.Attribute("Name"), "AfterBuild", StringComparison.InvariantCultureIgnoreCase))
     .Descendants(XDocumentExtensions.BuildNamespace + "Costura.EmbedTask").Remove();
 }