diff --git a/plugin-dotnet-server/src/main/kotlin/jetbrains/buildServer/dotnet/DotnetModelParser.kt b/plugin-dotnet-server/src/main/kotlin/jetbrains/buildServer/dotnet/DotnetModelParser.kt index b622dcae2..2daf35e5f 100644 --- a/plugin-dotnet-server/src/main/kotlin/jetbrains/buildServer/dotnet/DotnetModelParser.kt +++ b/plugin-dotnet-server/src/main/kotlin/jetbrains/buildServer/dotnet/DotnetModelParser.kt @@ -77,8 +77,8 @@ class DotnetModelParser { return null } - fun getCsProjectModels(element: Element): List? { - if (!element.isContentAvailable) { + fun getCsProjectModels(element: Element?): List? { + if (element == null || !element.isContentAvailable) { return null } diff --git a/plugin-dotnet-server/src/main/kotlin/jetbrains/buildServer/dotnet/fetchers/DotnetProjectsDataFetcher.kt b/plugin-dotnet-server/src/main/kotlin/jetbrains/buildServer/dotnet/fetchers/DotnetProjectsDataFetcher.kt index fda327584..ae716fe6a 100644 --- a/plugin-dotnet-server/src/main/kotlin/jetbrains/buildServer/dotnet/fetchers/DotnetProjectsDataFetcher.kt +++ b/plugin-dotnet-server/src/main/kotlin/jetbrains/buildServer/dotnet/fetchers/DotnetProjectsDataFetcher.kt @@ -32,14 +32,25 @@ abstract class DotnetProjectsDataFetcher(private val myModelParser: DotnetModelP for (projectPath in projectsPaths) { val path = projectPath.trimEnd('/') - val jsonProjectFile: String = getJsonProject(path) - myModelParser.getProjectModel(browser.getElement(jsonProjectFile))?.let { - items.addAll(getDataItems(it)) + + getJsonProject(path).let { + myModelParser.getProjectModel(browser.getElement(it))?.let { + items.addAll(getDataItems(it)) + } } - val csProjectFile: String = getCsProject(path, browser) - myModelParser.getCsProjectModel(browser.getElement(csProjectFile))?.let { - items.addAll(getDataItems(it)) + getCsProject(path, browser)?.let { + myModelParser.getCsProjectModel(browser.getElement(it))?.let { + items.addAll(getDataItems(it)) + } + } + + getCsProjects(path, browser)?.let { + myModelParser.getCsProjectModels(browser.getElement(it))?.let { + it.forEach { + items.addAll(getDataItems(it)) + } + } } } @@ -65,8 +76,10 @@ abstract class DotnetProjectsDataFetcher(private val myModelParser: DotnetModelP return projectFile } - private fun getCsProject(projectPath: String, browser: Browser): String { - if (!projectPath.endsWith(DotnetConstants.PROJECT_CSPROJ, ignoreCase = true)) { + private fun getCsProject(projectPath: String, browser: Browser): String? { + if (projectPath.endsWith(DotnetConstants.PROJECT_CSPROJ, ignoreCase = true)) { + return projectPath + } else { browser.getElement(projectPath)?.let { it.children?.let { it.firstOrNull { @@ -78,7 +91,25 @@ abstract class DotnetProjectsDataFetcher(private val myModelParser: DotnetModelP } } - return projectPath + return null + } + + private fun getCsProjects(projectPath: String, browser: Browser): String? { + if (projectPath.endsWith(DotnetConstants.PROJECT_SLN, ignoreCase = true)) { + return projectPath + } else { + browser.getElement(projectPath)?.let { + it.children?.let { + it.firstOrNull { + it.fullName.endsWith(DotnetConstants.PROJECT_SLN, ignoreCase = true) + }?.let { + return it.fullName + } + } + } + } + + return null } protected abstract fun getDataItems(project: Project?): Collection