示例#1
0
        public string LoadGuid(string fileName)
        {
            // check if a project with specified file is already cached
            if (_cachedProjects.ContainsKey(fileName))
            {
                // return the guid of the cached project
                return(((ProjectBase)_cachedProjects[fileName]).Guid);
            }
            string projectFileName = ProjectFactory.GetProjectFileName(fileName);
            string projectExt      = Path.GetExtension(projectFileName).ToLower(
                CultureInfo.InvariantCulture);

            // holds the XML definition of the project
            XmlElement xmlDefinition;

            try {
                XmlDocument doc = LoadProjectXml(fileName);
                xmlDefinition = doc.DocumentElement;
            } catch (Exception ex) {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                       "Error loading project '{0}'.", fileName), Location.UnknownLocation,
                                         ex);
            }

            IProjectBuildProvider provider = FindProvider(projectExt, xmlDefinition);

            if (provider != null)
            {
                _cachedProjectGuids[fileName] = provider.LoadGuid(xmlDefinition);
            }

            // return project GUID from cache
            return((string)_cachedProjectGuids[fileName]);
        }
示例#2
0
        private IProjectBuildProvider FindProvider(string projectExt, XmlElement xmlDefinition)
        {
            int max = 0;
            IProjectBuildProvider res = null;

            foreach (IProjectBuildProvider provider in _projectprovs)
            {
                int pri = provider.IsSupported(projectExt, xmlDefinition);
                if (pri > max)
                {
                    max = pri;
                    res = provider;
                }
            }
            return(res);
        }
示例#3
0
        private ProjectBase CreateProject(SolutionBase solution, SolutionTask solutionTask, TempFileCollection tfc, GacCache gacCache, ReferencesResolver referencesResolver, DirectoryInfo outputDir, string projectPath)
        {
            // determine the filename of the project
            string projectFileName = ProjectFactory.GetProjectFileName(projectPath);

            // determine the extension of the project file
            string projectExt = Path.GetExtension(projectFileName).ToLower(
                CultureInfo.InvariantCulture);

            // fast-skip setup projects since the project files is not XML-based
            if (projectExt == ".vdproj")
            {
                return(null);
            }

            // holds the XML definition of the project
            XmlElement xmlDefinition;

            try {
                XmlDocument doc = LoadProjectXml(projectPath);
                xmlDefinition = doc.DocumentElement;
            } catch (Exception ex) {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                       "Error loading project '{0}'.", projectPath), Location.UnknownLocation,
                                         ex);
            }

            IProjectBuildProvider provider = FindProvider(projectExt, xmlDefinition);

            if (provider != null)
            {
                return(provider.GetInstance(solution, projectPath, xmlDefinition,
                                            solutionTask, tfc, gacCache, referencesResolver, outputDir));
            }

            // either the project file is invalid or we don't support it
            throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                   "Project '{0}' is invalid or not supported (at this time).",
                                                   projectPath), Location.UnknownLocation);
        }
示例#4
0
 public void RegisterProvider(IProjectBuildProvider provider)
 {
     _projectprovs.Add(provider);
 }
示例#5
0
 public void RegisterProvider(IProjectBuildProvider provider) {
     _projectprovs.Add(provider);
 }