Exemple #1
0
        public string GetEvaluatedMetadata(string metadataName)
        {
            if (ReservedNameUtils.IsReservedMetadataName(metadataName))
            {
                string metadata = ReservedNameUtils.GetReservedMetadata(FinalItemSpec, metadataName, evaluatedMetadata);
                return(string.Equals(metadataName, "fullpath", StringComparison.OrdinalIgnoreCase)
                                                ? MSBuildUtils.Escape(metadata)
                                                : metadata);
            }

            if (evaluatedMetadata.Contains(metadataName))
            {
                return((string)evaluatedMetadata [metadataName]);
            }
            else
            {
                return(String.Empty);
            }
        }
Exemple #2
0
        void AddMetadata(string name, string value)
        {
            var options = IsDynamic ?
                          ParseOptions.AllowItemsMetadataAndSplit : ParseOptions.AllowItemsNoMetadataAndSplit;

            if (parent_item_group != null)
            {
                Expression e = new Expression();
                e.Parse(value, options);
                evaluatedMetadata [name] = (string)e.ConvertTo(parent_item_group.ParentProject,
                                                               typeof(string), ExpressionOptions.ExpandItemRefs);
            }
            else
            {
                evaluatedMetadata [name] = MSBuildUtils.Unescape(value);
            }

            unevaluatedMetadata [name] = value;
        }
Exemple #3
0
        public TaskItem(ITaskItem sourceItem)
        {
            if (sourceItem == null)
            {
                throw new ArgumentNullException("sourceItem");
            }

            var ti2 = sourceItem as ITaskItem2;

            if (ti2 != null)
            {
                escapedItemSpec = ti2.EvaluatedIncludeEscaped;
                escapedMetadata = ti2.CloneCustomMetadataEscaped();
            }
            else
            {
                escapedItemSpec = MSBuildUtils.Escape(sourceItem.ItemSpec);
                escapedMetadata = sourceItem.CloneCustomMetadata();
                foreach (string key in new ArrayList(escapedMetadata.Keys))
                {
                    escapedMetadata [key] = MSBuildUtils.Escape((string)escapedMetadata [key]);
                }
            }
        }
        //@base_path must be absolute
        Framework GetFrameworkDirectoriesForMoniker(FrameworkMoniker moniker, string base_path)
        {
            if (String.IsNullOrEmpty(base_path))
            {
                Log.LogMessage(MessageImportance.Low, "Invalid *empty* base path, ignoring. " + Environment.StackTrace);
                return(null);
            }

            Log.LogMessage(MessageImportance.Low, "Looking for framework '{0}' in root path '{1}'",
                           moniker, base_path);
            string framework_path = Path.Combine(base_path, Path.Combine(moniker.Identifier, moniker.Version));

            if (!String.IsNullOrEmpty(moniker.Profile))
            {
                framework_path = Path.Combine(framework_path, "Profile", moniker.Profile);
            }

            string redistlist_dir = Path.Combine(framework_path, "RedistList");
            string framework_list = Path.Combine(redistlist_dir, "FrameworkList.xml");

            if (!File.Exists(framework_list))
            {
                Log.LogMessage(MessageImportance.Low,
                               "Unable to find framework definition file '{0}' for Target Framework Moniker '{1}'",
                               framework_list, moniker);
                return(null);
            }

            Log.LogMessage(MessageImportance.Low, "Found framework definition list '{0}' for framework '{1}'",
                           framework_list, moniker);
            XmlReader xr = XmlReader.Create(framework_list);

            try {
                xr.MoveToContent();
                if (xr.LocalName != "FileList")
                {
                    Log.LogMessage(MessageImportance.Low, "Invalid frameworklist '{0}', expected a 'FileList' root element.",
                                   framework_list);
                    return(null);
                }

                var framework = new Framework();
                framework.DisplayName = xr.GetAttribute("Name");
                string framework_dir = xr.GetAttribute("TargetFrameworkDirectory");
                if (String.IsNullOrEmpty(framework_dir))
                {
                    framework_dir = Path.Combine(redistlist_dir, "..");
                }
                else
                {
                    framework_dir = Path.Combine(redistlist_dir, framework_dir);
                }

                var directories = new List <string> ();
                directories.Add(MSBuildUtils.FromMSBuildPath(framework_dir));

                string include = xr.GetAttribute("IncludeFramework");
                if (!String.IsNullOrEmpty(include))
                {
                    var included_framework = GetFrameworkDirectoriesForMoniker(new FrameworkMoniker(moniker.Identifier, include, null));

                    if (included_framework != null && included_framework.Directories != null)
                    {
                        directories.AddRange(included_framework.Directories);
                    }
                }

                framework.Directories = directories.ToArray();

                return(framework);
            } catch (XmlException xe) {
                Log.LogWarning("Error reading framework definition file '{0}': {1}", framework_list, xe.Message);
                Log.LogMessage(MessageImportance.Low, "Error reading framework definition file '{0}': {1}", framework_list,
                               xe.ToString());
                return(null);
            } finally {
                if (xr != null)
                {
                    ((IDisposable)xr).Dispose();
                }
            }
        }
