diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/CHANGELOG.md b/PluginsAndFeatures/azure-toolkit-for-rider/CHANGELOG.md index 865ea130d8..bd6780839f 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/CHANGELOG.md +++ b/PluginsAndFeatures/azure-toolkit-for-rider/CHANGELOG.md @@ -8,6 +8,10 @@ - Option to disable authentication cache +### Fixed + +- Plugin uses `v4` func cli even if the value of the MSBuild property is `v0` + ## [4.0.1] - 2024-08-16 ### Changed diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/PublishableProjectModelExtensions.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/PublishableProjectModelExtensions.kt index d564eb9732..be0939ea35 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/PublishableProjectModelExtensions.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/PublishableProjectModelExtensions.kt @@ -68,7 +68,7 @@ suspend fun PublishableProjectModel.getFunctionStack( .getInstance(project) .getFunctionLocalSettings(this) val workerRuntime = functionLocalSettings?.values?.workerRuntime ?: FunctionWorkerRuntime.DOTNET_ISOLATED - val coreToolsVersion = withContext(Dispatchers.EDT) { + val azureFunctionVersion = withContext(Dispatchers.EDT) { FunctionCoreToolsMsBuildService .getInstance() .requestAzureFunctionsVersion(project, this@getFunctionStack.projectFilePath) @@ -78,11 +78,19 @@ suspend fun PublishableProjectModel.getFunctionStack( val dotnetVersion = getProjectDotNetVersion(project, this) return FunctionRuntimeStack( workerRuntime.value(), - "~$coreToolsVersion", + functionRuntimeVersionFromProjectProperty(azureFunctionVersion), if (operatingSystem == OperatingSystem.LINUX) "${workerRuntime.value()}|$dotnetVersion" else "" ) } +private fun functionRuntimeVersionFromProjectProperty(azureFunctionVersion: String) = when (azureFunctionVersion) { + "4" -> "~4" + "3" -> "~3" + "2" -> "~2" + "1" -> "~1" + else -> "~4" +} + private fun getProjectDotNetVersion(project: Project, publishableProject: PublishableProjectModel): String? { val currentFramework = getCurrentFrameworkId(project, publishableProject) ?: return null return netAppVersionRegex.find(currentFramework)?.groups?.get(1)?.value diff --git a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/coreTools/FunctionCoreToolsMsBuildService.kt b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/coreTools/FunctionCoreToolsMsBuildService.kt index 6c2090e9e2..da0af6edfc 100644 --- a/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/coreTools/FunctionCoreToolsMsBuildService.kt +++ b/PluginsAndFeatures/azure-toolkit-for-rider/azure-intellij-plugin-appservice-dotnet/src/main/kotlin/com/microsoft/azure/toolkit/intellij/legacy/function/coreTools/FunctionCoreToolsMsBuildService.kt @@ -18,15 +18,9 @@ class FunctionCoreToolsMsBuildService { const val PROPERTY_AZURE_FUNCTIONS_VERSION = "AzureFunctionsVersion" } - suspend fun requestAzureFunctionsVersion(project: Project, projectFilePath: String): String? { - val functionVersion = project.solution.functionAppDaemonModel.getAzureFunctionsVersion + suspend fun requestAzureFunctionsVersion(project: Project, projectFilePath: String) = + project.solution + .functionAppDaemonModel + .getAzureFunctionsVersion .startSuspending(AzureFunctionsVersionRequest(projectFilePath)) - - //hack: sometimes we receive v0 even for v4 project - if (functionVersion == "v0") { - return "v4" - } - - return functionVersion - } } \ No newline at end of file