in rider/src/main/kotlin/com/jetbrains/aspire/rider/sessions/executableLibrary/ExecutableLibraryExecutableFactory.kt [31:95]
suspend fun createExecutable(launchConfiguration: DotNetSessionLaunchConfiguration): DotNetExecutable? {
val sessionProjectPath = launchConfiguration.projectPath
val launchProfile = getLaunchProfile(launchConfiguration, sessionProjectPath, project)
if (launchProfile == null) {
LOG.warn("Unable to find launch profile for session project $sessionProjectPath")
return null
}
if (!launchProfile.commandName.equals(ExecutableCommand.COMMAND_NAME, true)) {
LOG.warn("Launch profile command name for library project should be `${ExecutableCommand.COMMAND_NAME}`")
return null
}
val executablePath = launchProfile.executablePath
val workingDirectory = launchProfile.workingDirectory
val arguments = launchProfile.commandLineArgs ?: ""
if (executablePath.isNullOrEmpty() || workingDirectory.isNullOrEmpty()) {
LOG.warn("Some launch profile properties are empty or null")
return null
}
val workingDirectoryAbsolutePath = if (workingDirectory.startsWith("$(")) {
workingDirectory
} else {
val workingDirectoryPath = Path(workingDirectory)
if (!workingDirectoryPath.isAbsolute) {
sessionProjectPath.parent.resolve(workingDirectoryPath.normalize()).absolutePathString()
} else {
workingDirectoryPath.absolutePathString()
}
}
val envs = mergeEnvironmentVariables(launchConfiguration.envs, launchProfile.environmentVariables)
val targetFramework = MSBuildPropertyService.getInstance(project).getProjectTargetFramework(sessionProjectPath)
val executableParams = getExecutableParams(
sessionProjectPath,
executablePath,
workingDirectoryAbsolutePath,
arguments,
envs,
targetFramework,
project
)
LOG.trace { "Executable parameters for the project (${sessionProjectPath.absolutePathString()}): $executableParams" }
return DotNetExecutable(
executableParams.executablePath ?: executablePath,
targetFramework,
executableParams.workingDirectoryPath ?: workingDirectoryAbsolutePath,
executableParams.commandLineArgumentString ?: arguments,
TerminalMode.Auto,
executableParams.environmentVariables,
true,
{ _, _, _ -> },
null,
"",
true,
DotNetCoreRuntimeType
)
}