  public static VisualStudioProject getProject(File projectFile, String projectName, List<String> buildConfigurations)
      throws FileNotFoundException, DotNetToolsException {
    VisualStudioProject project = new VisualStudioProject();
    project.setProjectFile(projectFile);
    project.setName(projectName);
    File projectDir = projectFile.getParentFile();
    XPathFactory factory = XPathFactory.newInstance();
    XPath xpath = factory.newXPath();
    ClassLoader savedClassloader = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(xpath.getClass().getClassLoader());
    try {
      xpath.setNamespaceContext(new VisualStudioNamespaceContext());
      if (buildConfigurations != null) {
        Map<String, File> buildConfOutputDirMap = new HashMap<String, File>();
        for (String config : buildConfigurations) {
          XPathExpression configOutputExpression = xpath.compile("/vst:Project/vst:PropertyGroup[contains(@Condition,'" + config
            + "')]/vst:OutputPath");
          String configOutput = extractProjectProperty(configOutputExpression, projectFile);
          buildConfOutputDirMap.put(config, new File(projectDir, configOutput));
        }
        project.setBuildConfOutputDirMap(buildConfOutputDirMap);
      }
      XPathExpression projectTypeExpression = xpath.compile("/vst:Project/vst:PropertyGroup/vst:OutputType");
      XPathExpression assemblyNameExpression = xpath.compile("/vst:Project/vst:PropertyGroup/vst:AssemblyName");
      XPathExpression rootNamespaceExpression = xpath.compile("/vst:Project/vst:PropertyGroup/vst:RootNamespace");
      XPathExpression debugOutputExpression = xpath.compile("/vst:Project/vst:PropertyGroup[contains(@Condition,'Debug')]/vst:OutputPath");
      XPathExpression releaseOutputExpression = xpath
          .compile("/vst:Project/vst:PropertyGroup[contains(@Condition,'Release')]/vst:OutputPath");
      XPathExpression silverlightExpression = xpath.compile("/vst:Project/vst:PropertyGroup/vst:SilverlightApplication");
      XPathExpression projectGuidExpression = xpath.compile("/vst:Project/vst:PropertyGroup/vst:ProjectGuid");
      String typeStr = extractProjectProperty(projectTypeExpression, projectFile);
      String silverlightStr = extractProjectProperty(silverlightExpression, projectFile);
      String assemblyName = extractProjectProperty(assemblyNameExpression, projectFile);
      String rootNamespace = extractProjectProperty(rootNamespaceExpression, projectFile);
      String debugOutput = extractProjectProperty(debugOutputExpression, projectFile);
      String releaseOutput = extractProjectProperty(releaseOutputExpression, projectFile);
      String projectGuid = extractProjectProperty(projectGuidExpression, projectFile);
      projectGuid = projectGuid.substring(1, projectGuid.length() - 2);
      ArtifactType type = ArtifactType.LIBRARY;
      if (StringUtils.containsIgnoreCase(typeStr, "exe")) {
        type = ArtifactType.EXECUTABLE;
      }
      project.setProjectGuid(UUID.fromString(projectGuid));
      project.setProjectFile(projectFile);
      project.setType(type);
      project.setDirectory(projectDir);
      project.setAssemblyName(assemblyName);
      project.setRootNamespace(rootNamespace);
      project.setDebugOutputDir(new File(projectDir, debugOutput));
      project.setReleaseOutputDir(new File(projectDir, releaseOutput));
      if (StringUtils.isNotEmpty(silverlightStr)) {
        project.setSilverlightProject(true);
      }
      Thread.currentThread().setContextClassLoader(savedClassloader);
      Collection<SourceFile> sourceFiles = project.getSourceFiles();
      project.setAssemblyVersion(findAssemblyVersion(sourceFiles));
      assessTestProject(project, testProjectNamePattern, integTestProjectNamePattern);
      return project;
    } catch (XPathExpressionException xpee) {
      throw new DotNetToolsException("Error while processing the project " + projectFile, xpee);
    } finally {
      Thread.currentThread().setContextClassLoader(savedClassloader);
    }
  }

  public static VisualStudioProject getProject(File projectFile, String projectName, List<String> buildConfigurations)
      throws FileNotFoundException, DotNetToolsException {
    VisualStudioProject project = new VisualStudioProject();
    project.setProjectFile(projectFile);
    project.setName(projectName);
    File projectDir = projectFile.getParentFile();
    XPathFactory factory = XPathFactory.newInstance();
    XPath xpath = factory.newXPath();
    try {
      xpath.setNamespaceContext(new VisualStudioNamespaceContext());
      if (buildConfigurations != null) {
        Map<String, File> buildConfOutputDirMap = new HashMap<String, File>();
        for (String config : buildConfigurations) {
          XPathExpression configOutputExpression = xpath.compile("/vst:Project/vst:PropertyGroup[contains(@Condition,'" + config
            + "')]/vst:OutputPath");
          String configOutput = extractProjectProperty(configOutputExpression, projectFile);
          buildConfOutputDirMap.put(config, new File(projectDir, configOutput));
        }
        project.setBuildConfOutputDirMap(buildConfOutputDirMap);
      }
      XPathExpression projectTypeExpression = xpath.compile("/vst:Project/vst:PropertyGroup/vst:OutputType");
      XPathExpression assemblyNameExpression = xpath.compile("/vst:Project/vst:PropertyGroup/vst:AssemblyName");
      XPathExpression rootNamespaceExpression = xpath.compile("/vst:Project/vst:PropertyGroup/vst:RootNamespace");
      XPathExpression debugOutputExpression = xpath.compile("/vst:Project/vst:PropertyGroup[contains(@Condition,'Debug')]/vst:OutputPath");
      XPathExpression releaseOutputExpression = xpath
          .compile("/vst:Project/vst:PropertyGroup[contains(@Condition,'Release')]/vst:OutputPath");
      XPathExpression silverlightExpression = xpath.compile("/vst:Project/vst:PropertyGroup/vst:SilverlightApplication");
      XPathExpression projectGuidExpression = xpath.compile("/vst:Project/vst:PropertyGroup/vst:ProjectGuid");
      String typeStr = extractProjectProperty(projectTypeExpression, projectFile);
      String silverlightStr = extractProjectProperty(silverlightExpression, projectFile);
      String assemblyName = extractProjectProperty(assemblyNameExpression, projectFile);
      String rootNamespace = extractProjectProperty(rootNamespaceExpression, projectFile);
      String debugOutput = extractProjectProperty(debugOutputExpression, projectFile);
      String releaseOutput = extractProjectProperty(releaseOutputExpression, projectFile);
      String projectGuid = extractProjectProperty(projectGuidExpression, projectFile);
      projectGuid = projectGuid.substring(1, projectGuid.length() - 2);
      ArtifactType type = ArtifactType.LIBRARY;
      if (StringUtils.containsIgnoreCase(typeStr, "exe")) {
        type = ArtifactType.EXECUTABLE;
      }
      project.setProjectGuid(UUID.fromString(projectGuid));
      project.setProjectFile(projectFile);
      project.setType(type);
      project.setDirectory(projectDir);
      project.setAssemblyName(assemblyName);
      project.setRootNamespace(rootNamespace);
      project.setDebugOutputDir(new File(projectDir, debugOutput));
      project.setReleaseOutputDir(new File(projectDir, releaseOutput));
      if (StringUtils.isNotEmpty(silverlightStr)) {
        project.setSilverlightProject(true);
      }
      Collection<SourceFile> sourceFiles = project.getSourceFiles();
      project.setAssemblyVersion(findAssemblyVersion(sourceFiles));
      assessTestProject(project, testProjectNamePattern, integTestProjectNamePattern);
      return project;
    } catch (XPathExpressionException xpee) {
      throw new DotNetToolsException("Error while processing the project " + projectFile, xpee);
    } finally {
    }
  }
