C# Autorest生成在升级后失败。

huangapple go评论68阅读模式
英文:

C# Autorest Generation Fails After Upgrade

问题

以下是您提供的内容的翻译部分:

我曾经有一个用于生成自动REST代码的脚本,该脚本使用的是autorest 3.0.6306和autorest/csharp 2.3.79。

我尝试将autorest的版本升级到3.6.3,csharp版本为3.0.0-beta.20230604.1。

脚本相当基本

$SwashbuckleOutputFile = "removed/for/privacy.json"

$WorkingOutputFile = "removed/for/privacy.json"

$SwaggerDocumentName = "RemovedForPrivacyClient"

$InputApiDll = "./bin/Debug/net6.0/Removed.For.Privacy.dll"

$ClientClassesHomeDirectory = "../Removed/For/Privacy"


dotnet tool restore

dotnet build

dotnet swagger tofile --output $SwashbuckleOutputFile $InputApiDll $SwaggerDocumentName

((Get-Content $SwashbuckleOutputFile -Raw) -replace ',\s+"additionalProperties": (false|\{ \})','') | Set-Content $WorkingOutputFile

npm i --silent autorest


./node_modules/.bin/autorest --csharp --enum-types=true --version=3.6.3 --input-file=$WorkingOutputFile --output-folder=$ClientClassesHomeDirectory --use=@autorest/csharp@3.0.0-beta.20230604.1 --namespace=Removed.For.Privacy --clear-output-folder --verbose

一切似乎都在顺利进行,直到生成似乎突然...停止。

PS /Removed> ./buildAndGenerateSwagger.ps1

工具 'swashbuckle.aspnetcore.cli'(版本 '5.6.3')已恢复。可用命令:swagger

 

还原成功。

Microsoft(R)构建引擎版本17.2.0+41abc5629用于.NET

版权所有(C)Microsoft Corporation。保留所有权利。

 

 确定要还原的项目...

 所有项目都已经为还原而更新。

 项目1-> /Removed.for.privacy.dll

 项目2-> /Removed.For.Privacy.2.dll

 项目3-> Removed.For.Privacy.3.dll

 

构建成功。

  0个警告

  0个错误

 

经过的时间00:00:03.10

*** AWS Cloudwatch logGroupName: 

***日志路径: 

Swagger JSON/YAML已成功写入/Removed/For/Privacy.json

+ autorest@3.6.3

在0.95秒内更新了1个包并审核了2个包

 

1个包正在寻找资金

  运行“npm fund”以获取详细信息

 

发现0个漏洞

 

AutoRest代码生成实用程序[CLI版本:3.6.3;节点:v12.11.1]

(C)2018 Microsoft Corporation。

https://aka.ms/autorest

info | 从配置中选择的AutoRest核心版本:3.6.3。

info |  加载AutoRest核心 '...'(3.6.3)

verbose | [0.75 s]  初始配置文件 'file:.../readme.md'

verbose | [0.75 s]  包括配置文件 'file:.../readme.md'

verbose | [0.76 s]  包括配置文件 '.../@autorest/core/dist/resources/default-configuration.md'

