'Task 'prepareKotlinBuildScriptModel' not found in project

I have this error in my project Task 'prepareKotlinBuildScriptModel' not found in project I was looking at it online and found that adding the following lines will fix it

task prepareKotlinBuildScriptModel {

}

I tried adding the above to build.gradle.kts and following error ocured.

Function invocation 'task(...)' expected

I also tried tasks.register("prepareKotlinBuildScriptModel"){} which did not work too

what is the correct way of writing a task please.

thanks for your help in advance

thanks R



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source