ProjectReader.GetDependenciesDirectory C# (CSharp) Method

GetDependenciesDirectory() public static method

public static GetDependenciesDirectory ( string projectFile ) : string
projectFile string
return string
    public static string GetDependenciesDirectory(string projectFile)
    {
        var xDocument = ReadXDocument(projectFile);
        var elements =
            from el in xDocument.BuildDescendants("Reference")
            where ((string) el.Attribute("Include")).StartsWith("NotifyPropertyWeaver")
            select el;
        var firstOrDefault = elements.FirstOrDefault();
        if (firstOrDefault != null)
        {
            var value = firstOrDefault.Value;
            var indexOf = value.IndexOf("NotifyPropertyWeaver.dll", StringComparison.OrdinalIgnoreCase);
            if (indexOf > 0)
            {
                return value.Substring(0, indexOf);
            }
        }

        return null;
    }

Usage Example

    public void ProcessAttributeFile(Project project)
    {
        var dependenciesDirectory = ProjectReader.GetDependenciesDirectory(project.FullName);

        if (dependenciesDirectory == null)
        {
            return;
        }

        var directoryInfo = fullPathResolver.GetFullPath(dependenciesDirectory, project);
        var targetFile    = new FileInfo(Path.Combine(directoryInfo.FullName, "NotifyPropertyWeaver.dll"));

        if (!targetFile.Exists)
        {
            return;
        }
        if (VersionChecker.IsVersionNewer(targetFile))
        {
            var frameworkType = FrameworkTypeReader.GetFrameworkType(project.FullName);
            fileExporter.ExportAttribute(directoryInfo, frameworkType);
        }
    }