Jesse
Jesse

Reputation: 21

AutoRest generated client won't compile - Cannot resolve RequestContext

When generating a client the resulting package appears to have all the necessary packages. The code references RequestContext, which is part of Azure.Core, but neither Visual Studio 2022 nor Rider can resolve it.

I'm hesitant to add our org's Swagger file. Fortunately this occurs even when using the example yaml file from the autorest repo: Petstore.Yaml

My settings are pretty basic: autorest --input-file=petstore.yaml --csharp --namespace=Petstore --output-folder=Client

I am using the current version of Autorest (3.7.0) with extensions: @autorest/csharp: (latest->3.0.0-beta.20240116.1) @autorest/modelerfour: (4.26.0->4.26.0)

There must be a package or setting I'm missing, but I have not found any documentation related to this issue.

Upvotes: 2

Views: 126

Answers (1)

Adam Adamczyk
Adam Adamczyk

Reputation: 11

Try something similar like this

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
        <LangVersion>11.0</LangVersion>
        <Nullable>annotations</Nullable>
        <IncludeGeneratorSharedCode>true</IncludeGeneratorSharedCode>
        <RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json</RestoreAdditionalProjectSources>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Azure.Core" Version="1.39.0" />
        <PackageReference Include="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20240424.1" PrivateAssets="All" />
    </ItemGroup>

</Project>

Upvotes: 0

Related Questions