Skip to content

Commit

Permalink
Use the AzureFunctionsVersion MSBuild property value to choose the …
Browse files Browse the repository at this point in the history
…proper func cli
  • Loading branch information
rafaelldi committed Aug 16, 2024
1 parent f981c72 commit 5b9c2c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
4 changes: 4 additions & 0 deletions PluginsAndFeatures/azure-toolkit-for-rider/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 5b9c2c5

Please sign in to comment.