public int IsSupported(string projectExt, XmlElement xmlDefinition)
 {
     if (projectExt == ".vjsproj")
     {
         return(5);
     }
     if (JSharpProject.IsSupported(xmlDefinition))
     {
         return(10);
     }
     return(0);
 }
 public string LoadGuid(XmlElement xmlDefinition)
 {
     return(JSharpProject.LoadGuid(xmlDefinition));
 }
Example #3
0
        private static 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);

            // 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);
            }

            // first identify project based on known file extensions
            switch (projectExt)
            {
            case ".vbproj":
                return(new VBProject(solution, projectPath, xmlDefinition,
                                     solutionTask, tfc, gacCache, referencesResolver,
                                     outputDir));

            case ".csproj":
                return(new CSharpProject(solution, projectPath, xmlDefinition,
                                         solutionTask, tfc, gacCache, referencesResolver,
                                         outputDir));

            case ".vjsproj":
                return(new JSharpProject(solution, projectPath, xmlDefinition,
                                         solutionTask, tfc, gacCache, referencesResolver,
                                         outputDir));

            case ".vcproj":
                return(new VcProject(solution, projectPath, xmlDefinition,
                                     solutionTask, tfc, gacCache, referencesResolver,
                                     outputDir));
            }

            // next, identify project based on XML definition
            if (VBProject.IsSupported(xmlDefinition))
            {
                return(new VBProject(solution, projectPath, xmlDefinition,
                                     solutionTask, tfc, gacCache, referencesResolver, outputDir));
            }
            else if (CSharpProject.IsSupported(xmlDefinition))
            {
                return(new CSharpProject(solution, projectPath, xmlDefinition,
                                         solutionTask, tfc, gacCache, referencesResolver, outputDir));
            }
            else if (JSharpProject.IsSupported(xmlDefinition))
            {
                return(new JSharpProject(solution, projectPath, xmlDefinition,
                                         solutionTask, tfc, gacCache, referencesResolver, outputDir));
            }
            else if (VcProject.IsSupported(xmlDefinition))
            {
                return(new VcProject(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);
        }