Exemple #5
0
        // true if the resx file or any file referenced
        // by the resx is newer than the .resources file
        //
        // Code taken from monodevelop
        // main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MD1/MD1DotNetProjectHandler.cs
        bool IsResgenRequired(string resx_filename, string resources_filename)
        {
            if (IsFileNewerThan(resx_filename, resources_filename))
            {
                Log.LogMessage(MessageImportance.Low,
                               "Resource file '{0}' is newer than the source file '{1}', skipping.",
                               resources_filename, resx_filename);
                return(true);
            }

            if (String.Compare(Path.GetExtension(resx_filename), ".resx", true) != 0)
            {
                return(true);
            }

            // resx file, check for files referenced from there
            XmlTextReader xr = null;

            try {
                // look for
                // <data type="System.Resources.ResXFileRef, System.Windows.Forms" ..>
                //   <value>... filename;.. </value>
                // </data>
                xr = new XmlTextReader(resx_filename);
                string basepath = Path.GetDirectoryName(resx_filename);
                while (xr.Read())
                {
                    if (xr.NodeType != XmlNodeType.Element ||
                        String.Compare(xr.LocalName, "data") != 0)
                    {
                        continue;
                    }

                    string type = xr.GetAttribute("type");
                    if (String.IsNullOrEmpty(type))
                    {
                        continue;
                    }

                    if (String.Compare(type, "System.Resources.ResXFileRef, System.Windows.Forms") != 0)
                    {
                        continue;
                    }

                    xr.ReadToDescendant("value");
                    if (xr.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }

                    string value = xr.ReadElementContentAsString();

                    string [] parts = value.Split(';');
                    if (parts.Length > 0)
                    {
                        string referenced_filename = MSBuildUtils.FromMSBuildPath(
                            Path.Combine(basepath, parts [0]).Trim());
                        if (File.Exists(referenced_filename) &&
                            IsFileNewerThan(referenced_filename, resources_filename))
                        {
                            return(true);
                        }
                    }
                }
            } catch (XmlException) {
                // Ignore xml errors, let resgen handle it
                return(true);
            } finally {
                if (xr != null)
                {
                    xr.Close();
                }
            }

            return(false);
        }
Exemple #6
0
 internal static string FromMSBuildPath(string relPath)
 {
     return(MSBuildUtils.FromMSBuildPath(relPath));
 }
Exemple #7
0
 public static string Escape(string unescapedExpression)
 {
     return(MSBuildUtils.Escape(unescapedExpression));
 }
