<commit_before>package jetbrains.buildServer.agent

import jetbrains.buildServer.agent.impl.OSTypeDetector
import jetbrains.buildServer.util.OSType
import jetbrains.buildServer.util.StringUtil
import java.io.File

class EnvironmentImpl(private val _fileSystemService: FileSystemService) : Environment {
    override fun tryGetVariable(name: String): String? {
        return System.getenv(name)
    }

    override val paths: Sequence<File>
        get() =
            tryGetVariable(PathEnvironmentVariableName)?.let {
                return StringUtil.splitHonorQuotes(it, File.pathSeparatorChar)
                        .asSequence()
                        .map { File(it) }
                        .filter { _fileSystemService.isExists(it) }
            } ?: emptySequence()

    override val os: OSType
        get() = OSDetector.detect() ?: OSType.UNIX

    companion object {
        private const val PathEnvironmentVariableName = "PATH"
        private val OSDetector = OSTypeDetector()
    }
}<commit_msg>Make .NET CLI more robust in finding dotnet core installation<commit_after>package jetbrains.buildServer.agent

import jetbrains.buildServer.agent.impl.OSTypeDetector
import jetbrains.buildServer.util.OSType
import jetbrains.buildServer.util.StringUtil
import java.io.File

class EnvironmentImpl(private val _fileSystemService: FileSystemService) : Environment {
    override fun tryGetVariable(name: String): String? {
        return System.getenv(name)
    }

    override val paths: Sequence<File>
        get() =
            (tryGetVariable(PathEnvironmentVariableName)?.let { path ->
                StringUtil.splitHonorQuotes(path, File.pathSeparatorChar)
                        .asSequence()
                        .map { File(it) }
                        .filter { _fileSystemService.isExists(it) }
            } ?: emptySequence()) + getHintPaths()

    override val os: OSType
        get() = OSDetector.detect() ?: OSType.UNIX

    /**
     * Provides a well known paths for tools on each platform.
     */
    private fun getHintPaths(): Sequence<File> = sequence {
        when (os) {
            OSType.MAC -> yield(File("/usr/local/share/dotnet"))
            OSType.UNIX -> yield(File("/usr/share/dotnet"))
            OSType.WINDOWS -> yield(File("C:\\Program Files\\dotnet"))
        }
    }

    companion object {
        private const val PathEnvironmentVariableName = "PATH"
        private val OSDetector = OSTypeDetector()
    }
}
{'fraction_non_alphanumeric': 0.09620048504446241, 'fraction_numerical': 0.0, 'mean_word_length': 2.5206258890469417, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4630868', 'n_tokens_mistral': 692, 'n_tokens_neox': 666, 'n_words': 146}