private boolean hasPackages()

in nuget-server/src/jetbrains/buildServer/nuget/server/runner/install/PackagesInstallerRunnerDiscoverer.java [69:105]


  private boolean hasPackages(Element solutionFile) {
    InputStream stream = null;
    try {
      stream = solutionFile.getInputStream();
      final String text = StreamUtil.readText(stream);
      for (String line : text.split("\\r?\\n")) {
        final Matcher matcher = PROJECT_PATH_PATTERN.matcher(line);
        if (!matcher.find()) {
          continue;
        }

        final String projectFilePath = matcher.group(1);
        if (!PROJECT_NAME_PATTERN.matcher(projectFilePath).find()) {
          continue;
        }

        // Check packages.config file existence in the project file directory
        final String packagesPath = FileUtil.normalizeRelativePath(solutionFile.getFullName() + "/../" + projectFilePath + "/../" + PACKAGES_CONFIG);
        final Element packagesElement = solutionFile.getBrowser().getElement(packagesPath);
        if (packagesElement != null && packagesElement.isContentAvailable()) {
          return true;
        }

        // Check that project file contains PackageReferences
        final String projectPath = FileUtil.normalizeRelativePath(solutionFile.getFullName() + "/../" + projectFilePath);
        if (hasProjectReferences(solutionFile.getBrowser().getElement(projectPath))) {
          return true;
        }
      }
    } catch (IOException e) {
      LOG.infoAndDebugDetails("Failed to read solution contents " + solutionFile.getFullName(), e);
    } finally {
      FileUtil.close(stream);
    }

    return false;
  }