Exemple #8
0
        // Split: Split on ';'
        //	   Eg. Property values don't need to be split
        //
        // AllowItems: if false, item refs should not be treated as item refs!
        //	        it converts them to strings in the final expressionCollection
        //
        // AllowMetadata: same as AllowItems, for metadata
        public void Parse(string expression, ParseOptions options)
        {
            bool split      = (options & ParseOptions.Split) == ParseOptions.Split;
            bool allowItems = (options & ParseOptions.AllowItems) == ParseOptions.AllowItems;
            bool allowMd    = (options & ParseOptions.AllowMetadata) == ParseOptions.AllowMetadata;

            expression = expression.Replace('\\', Path.DirectorySeparatorChar);

            string [] parts;
            if (split)
            {
                parts = expression.Split(new char [] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            }
            else
            {
                parts = new string [] { expression }
            };

            // TODO: Too complicated, each part parses only its known part
            // we should simply do it in one go and avoid all this parts code madness

            List <ArrayList> p1 = new List <ArrayList> (parts.Length);
            List <ArrayList> p2 = new List <ArrayList> (parts.Length);
            List <ArrayList> p3 = new List <ArrayList> (parts.Length);

            Prepare(p1, parts.Length);
            Prepare(p2, parts.Length);
            Prepare(p3, parts.Length);

            for (int i = 0; i < parts.Length; i++)
            {
                p1 [i] = SplitItems(parts [i], allowItems);
            }

            for (int i = 0; i < parts.Length; i++)
            {
                p2 [i] = new ArrayList();
                foreach (object o in p1[i])
                {
                    if (o is string)
                    {
                        p2 [i].AddRange(ExtractProperties((string)o));
                    }
                    else
                    {
                        p2 [i].Add(o);
                    }
                }
            }

            for (int i = 0; i < parts.Length; i++)
            {
                p3 [i] = new ArrayList();
                foreach (object o in p2[i])
                {
                    if (o is string)
                    {
                        p3 [i].AddRange(SplitMetadata((string)o));
                    }
                    else
                    {
                        p3 [i].Add(o);
                    }
                }
            }

            CopyToExpressionCollection(p3, allowItems, allowMd);
        }

        void Prepare(List <ArrayList> l, int length)
        {
            for (int i = 0; i < length; i++)
            {
                l.Add(null);
            }
        }

        void CopyToExpressionCollection(List <ArrayList> lists, bool allowItems, bool allowMd)
        {
            for (int i = 0; i < lists.Count; i++)
            {
                foreach (object o in lists[i])
                {
                    if (o is string)
                    {
                        expressionCollection.Add(MSBuildUtils.Unescape((string)o));
                    }
                    else if (!allowItems && o is ItemReference)
                    {
                        expressionCollection.Add(((ItemReference)o).OriginalString);
                    }
                    else if (!allowMd && o is MetadataReference)
                    {
                        expressionCollection.Add(((MetadataReference)o).OriginalString);
                    }
                    else if (o is IReference)
                    {
                        expressionCollection.Add((IReference)o);
                    }
                }
                if (i < lists.Count - 1)
                {
                    expressionCollection.Add(";");
                }
            }
        }

        ArrayList SplitItems(string text, bool allowItems)
        {
            ArrayList phase1 = new ArrayList();
            Match     m;

            m = ItemRegex.Match(text);

            while (m.Success)
            {
                string        name = null, transform = null, separator = null;
                ItemReference ir;

                name = m.Groups [ItemRegex.GroupNumberFromName("itemname")].Value;

                if (m.Groups [ItemRegex.GroupNumberFromName("has_transform")].Success)
                {
                    transform = m.Groups [ItemRegex.GroupNumberFromName("transform")].Value;
                }

                if (m.Groups [ItemRegex.GroupNumberFromName("has_separator")].Success)
                {
                    separator = m.Groups [ItemRegex.GroupNumberFromName("separator")].Value;
                }

                ir = new ItemReference(text.Substring(m.Groups [0].Index, m.Groups [0].Length),
                                       name, transform, separator, m.Groups [0].Index, m.Groups [0].Length);
                phase1.Add(ir);
                m = m.NextMatch();
            }

            ArrayList phase2   = new ArrayList();
            int       last_end = -1;
            int       end      = text.Length - 1;

            foreach (ItemReference ir in phase1)
            {
                int a, b;

                a = last_end;
                b = ir.Start;

                if (b - a - 1 > 0)
                {
                    phase2.Add(text.Substring(a + 1, b - a - 1));
                }

                last_end = ir.End;
                phase2.Add(ir);
            }

            if (last_end < end)
            {
                phase2.Add(text.Substring(last_end + 1, end - last_end));
            }

            return(phase2);
        }
Exemple #9
0
        internal void Evaluate(Project project, bool evaluatedTo)
        {
            // FIXME: maybe make Expression.ConvertTo (null, ...) work as MSBuildUtils.Unescape ()?
            if (project == null)
            {
                this.finalItemSpec = MSBuildUtils.Unescape(Include);
                return;
            }

            foreach (XmlNode xn in itemElement.ChildNodes)
            {
                XmlElement xe = xn as XmlElement;
                if (xe != null && ConditionParser.ParseAndEvaluate(xe.GetAttribute("Condition"), project))
                {
                    AddMetadata(xe.Name, xe.InnerText);
                }
            }

            if (IsDynamic)
            {
                if (!evaluatedTo)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(Remove))
                {
                    RemoveItems(project);
                    return;
                }

                if (string.IsNullOrEmpty(Include))
                {
                    UpdateMetadata(project);
                    return;
                }
            }

            DirectoryScanner directoryScanner;
            Expression       includeExpr, excludeExpr;

            ITaskItem[] includes, excludes;

            var options = IsDynamic ?
                          ParseOptions.AllowItemsMetadataAndSplit : ParseOptions.AllowItemsNoMetadataAndSplit;

            includeExpr = new Expression();
            includeExpr.Parse(Include, options);
            excludeExpr = new Expression();
            excludeExpr.Parse(Exclude, options);

            includes = (ITaskItem[])includeExpr.ConvertTo(project, typeof(ITaskItem[]),
                                                          ExpressionOptions.ExpandItemRefs);
            excludes = (ITaskItem[])excludeExpr.ConvertTo(project, typeof(ITaskItem[]),
                                                          ExpressionOptions.ExpandItemRefs);

            this.finalItemSpec = (string)includeExpr.ConvertTo(project, typeof(string),
                                                               ExpressionOptions.ExpandItemRefs);

            directoryScanner = new DirectoryScanner();

            directoryScanner.Includes = includes;
            directoryScanner.Excludes = excludes;

            if (project.FullFileName != String.Empty)
            {
                directoryScanner.ProjectFile   = project.ThisFileFullPath;
                directoryScanner.BaseDirectory = new DirectoryInfo(Path.GetDirectoryName(project.FullFileName));
            }
            else
            {
                directoryScanner.BaseDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
            }

            directoryScanner.Scan();

            foreach (ITaskItem matchedItem in directoryScanner.MatchedItems)
            {
                AddEvaluatedItem(project, evaluatedTo, matchedItem);
            }
        }