verbose | [0.78 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/inspect.md'

verbose | [0.79 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/directives.md'

verbose | [0.80 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/pipeline.md'

verbose | [0.81 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/loader-openapi.md'

verbose | [0.83 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/miscellaneous.md'

verbose | [0.84 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-powershell.md'

verbose | [0.86 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-azureresourceschema.md'

verbose | [0.88 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-csharp.md'

verbose | [0.89 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-go.md'

verbose | [0.90 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-java.md'

verbose | [0.91 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-nodejs.md'

verbose | [0.93 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-php.md'

verbose | [0.94 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-python.md'

verbose | [0.95 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-ruby.md'

verbose | [0.97 s]  包括配置文件 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-typescript.md'

verbose | [0.98 s]  包括配置文件 'file:.../.autorest/@

<details>
<summary>英文:</summary>

I had a script I was using for autorest generation that was using autorest 3.0.6306 with autorest/csharp at 2.3.79

I&#39;m trying to upgrade our version of autorest to 3.6.3 with csharp at 3.0.0-beta.20230604.1

The script is fairly basic


$SwashbuckleOutputFile ="removed/for/privacy.json"

$WorkingOutputFile ="removed/for/privacy.json"

$SwaggerDocumentName ="RemovedForPrivacyClient"

$InputApiDll ="./bin/Debug/net6.0/Removed.For.Privacy.dll"

$ClientClassesHomeDirectory ="../Removed/For/Privacy"

dotnet tool restore

dotnet build

dotnet swagger tofile --output $SwashbuckleOutputFile $InputApiDll $SwaggerDocumentName

((Get-Content-path $SwashbuckleOutputFile -Raw) -replace',[\s]+"additionalProperties": (false|{ })','') |Set-Content-Path $WorkingOutputFile

npm i --silent autorest

./node_modules/.bin/autorest --csharp --enum-types=true --version=3.6.3--input-file=$WorkingOutputFile --output-folder=$ClientClassesHomeDirectory --use=@autorest/csharp@3.0.0-beta.20230604.1--namespace=Removed.For.Privacy --clear-output-folder --verbose


Everything seems to be proceeding apace until generation seems to just suddenly... stop.

PS /Removed> ./buildAndGenerateSwagger.ps1

Tool 'swashbuckle.aspnetcore.cli' (version '5.6.3') was restored. Available commands: swagger

 

Restore was successful.

Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET

Copyright (C) Microsoft Corporation. All rights reserved.

 

  Determining projects to restore...

  All projects are up-to-date for restore.

  Project 1-> /Removed.for.privacy.dll

  Project 2-> /Removed.For.Privacy.2.dll

  Project 3-> Removed.For.Privacy.3.dll

 

Build succeeded.

    0 Warning(s)

    0 Error(s)

 

Time Elapsed 00:00:03.10

***AWS Cloudwatch logGroupName: 

***Log Path: 

Swagger JSON/YAML succesfully written to /Removed/For/Privacy.json

updated 1 package and audited 2 packages in 0.95s

 

1 package is looking for funding

  run npm fund for details

 

found 0 vulnerabilities

 

AutoRest code generation utility [cli version: 3.6.3; node: v12.11.1]

(C) 2018 Microsoft Corporation.

https://aka.ms/autorest

info   | AutoRest core version selected from configuration: 3.6.3.

info   |   Loading AutoRest core      '...' (3.6.3)

verbose | [0.75 s]   Initial configuration file 'file:.../readme.md'

verbose | [0.75 s]   Including configuration file 'file:.../readme.md'

verbose | [0.76 s]   Including configuration file '.../@autorest/core/dist/resources/default-configuration.md'

verbose | [0.78 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/inspect.md'

verbose | [0.79 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/directives.md'

verbose | [0.80 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/pipeline.md'

verbose | [0.81 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/loader-openapi.md'

verbose | [0.83 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/miscellaneous.md'

verbose | [0.84 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-powershell.md'

verbose | [0.86 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-azureresourceschema.md'

verbose | [0.88 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-csharp.md'

verbose | [0.89 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-go.md'

verbose | [0.90 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-java.md'

verbose | [0.91 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-nodejs.md'

verbose | [0.93 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-php.md'

verbose | [0.94 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-python.md'

verbose | [0.95 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-ruby.md'

verbose | [0.97 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-typescript.md'

verbose | [0.98 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-validators.md'

verbose | [1.00 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-az.md'

verbose | [1.01 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-terraform.md'

verbose | [1.03 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/plugin-azure-functions.md'

verbose | [1.04 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/graphs.md'

verbose | [1.06 s]   Including configuration file 'file:.../.autorest/@autorestcore@3.6.3/nodemodules/@autorest/core/dist/resources/help-configuration.md'

info   |   Loading AutoRest extension '@autorest/csharp' (3.0.0-beta.20230604.1->3.0.0-beta.20230604.1)

verbose | [1.12 s]   Including extension configuration file 'file:.../.autorest/@autorestcsharp@3.0.0-beta.20230604.1/nodemodules/@autorest/csharp/readme.md'

verbose | [1.12 s]   Including configuration file 'file:.../.autorest/@autorestcsharp@3.0.0-beta.20230604.1/nodemodules/@autorest/csharp/readme.md'

info   |   Loading AutoRest extension '@autorest/modelerfour' (4.26.0->4.26.0)

verbose | [1.19 s]   Including extension configuration file 'file:.../.autorest/@autorestmodelerfour@4.26.0/nodemodules/@autorest/modelerfour/readme.md'

verbose | [1.19 s]   Including configuration file 'file:.../.autorest/@autorestmodelerfour@4.26.0/nodemodules/@autorest/modelerfour/readme.md'

verbose | [1.93 s] Reading OpenAPI 3.0 file file:Removed/For/Privacy.json

warning | PreCheck/CheckDuplicateSchemas | Checking for duplicate schemas, this could take a (long) while.  Run with --verbose for more detail.

verbose | [2.57 s] Found and removed 0 duplicate schema

And that&#39;s it. It just stops there. Hangs dead for the rest of time. I&#39;ve let it run for hours and it never continues past that point.


I&#39;ve tried adding and removing stuff from that final command, changing the way it works. The command originally didn&#39;t have `--csharp` included because that was in the readme (which only has `output-folder`, `namespace`, and `csharp` in it) and I added that. Nothing seems to be changing the fact that this thing just stops after the duplicate check.

</details>


# 答案1
**得分**: 0

答案是使用版本3.9.6而不是3.6.3。

<details>
<summary>英文:</summary>

The answer was to use version 3.9.6 instead of 3.6.3 

</details>



huangapple
  • 本文由 发表于 2023年6月8日 03:26:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76426535.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定