in rider/src/main/kotlin/com/jetbrains/aspire/rider/run/host/AspireHostExecutorFactory.kt [42:75]
override suspend fun create(
executorId: String,
environment: ExecutionEnvironment,
lifetime: Lifetime
): RunProfileState {
val activeRuntime = RiderDotNetActiveRuntimeHost.getInstance(project).dotNetCoreRuntime.value
?: throw CantRunException("Unable to find appropriate dotnet runtime")
val projects = project.solution.runnableProjectsModel.projects.valueOrNull
?: throw CantRunException(DotNetProjectConfigurationParameters.SOLUTION_IS_LOADING)
val runnableProject = projects.singleOrNull {
it.kind == AspireRunnableProjectKinds.AspireHost && it.projectFilePath == parameters.projectFilePath
} ?: throw CantRunException(DotNetProjectConfigurationParameters.PROJECT_NOT_SPECIFIED)
val projectOutput = runnableProject
.projectOutputs
.singleOrNull { it.tfm?.presentableName == parameters.projectTfm }
?: runnableProject.projectOutputs.firstOrNull()
?: throw CantRunException("Unable to get the project output for ${parameters.projectTfm}")
val profile = LaunchSettingsJsonService
.getInstance(project)
.getProjectLaunchProfileByName(runnableProject, parameters.profileName)
?: throw CantRunException("Profile ${parameters.profileName} not found")
val executable = getDotNetExecutable(runnableProject, projectOutput, profile, activeRuntime)
return when (executorId) {
DefaultRunExecutor.EXECUTOR_ID -> AspireHostRunProfileState(executable, activeRuntime, environment)
DefaultDebugExecutor.EXECUTOR_ID -> AspireHostDebugProfileState(executable, activeRuntime, environment)
else -> throw CantRunException("Unable to execute Aspire host with $executorId executor")
}
}