Jon Koeter
Jon Koeter

Reputation: 1094

Unable to upgrade Azure Functions Core Tools, Exception "Cannot create instance of type 'NuGet.Versioning.VersionRange'"

I'm trying to run an Azure Function. After upgrading to .Net 6, debugging it locally with an updated version of Visual Studio 2022 gives me the following exception:

A host error has occurred during startup operation 'dca54039-23ee-4ec2-ad9d-9deafe1b2869'. [2022-09-08T07:07:05.464Z] Microsoft.Extensions.Configuration.Binder: Cannot create instance of type 'NuGet.Versioning.VersionRange' because it is missing a public parameterless constructor.

Exception when running on my machine

My co-workers do not get this error and it works great in production. The big difference we found was that they have a Core Tools Version that differs from mine.

I believe the problem lies here, but besides trying to upgrade I also tried other things:

Adding the verbose flag does not get me any further and outputs the following:

Verbose enabled

Since then I've been trying to upgrade the Tools version. But here's the thing: even though func --version tells me I have 4.0.4736, the debug window still says 4.0.3971. I tried the following things:

PS C:\Windows\system32> npm i -g azure-functions-core-tools@4 --unsafe-perm true

changed 51 packages, and audited 52 packages in 18s found 0 vulnerabilities

PS C:\Windows\system32> npm i -g [email protected] --unsafe-perm true

changed 51 packages, and audited 52 packages in 26s found 0 vulnerabilities

PS C:\Windows\system32> func --version 4.0.4736

Nothing seems to help.

Upvotes: 5

Views: 5843

Answers (3)

DilLip_Chowdary
DilLip_Chowdary

Reputation: 1191

For Linux Users:

This could resolve your issue:

Uninstall:

npm uninstall -g azure-functions-core-tools

ReInstall:

npm install -g azure-functions-core-tools

Upvotes: 1

Sampath Kumar
Sampath Kumar

Reputation: 1

This worked for me:

  1. Close Visual Studio,
  2. Delete folder C:\Users\***\AppData\Local\AzureFunctionsTools
  3. Delete temp and %temp%
  4. Restart PC
  5. Restart Visual Studio.
  6. Launch Application, folder gets recreated.

App started running for me and the below error got resolved:

A host error has occurred during startup operation '8bd9dcec-3c37-4ecf-9db9-894534073cfd'.

[2022-11-15T07:08:40.813Z] System.Private.CoreLib: Could not load file or assembly 'Microsoft.Azure.WebJobs.Extensions.Http, Version=3.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

Upvotes: -1

Jon Koeter
Jon Koeter

Reputation: 1094

The solution was:

  • Close Visual Studio
  • Delete folder C:\Users\***\AppData\Local\AzureFunctionsTools
  • Restart Visual Studio.
  • Launch Application, folder gets recreated.

As soon as I had my co-worker review this question (to make sure I didn't post any vulnerabilities) he said "Oh, that other co-worker found a solution, you should delete C:\Users\***\AppData\Local\AzureFunctionsTools and you're good to go"

So I did.

And it works right away.

Upvotes: 10

Related Questions