示例#1
0
        void UpdateScripts()
        {
            SortedList <string, string> items      = new SortedList <string, string>();
            SortedList <string, string> extensions = new SortedList <string, string>(StringComparer.OrdinalIgnoreCase);

            foreach (string v in GetParameters("ScriptItems", Parameters.ScriptItems, "Content;Compile;EmbeddedResource;None"))
            {
                if (!items.ContainsKey(v))
                {
                    items.Add(v, "Item");
                }
            }

            foreach (string v in GetParameters("ScriptExtensions", Parameters.ScriptExtensions, null))
            {
                string ext = v;

                if (!ext.StartsWith("."))
                {
                    ext = '.' + ext;
                }

                if (!extensions.ContainsKey(ext))
                {
                    extensions.Add(ext, "Item");
                }
            }

            foreach (ProjectItem i in BuildItems)
            {
                string name;
                if (!items.TryGetValue(i.Name, out name))
                {
                    continue;
                }

                string extension = Path.GetExtension(i.Include);

                if (!extensions.ContainsKey(extension))
                {
                    continue;
                }

                ScriptFiles.AddUnique(i.Include);
            }
        }
示例#2
0
        private void FindContentAndScripts(XPathDocument doc)
        {
            SortedList <string, string> extensions = new SortedList <string, string>(StringComparer.OrdinalIgnoreCase);

            if (Parameters.ScriptExtensions != null)
            {
                foreach (string extension in Parameters.ScriptExtensions)
                {
                    string ext = extension;

                    if (!ext.StartsWith("."))
                    {
                        ext = '.' + ext;
                    }

                    if (!extensions.ContainsKey(ext))
                    {
                        extensions.Add(ext, "Item");
                    }
                }
            }

            foreach (XPathNavigator nav in doc.CreateNavigator().Select("//File[@RelativePath]"))
            {
                string file = nav.GetAttribute("RelativePath", "");
                bool   deploymentContent = ("true" == nav.GetAttribute("DeploymentContent", ""));

                if (deploymentContent)
                {
                    ContentFiles.AddUnique(file);
                }

                if (extensions.ContainsKey(Path.GetExtension(file)))
                {
                    ScriptFiles.AddUnique(file);
                }
            }
        }