Open degant opened 2 years ago
Have you added reference to Microsoft.Azure.AutoRest.CSharp
?
<PropertyGroup>
<LangVersion>9.0</LangVersion>
<IncludeGeneratorSharedCode>true</IncludeGeneratorSharedCode>
<RestoreAdditionalProjectSources>https://azuresdkartifacts.blob.core.windows.net/azure-sdk-tools/index.json</RestoreAdditionalProjectSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20211112.1" />
</ItemGroup>
I tried to add the reference you mentioned along with RestoreAdditionalProjectSources
but it looks like that version isn't available in the source. Let me know if there's a different source I need to use for these beta packages. I couldn't find them in nuget.org either.
error NU1102: Unable to find package Microsoft.Azure.AutoRest.CSharp with version (>= 3.0.0-beta.20211110.2)
error NU1102: - Found 144 version(s) in https://azuresdkartifacts.blob.core.windows.net/azure-sdk-tools/index.json [ Nearest version: 3.0.0-beta.20210604.3 ]
So I ended up adding 3.0.0-beta.20210604.3. It is now able to resolve RawRequestUriBuilder
but ClientDiagnostics
still doesn't work. Do you have a sample for the v3 version outside of azure-sdk-net?
Try
<PropertyGroup>
<IncludeGeneratorSharedCode>true</IncludeGeneratorSharedCode>
<RestoreAdditionalProjectSources>https://azuresdkartifacts.blob.core.windows.net/azure-sdk-tools/index.json</RestoreAdditionalProjectSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.21.0" />
<PackageReference Include="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20210311.1" PrivateAssets="All" />
</ItemGroup>
Thanks @eskaufel , had the same issue and this helped.
I've just generated a new client and it is not compiling. As far as I see everything is included in the csproj file, as @eskaufel suggested, but I still get the following error message.
Unable to find package Microsoft.Azure.AutoRest.CSharp with version (>= 3.0.0-beta.20220221.1)
- Found 144 version(s) in https://azuresdkartifacts.blob.core.windows.net/azure-sdk-tools/index.json [ Nearest version: 3.0.0-beta.20210604.3 ]
- Found 0 version(s) in Microsoft Visual Studio Offline Packages
- Found 0 version(s) in nuget.org
As far as I see there is a big gap between the available version (20210604.3) and the requested one (20220221.1), so what to do now?
Generated csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>annotations</Nullable>
</PropertyGroup>
<PropertyGroup>
<LangVersion>8.0</LangVersion>
<IncludeGeneratorSharedCode>true</IncludeGeneratorSharedCode>
<RestoreAdditionalProjectSources>https://azuresdkartifacts.blob.core.windows.net/azure-sdk-tools/index.json</RestoreAdditionalProjectSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20220221.1" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.22.0" />
</ItemGroup>
</Project>
Thanks to lots of pointers in this issue and others I've found a combination that builds at the time of writing. The main discovery is that the feed used to publish Microsoft.Azure.AutoRest.CSharp
nuget to has changed to https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json
- please could this be pushed to nuget.org?
Here's what worked for me:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup>
<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.25.0" />
<PackageReference Include="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20221103.1" />
</ItemGroup>
<Target Name="PreBuild" AfterTargets="PreBuildEvent">
<!-- npm install -g autorest@latest -->
<Exec Command="autorest --use:@autorest/csharp@3.0.0-beta.20221103.1 --input-file=swagger.json --output-folder=. --verbose" />
</Target>
</Project>
Hopefully that helps someone else who lands here.
Just so the project is aware, after trawling through a few threads etc on this @neilrees post above was most helpful. You have to add in the additional Nuget source AND include prerelease to be able to see the magical "Microsoft.Azure.AutoRest.CSharp" package that everyone mentions.
Still doesn't work.
Yes, I tried the alpha of Azure.Core also. Didn't change anything.
There is nothing else in my project, just the auto-generated code.
Update (for myself): it looks like this excellent project is now broken for what we use it for and has no intention of supporting what once was. It seems like a very bizarre decision, Ref: https://github.com/Azure/autorest.csharp/issues/1044 Other users have mentioned NSwag https://github.com/RicoSuter/NSwag which I guess I now have to check out as it seems my use-case has been abandoned.
I followed the steps mentioned here (Use outside of the azure-sdk-net repo) to try out the v3 generator, but the generator adds
ClientDiagnostics
to all my constructors which is basically inaccessible since it is marked as internal inAzure.Core
. I think it is pretty cool that you're usingHttpPipeline
and most of the Azure.Core stuff for building the v3 clients, but I'm not sure how to use it outside of the azure-sdk-net repo. Am I missing something here? or following some incorrect steps to generate?