Exemple #10
0
 void ITaskItem2.SetMetadataValueLiteral(string metadataName, string metadataValue)
 {
     SetMetadata(metadataName, MSBuildUtils.Escape(metadataValue));
 }
Exemple #11
0
 public string GetMetadata(string metadataName)
 {
     return(MSBuildUtils.Unescape(GetMetadataValue(metadataName)));
 }
Exemple #12
0
 public static string Unescape(string escaped)
 {
     return(MSBuildUtils.Unescape(escaped));
 }
Exemple #13
0
 public static string Escape(string unescaped)
 {
     return(MSBuildUtils.Escape(unescaped));
 }
Exemple #14
0
        // Split: Split on ';'
        //	   Eg. Property values don't need to be split
        //
        // AllowItems: if false, item refs should not be treated as item refs!
        //	        it converts them to strings in the final expressionCollection
        //
        // AllowMetadata: same as AllowItems, for metadata
        public void Parse(string expression, ParseOptions options)
        {
            bool split      = (options & ParseOptions.Split) == ParseOptions.Split;
            bool allowItems = (options & ParseOptions.AllowItems) == ParseOptions.AllowItems;
            bool allowMd    = (options & ParseOptions.AllowMetadata) == ParseOptions.AllowMetadata;

            expression = expression.Replace('\\', Path.DirectorySeparatorChar);

            string [] parts;
            if (split)
            {
                parts = expression.Split(new char [] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            }
            else
            {
                parts = new string [] { expression }
            };

            List <ArrayList> p1 = new List <ArrayList> (parts.Length);
            List <ArrayList> p2 = new List <ArrayList> (parts.Length);
            List <ArrayList> p3 = new List <ArrayList> (parts.Length);

            Prepare(p1, parts.Length);
            Prepare(p2, parts.Length);
            Prepare(p3, parts.Length);

            for (int i = 0; i < parts.Length; i++)
            {
                p1 [i] = SplitItems(parts [i], allowItems);
            }

            for (int i = 0; i < parts.Length; i++)
            {
                p2 [i] = new ArrayList();
                foreach (object o in p1[i])
                {
                    if (o is string)
                    {
                        p2 [i].AddRange(SplitProperties((string)o));
                    }
                    else
                    {
                        p2 [i].Add(o);
                    }
                }
            }

            for (int i = 0; i < parts.Length; i++)
            {
                p3 [i] = new ArrayList();
                foreach (object o in p2[i])
                {
                    if (o is string)
                    {
                        p3 [i].AddRange(SplitMetadata((string)o));
                    }
                    else
                    {
                        p3 [i].Add(o);
                    }
                }
            }

            CopyToExpressionCollection(p3, allowItems, allowMd);
        }

        void Prepare(List <ArrayList> l, int length)
        {
            for (int i = 0; i < length; i++)
            {
                l.Add(null);
            }
        }

        void CopyToExpressionCollection(List <ArrayList> lists, bool allowItems, bool allowMd)
        {
            for (int i = 0; i < lists.Count; i++)
            {
                foreach (object o in lists[i])
                {
                    if (o is string)
                    {
                        expressionCollection.Add(MSBuildUtils.Unescape((string)o));
                    }
                    else if (!allowItems && o is ItemReference)
                    {
                        expressionCollection.Add(((ItemReference)o).OriginalString);
                    }
                    else if (!allowMd && o is MetadataReference)
                    {
                        expressionCollection.Add(((MetadataReference)o).OriginalString);
                    }
                    else if (o is IReference)
                    {
                        expressionCollection.Add((IReference)o);
                    }
                }
                if (i < lists.Count - 1)
                {
                    expressionCollection.Add(";");
                }
            }
        }

        ArrayList SplitItems(string text, bool allowItems)
        {
            ArrayList phase1 = new ArrayList();
            Match     m;

            m = ItemRegex.Match(text);

            while (m.Success)
            {
                string        name = null, transform = null, separator = null;
                ItemReference ir;

                name = m.Groups [ItemRegex.GroupNumberFromName("itemname")].Value;

                if (m.Groups [ItemRegex.GroupNumberFromName("has_transform")].Success)
                {
                    transform = m.Groups [ItemRegex.GroupNumberFromName("transform")].Value;
                }

                if (m.Groups [ItemRegex.GroupNumberFromName("has_separator")].Success)
                {
                    separator = m.Groups [ItemRegex.GroupNumberFromName("separator")].Value;
                }

                ir = new ItemReference(text.Substring(m.Groups [0].Index, m.Groups [0].Length),
                                       name, transform, separator, m.Groups [0].Index, m.Groups [0].Length);
                phase1.Add(ir);
                m = m.NextMatch();
            }

            ArrayList phase2   = new ArrayList();
            int       last_end = -1;
            int       end      = text.Length - 1;

            foreach (ItemReference ir in phase1)
            {
                int a, b;

                a = last_end;
                b = ir.Start;

                if (b - a - 1 > 0)
                {
                    phase2.Add(text.Substring(a + 1, b - a - 1));
                }

                last_end = ir.End;
                phase2.Add(ir);
            }

            if (last_end < end)
            {
                phase2.Add(text.Substring(last_end + 1, end - last_end));
            }

            return(phase2);
        }

        ArrayList SplitProperties(string text)
        {
            ArrayList phase1 = new ArrayList();
            Match     m;

            m = PropertyRegex.Match(text);

            while (m.Success)
            {
                PropertyReference pr;
                Group             rg = m.Groups["is_registry"];

                if (rg.Success)
                {
                    string key   = m.Groups["key"].Value;
                    string value = "";

                    if (m.Groups["has_value"].Success)
                    {
                        value = m.Groups["value"].Value;
                    }

                    pr = new PropertyReference(rg.Value, rg.Index, rg.Length, key, value);
                }
                else
                {
                    string name = m.Groups[PropertyRegex.GroupNumberFromName("name")].Value;
                    pr = new PropertyReference(name, m.Groups[0].Index, m.Groups[0].Length);
                }

                phase1.Add(pr);
                m = m.NextMatch();
            }

            ArrayList phase2   = new ArrayList();
            int       last_end = -1;
            int       end      = text.Length - 1;

            foreach (PropertyReference pr in phase1)
            {
                int a, b;

                a = last_end;
                b = pr.Start;

                if (b - a - 1 > 0)
                {
                    phase2.Add(text.Substring(a + 1, b - a - 1));
                }

                last_end = pr.End;
                phase2.Add(pr);
            }

            if (last_end < end)
            {
                phase2.Add(text.Substring(last_end + 1, end - last_end));
            }

            return(phase2);
        }

        ArrayList SplitMetadata(string text)
        {
            ArrayList phase1 = new ArrayList();
            Match     m;

            m = MetadataRegex.Match(text);

            while (m.Success)
            {
                string            name = null, meta = null;
                MetadataReference mr;

                if (m.Groups [MetadataRegex.GroupNumberFromName("name")].Success)
                {
                    name = m.Groups [MetadataRegex.GroupNumberFromName("name")].Value;
                }

                meta = m.Groups [MetadataRegex.GroupNumberFromName("meta")].Value;

                mr = new MetadataReference(text.Substring(m.Groups [0].Index, m.Groups [0].Length),
                                           name, meta, m.Groups [0].Index, m.Groups [0].Length);
                phase1.Add(mr);
                m = m.NextMatch();
            }

            ArrayList phase2   = new ArrayList();
            int       last_end = -1;
            int       end      = text.Length - 1;

            foreach (MetadataReference mr in phase1)
            {
                int a, b;

                a = last_end;
                b = mr.Start;

                if (b - a - 1 > 0)
                {
                    phase2.Add(text.Substring(a + 1, b - a - 1));
                }

                last_end = mr.End;
                phase2.Add(mr);
            }

            if (last_end < end)
            {
                phase2.Add(text.Substring(last_end + 1, end - last_end));
            }

            return(phase2);
        }
        private static void DigestBuildItems(Project project, ProjectDigest projectDigest, string projectBasePath, ICollection <ProjectReference> projectReferences, ICollection <Reference> references, ICollection <Compile> compiles, ICollection <None> nones, ICollection <WebReferenceUrl> webReferenceUrls, ICollection <Content> contents, ICollection <Folder> folders, ICollection <WebReferences> webReferencesList, ICollection <EmbeddedResource> embeddedResources, ICollection <BootstrapperPackage> bootstrapperPackages, ICollection <string> globalNamespaceImports, IList <ComReference> comReferenceList)
        {
            string targetFramework = projectDigest.TargetFramework != null?projectDigest.TargetFramework.Substring(0, 3) : "2.0";

            RspUtility rsp = new RspUtility();

            foreach (BuildItemGroup buildItemGroup in project.ItemGroups)
            {
                foreach (BuildItem buildItem in buildItemGroup)
                {
                    if (!buildItem.IsImported)
                    {
                        switch (buildItem.Name)
                        {
                        case "ProjectReference":
                            ProjectReference prjRef = new ProjectReference(projectBasePath);
                            prjRef.ProjectPath = buildItem.Include;
                            prjRef.Name        = GetProjectAssemblyName(Path.GetFullPath(prjRef.ProjectFullPath));
                            prjRef.RoleType    = buildItem.GetMetadata("RoleType");
                            projectReferences.Add(prjRef);
                            break;

                        case "Reference":
                            // TODO: significant refactoring needed here - it should be calling the same resolution code that is in
                            //   AbstractPomConverter to find the right artifact based on the simple name

                            Reference reference = new Reference(projectBasePath);
                            //set processorArchitecture property to platform, it will be used by GacUtility in
                            // order to resolve artifact to right processor architecture
                            if (!string.IsNullOrEmpty(projectDigest.Platform))
                            {
                                reference.ProcessorArchitecture = projectDigest.Platform;
                            }
                            string hintPath = buildItem.GetMetadata("HintPath");
                            if (!string.IsNullOrEmpty(hintPath))
                            {
                                string fullHint = Path.Combine(projectBasePath, hintPath);
                                if (File.Exists(fullHint))
                                {
                                    reference.HintPath = Path.GetFullPath(fullHint);
                                }
                                else
                                {
                                    reference.HintPath = fullHint;
                                }
                                SetReferenceFromFile(new FileInfo(fullHint), reference);
                            }
                            if ((string.IsNullOrEmpty(reference.HintPath) || !(new FileInfo(reference.HintPath).Exists)) && !rsp.IsRspIncluded(buildItem.Include, projectDigest.Language))
                            {
                                if (buildItem.Include.Contains(","))
                                {
                                    // complete name
                                    reference.SetAssemblyInfoValues(buildItem.Include);
                                }
                                else if (projectDigest.DependencySearchConfig.SearchGac && projectDigest.TargetFrameworkIdentifier != "Silverlight")
                                {
                                    // simple name needs to be resolved
                                    List <string> refs = GacUtility.GetInstance().GetAssemblyInfo(buildItem.Include, null, null);
                                    if (refs.Count == 0)
                                    {
                                        log.Warn("Unable to find reference '" + buildItem.Include + "' in " + string.Join("; ", refs.ToArray()));
                                    }
                                    else if (refs.Count > 1)
                                    {
                                        string best          = null;
                                        string bestFramework = "0.0";
                                        foreach (string s in refs)
                                        {
                                            try
                                            {
                                                Assembly a         = Assembly.ReflectionOnlyLoad(s);
                                                string   framework = a.ImageRuntimeVersion.Substring(1, 3);
                                                if (framework.CompareTo(targetFramework) <= 0 && framework.CompareTo(bestFramework) > 0)
                                                {
                                                    best          = s;
                                                    bestFramework = framework;
                                                }
                                            }
                                            catch (Exception e)
                                            {
                                                // skip this assembly
                                                log.Error("An error occurred loading assembly '" + s + "' - check that your PATH to gacutil matches your runtime environment: " + e.Message);
                                            }
                                        }
                                        reference.SetAssemblyInfoValues(best);
                                    }
                                    else
                                    {
                                        reference.SetAssemblyInfoValues(refs[0]);
                                    }
                                }
                                else
                                {
                                    reference.Name = buildItem.Include;
                                }
                            }
                            if ("NUnit.Framework".Equals(reference.Name, StringComparison.OrdinalIgnoreCase))
                            {
                                reference.Name         = "NUnit.Framework";
                                projectDigest.UnitTest = true;
                            }
                            if (!string.IsNullOrEmpty(reference.Name))
                            {
                                references.Add(reference);
                            }
                            break;

                        case "Compile":
                            Compile compile = new Compile(projectBasePath);
                            compile.IncludePath           = buildItem.Include;
                            compile.AutoGen               = buildItem.GetMetadata("AutoGen");
                            compile.DesignTimeSharedInput = buildItem.GetMetadata("DesignTimeSharedInput");
                            compile.DependentUpon         = buildItem.GetMetadata("DependentUpon");
                            compile.DesignTime            = buildItem.GetMetadata("DesignTime");
                            compile.SubType               = buildItem.GetMetadata("SubType");
                            compiles.Add(compile);
                            break;

                        case "None":
                            None none = new None(projectBasePath);
                            none.IncludePath = buildItem.Include;

                            none.Link = buildItem.GetMetadata("Link");

                            none.Generator     = buildItem.GetMetadata("Generator");
                            none.LastGenOutput = buildItem.GetMetadata("LastGenOutput");
                            none.DependentUpon = buildItem.GetMetadata("DependentUpon");

                            nones.Add(none);

                            //add included web reference when reimporting
                            if (buildItem.Include.Contains(".wsdl"))
                            {
                                string path = Path.GetDirectoryName(buildItem.Include) + "\\";

                                WebReferenceUrl webUrl = new WebReferenceUrl();
                                webUrl.UrlBehavior = "Dynamic";
                                webUrl.RelPath     = path;

                                if (!webRefExists(webUrl, webReferenceUrls))
                                {
                                    webReferenceUrls.Add(webUrl);
                                }
                            }
                            break;

                        case "WebReferenceUrl":
                            WebReferenceUrl web = new WebReferenceUrl();
                            web.UrlBehavior                 = buildItem.GetMetadata("UrlBehavior");
                            web.RelPath                     = buildItem.GetMetadata("RelPath");
                            web.UpdateFromURL               = buildItem.GetMetadata("UpdateFromURL");
                            web.ServiceLocationURL          = buildItem.GetMetadata("ServiceLocationURL");
                            web.CachedDynamicPropName       = buildItem.GetMetadata("CachedDynamicPropName");
                            web.CachedAppSettingsObjectName = buildItem.GetMetadata("CachedAppSettingsObjectName");
                            web.CachedSettingsPropName      = buildItem.GetMetadata("CachedSettingsPropName");

                            if (!webRefExists(web, webReferenceUrls))
                            {
                                webReferenceUrls.Add(web);
                            }
                            break;

                        case "COMReference":
                            ComReference comRef = new ComReference();
                            comRef.Include      = buildItem.Include;
                            comRef.Guid         = buildItem.GetMetadata("Guid");
                            comRef.VersionMajor = buildItem.GetMetadata("VersionMajor");
                            comRef.VersionMinor = buildItem.GetMetadata("VersionMinor");
                            comRef.Lcid         = buildItem.GetMetadata("Lcid");
                            comRef.Isolated     = buildItem.GetMetadata("Isolated");
                            comRef.WrapperTool  = buildItem.GetMetadata("WrapperTool");
                            comReferenceList.Add(comRef);
                            break;

                        case "Content":
                            Content content = new Content(projectBasePath);
                            content.IncludePath = buildItem.Include;
                            contents.Add(content);

                            //add web reference in <includes> tag of compile-plugin
                            if (content.IncludePath.Contains("Web References"))
                            {
                                Compile compileWebRef = new Compile(projectBasePath);
                                compileWebRef.IncludePath = buildItem.Include;
                                compiles.Add(compileWebRef);
                            }
                            break;

                        case "Folder":
                            Folder folder = new Folder(projectBasePath);
                            folder.IncludePath = buildItem.Include;
                            folders.Add(folder);
                            break;

                        case "WebReferences":
                            WebReferences webReferences = new WebReferences(projectBasePath);
                            webReferences.IncludePath = buildItem.Include;
                            webReferencesList.Add(webReferences);
                            break;

                        case "EmbeddedResource":
                            EmbeddedResource embeddedResource = new EmbeddedResource(projectBasePath);
                            embeddedResource.IncludePath = buildItem.Include;

                            embeddedResource.DependentUpon = buildItem.GetMetadata("DependentUpon");
                            embeddedResource.SubType       = buildItem.GetMetadata("SubType");
                            embeddedResource.Generator     = buildItem.GetMetadata("Generator");
                            embeddedResource.LastGenOutput = buildItem.GetMetadata("LastGenOutput");
                            embeddedResource.WithCulture   = buildItem.GetMetadata("WithCulture");
                            if (string.IsNullOrEmpty(embeddedResource.WithCulture))
                            {
                                embeddedResource.WithCulture = MSBuildUtils.DetermineResourceCulture(buildItem.Include);
                            }

                            embeddedResources.Add(embeddedResource);
                            break;

                        case "BootstrapperPackage":
                            BootstrapperPackage bootstrapperPackage = new BootstrapperPackage(projectBasePath);
                            bootstrapperPackage.IncludePath = buildItem.Include;
                            bootstrapperPackage.Visible     = buildItem.GetMetadata("Visible");
                            bootstrapperPackage.ProductName = buildItem.GetMetadata("ProductName");
                            bootstrapperPackage.Install     = buildItem.GetMetadata("Install");


                            bootstrapperPackages.Add(bootstrapperPackage);
                            break;

                        case "Import":
                            globalNamespaceImports.Add(buildItem.Include);
                            break;

                        case "BaseApplicationManifest":
                            projectDigest.BaseApplicationManifest = buildItem.Include;
                            break;

                        default:
                            log.Debug("Unhandled ItemGroup: " + buildItem.Name);
                            break;
                        }
                    }
                }
            }
        }