I got it working with the following script and by fixing my environment variable MSBuildSDKsPath which was pointing to an non existing .net sdk folder.
https://github.com/microsoft/DockerTools/issues/456#issuecomment-2784574266