question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AutoRest does not load the correct version of extension '@autorest/csharp'

See original GitHub issue

Repro steps:

  1. At any time of this repo, clean all the cache, for example at that time the Microsoft.Azure.AutoRest.CSharp version is 3.0.0-beta.20230328.2.
  2. Run dotnet msbuild /t:GenerateCode under an arbitrary project. The version autorest is loading should be 3.0.0-beta.20230328.2.
  3. Change the Microsoft.Azure.AutoRest.CSharp version to 3.0.0-beta.20230329.1.
  4. Run dotnet msbuild /t:GenerateCode again, you would see the Microsoft.Azure.AutoRest.CSharp version is still 3.0.0-beta.20230328.2 instead of 3.0.0-beta.20230329.1.

info | Loading local AutoRest extension ‘@autorest/csharp’ (C:/Users/pashao.FAREAST/.nuget/packages/microsoft.azure.autorest.csharp/3.0.0-beta.20230328.2/buildMultiTargeting/…/tools/net6.0/any/)

Root cause: You could go to {RopoRoot}\artifacts\obj\Azure.Analytics.Synapse.Monitoring for example, there is a cache file project.nuget.cache. Its content is image

Suggestion: I suggest we add a dotnet restore to every autorest.md, otherwise user might generate incorrect code from out-of-date generator. image

Issue Analytics

  • State:open
  • Created 6 months ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pshao25commented, Mar 31, 2023

Is this issue more of a concern now than before due to all the activity happening in the autorest repo? As Michael said I would assume this is package caching concern which is usually diminished by backward compatibility. So, if you end up using an older package you generate older code but not necessarily incorrect code.

I would rephrase as “user might generate unexpected code from out-of-date generator.”

1reaction
heathscommented, Mar 30, 2023

I agree with Michael. Solve this as low down the stack as possible by depending on the Restore target for GenerateCode. You might need to find some way to force it, though. Maybe. Given a <PackageReference> changed that may not be necessary.

If you fix it in some higher-level script, if and when someone calls the GenerateCode target themselves or another script is written for some other purpose, the problem will be apparent again and may be hard to diagnose for people who aren’t as familiar with the system end-to-end.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to install Autorest extension... · Issue #2736 · Azure ...
When I try to generate csharp proxy I get the following error: Installing AutoRest extension '@microsoft.azure/autorest.csharp' (~2.1.0) ...
Read more >
How to downgrade Autorest extensions - specifically C# ...
I am using Autorest to generate C# code from an OpenAPI YAML file. I tried to upgrade the Autorest C# extension to the...
Read more >
AutoRest Versioning
The CLI can load any version of the AutoRest Core module by using the command line --version:[VERSION] where [VERSION] is one of: a...
Read more >
AutoRest Extensions for OpenAPI 2.0
The following documents describes AutoRest specific vendor extensions for OpenAPI 2.0 schema. Code generation impact and support may vary per language. Some of ......
Read more >
autorest | Yarn - Package Manager
The AutoRest tool generates client libraries for accessing RESTful web services. Input to AutoRest is an OpenAPI spec that describes the REST API....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found