fun validate()

in rider/src/main/kotlin/com/jetbrains/aspire/rider/run/host/AspireHostConfigurationParameters.kt [77:114]


    fun validate() {
        if (!project.solution.isLoaded.hasTrueValue) {
            throw RuntimeConfigurationError(DotNetProjectConfigurationParameters.SOLUTION_IS_LOADING)
        }

        val runnableProjects = project.solution.runnableProjectsModel.projects.valueOrNull
            ?: throw RuntimeConfigurationError(DotNetProjectConfigurationParameters.SOLUTION_IS_LOADING)

        if (projectFilePath.isEmpty()) {
            throw RuntimeConfigurationError(DotNetProjectConfigurationParameters.PROJECT_NOT_SPECIFIED)
        }
        val project = runnableProjects.singleOrNull {
            it.projectFilePath == projectFilePath && it.kind == AspireRunnableProjectKinds.AspireHost
        } ?: throw RuntimeConfigurationError(RiderRunBundle.message("selected.project.not.found"))

        if (projectTfm.isEmpty() || projectTfm.equals("unknown", ignoreCase = true)) {
            throw RuntimeConfigurationError(RiderRunBundle.message("dialog.message.target.framework.is.not.specified"))
        }

        if (profileName.isEmpty()) {
            throw RuntimeConfigurationError(RiderRunBundle.message("launch.profile.is.not.specified"))
        }

        if (!trackWorkingDirectory) {
            val workingDirectoryPath = Path(workingDirectory)
            if (!workingDirectoryPath.exists() || !workingDirectoryPath.isDirectory())
                throw RuntimeConfigurationError(
                    RiderRunBundle.message(
                        "dialog.message.invalid.working.dir",
                        workingDirectory.ifEmpty { "<empty>" }
                    )
                )
        }

        if (!project.problems.isNullOrEmpty()) {
            throw RuntimeConfigurationError(project.problems)
        }
    }