in nuget-agent/src/jetbrains/buildServer/nuget/agent/util/impl/NuGetCommandLineProvider.kt [27:86]
fun getProgramCommandLine(context: BuildRunnerContext,
executable: String,
args: Collection<String>,
workingDir: File,
env: Map<String, String>): ProgramCommandLine {
var (executablePath, arguments) = getExecutableAndArguments(executable, args, context)
val buildLogger = context.build.buildLogger
val environment = context.buildParameters.environmentVariables.toMutableMap()
val version = myVersions.getOrPut(executable) { getNugetVersion(executable, context) }
// Since NuGet 2.0 for authentication could be used NuGet runner.
// Since NuGet 3.3 it's possible to use credential providers:
// https://docs.microsoft.com/en-us/nuget/reference/extensibility/nuget-exe-credential-providers
// Since NuGet 4.8 it's possible to use NuGet authentication plugin:
// https://github.com/NuGet/Home/wiki/NuGet-cross-plat-authentication-plugin
when {
version < NUGET_VERSION_2_0 -> {
buildLogger.warning("You use NuGet $version. Feed authentication is only supported from NuGet $NUGET_VERSION_2_0")
}
version < NUGET_VERSION_3_3 -> {
if (!mySystemInformation.isWindows) {
throw RunBuildException("Only NuGet 3.3 and higher is compatible with Mono runtime.").apply {
isLogStacktrace = false
}
}
arguments.add(0, executablePath)
executablePath = myNugetProvider.nuGetRunnerPath.path
}
else -> {
// NuGet 3.5+ does not properly work under SYSTEM account on Windows:
// https://github.com/NuGet/Home/issues/4277
if (version >= NUGET_VERSION_3_5 && mySystemInformation.isWindows &&
"SYSTEM".equals(mySystemInformation.userName, true) &&
!context.buildParameters.environmentVariables.containsKey(NUGET_PACKAGES_ENV)) {
val packagesPath = File(context.build.buildTempDirectory, ".nuget/packages")
buildLogger.message("Setting '$NUGET_PACKAGES_ENV' environment variable to '$packagesPath'")
environment[NUGET_PACKAGES_ENV] = packagesPath.path
buildLogger.message("##teamcity[setParameter name='env.$NUGET_PACKAGES_ENV' value='$packagesPath']")
}
// NuGet < 4.8 and NuGet < 4.9 on Mono does not support credentials plugin,
// so we need to remove environment variable to prevent runtime errors
if (version < NUGET_VERSION_4_8 ||
version < NUGET_VERSION_4_9 && !mySystemInformation.isWindows) {
environment.remove(NUGET_PLUGIN_PATH_ENV_VAR)
}
}
}
// Disable interactive mode for credentials requests
environment["NUGET_EXE_NO_PROMPT"] = "true"
environment.putAll(env)
return SimpleProgramCommandLine(
environment,
workingDir.path,
executablePath,
arguments
)
}