Open LucasYao93 opened 2 years ago
Following are details about how to build autorest.csharp with Visual Studio.
new AutoRest.Simplify.CSharpSimplifier().Run(fs).ConfigureAwait(false).GetAwaiter().GetResult();
from the Program.cs to disable simplifier pluginIf you run into any build errors, you probably need to install dotnet core 2.1 in Visual Studio
In this directory, run AutoRest.
To generate SDK with autorest.csharp
autorest --use:<path-to-autorest.csharp> --tag=basic-get.csharp
# Install NodeJS 14.20.1
nvs add 14.20.1
# Switch to version 14.20.1
nvs use 14.20.1
npm install -g dotnet-sdk-2.1
npm install -g autorest@latest
npm install -g @microsoft/rush@5.63.1
visual studio code
Code repo is located in https://github.com/Azure/autorest.powershell.
And there are two major branches
# Install dependencies
rush update
# Clean build
rush rebuild
Following are some useful commands of rush. Please refer here for more details about rush.
# detect issues that do not follow the lint rule
rush lint
# autofix the issues that do not follow the lint rule
rush fix
# Caculate the next release version
rush set-versions
# run all npm test
rush test
# auto packaging
rush watch
# For more cmds, you may run following cmd
rush -h
*Note: except for embedded commands of rush, we have some custom ones defined in common/config/rush/command-line.json.*
autorest --use:C:\Users\xxx\source\autorest.powershell
autorest --use:C:\Users\xxx\source\autorest.powershell --interactive
autorest --use:C:\Users\xxx\source\autorest.powershell --powershell.debugger
content-type
is a multipart/formdata
then we should go thru the parameters of the body and look for a string/binary parameters and remember to add another parameter for the filename of the string/binaryAll generated code are in generated/api
project→namespace→class, interface→property, field, method→local varible, statement like if else.
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ModuleDescription $moduleDescription -DocsFolder $docsFolder -ExamplesFolder $examplesFolder -ModuleGuid $guid
Export-FormatPs1xml -FilePath $formatPs1xml
Export-Psd1 -ExportsFolder $exportsFolder -CustomFolder $customFolder -Psd1Path $psd1 -ModuleGuid $guid
Export-TestStub -ModuleName $moduleName -ExportsFolder $exportsFolder -OutputFolder $testFolder
Export-ExampleStub -ExportsFolder $exportsFolder -OutputFolder $examplesFolder
Export-CmdletSurface -ModuleName $moduleName -CmdletFolder $exportsFolder -OutputFolder $resourcesFolder -IncludeGeneralParameters $IncludeGeneralParameters.IsPresent -UseExpandedFormat $UseExpandedFormat.IsPresent
Export-ModelSurface -OutputFolder $resourcesFolder -UseExpandedFormat $UseExpandedFormat.IsPresent
Export-HelpMarkdown -ModuleInfo $moduleInfo -FunctionInfo $cmdletFunctionInfo -HelpInfo $cmdletHelpInfo -DocsFolder $docsPath -ExamplesFolder $examplesPath
GetCommonParameter -- not used
GetScriptCmdlets -- an internal cmdlets used by other cmdlets
Get guid from the psd1 file, if not existed, create a new one.
Export the surface (signature) of the cmdlet
List all the cmdlets in a script folder (e.g. exports)
Generate two empty example stubs with name, code, description with the exports folder as input, if example files are there, do not do it.
Generate format file by using exported class (in model namespace and support namespace) in the assembly
There is a bug. For no profiles, "exports" should not appear in the docs path.
Export models by using exported class (in model namespace and support namespace) in the assembly
Generate proxy (may include docs, which is controlled by -ExcludeDocs) from the dll and custom script.
Generate psd1 file, GUID will be generated if there is no GUID in a existed psd1 file.
Generate test files per cmdlet from the exports folder
Get the common parameters (Azure, Runtime, Confirm, WhatIf, First, Skip, IncludeTotalCount)
autorest --use:..\..\..\..\autorest.csharp --tag=basic-get.csharp
autorest --use:..\..\..\..\autorest.powershell --tag=basic-get.powershell
autorest --use:..\..\..\..\autorest.powershell --tag=basic-spec-required.powershell
AutoRest code generation utility [cli version: 3.6.2; node: v14.20.1]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
info | Loading AutoRest core 'C:\Users\v-diya\.autorest\@autorestcore@3.9.3\nodemodules\@autorest\core\dist' (3.9.3)
info |
The default version of @autorest/powershell has been bumped from 2.1+ to 3.0+.
> If you still want to use 2.1+ version, please specify it with --use:@autorest/powershell@2.1.{x}, e.g 2.1.401.
info | Loading local AutoRest extension '@autorest/powershell' (C:\Users\v-diya\repository\AutorestSdkSupport\autorest.powershell)
info | Loading AutoRest extension '@autorest/modelerfour' (4.23.1->4.23.1)
warning | PreCheck/CheckDuplicateSchemas | Checking for duplicate schemas, this could take a (long) while. Run with --verbose for more detail.
warning | UsingTemporaryFlag | modelerfour.treat-type-object-as-anything options is a temporary flag. It WILL be removed in the future.
C:\Users\v-diya\repository\AutorestSdkSupport\autorest.powershell\powershell\dist\plugins\sdk-generate.js - FAILURE {"path":"C:\\Users\\v-diya\\repository\\AutorestSdkSupport\\autorest.powershell\\powershell\\resources\\templates\\azureServiceClient.ejs"}
fatal | TypeError: C:\Users\v-diya\repository\AutorestSdkSupport\autorest.powershell\powershell\resources\templates\azureServiceClient.ejs:20
18| {
19| <%# ToDo: add ServiceClientBodyTemplate -%>
>> 20| <%- include('serviceClientBody', {project: project}) -%>
21| /// <summary>
22| /// An optional partial-method to perform custom initialization.
23| /// </summary>
C:\Users\v-diya\repository\AutorestSdkSupport\autorest.powershell\powershell\resources\templates\serviceClientBody.ejs:14
12| /// </summary>
13| public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; }
>> 14| <% project.model.globalParameters.filter(p=>p.language.default.name != '$host').forEach(function(parameter) {-%>
15| /// <summary>
16| /// <%=parameter.language.default.description%>
17| /// </summary>
Cannot read property 'filter' of undefined
fatal | Process() cancelled due to failure
error | Error: Plugin generate reported failure.
error | Autorest completed with an error. If you think the error message is unclear, or is a bug, please declare an issues at https://github.com/Azure/autorest/issues with the error message you are seeing.
autorest --use:..\..\..\..\autorest.powershell --tag=basic-spec-root.powershell
AutoRest code generation utility [cli version: 3.6.2; node: v14.20.1]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
info | Loading AutoRest core 'C:\Users\v-diya\.autorest\@autorestcore@3.9.3\nodemodules\@autorest\core\dist' (3.9.3)
info |
The default version of @autorest/powershell has been bumped from 2.1+ to 3.0+.
> If you still want to use 2.1+ version, please specify it with --use:@autorest/powershell@2.1.{x}, e.g 2.1.401.
info | Loading local AutoRest extension '@autorest/powershell' (C:\Users\v-diya\repository\AutorestSdkSupport\autorest.powershell)
info | Loading AutoRest extension '@autorest/modelerfour' (4.23.1->4.23.1)
warning | PreCheck/CheckDuplicateSchemas | Checking for duplicate schemas, this could take a (long) while. Run with --verbose for more detail.
warning | UsingTemporaryFlag | modelerfour.treat-type-object-as-anything options is a temporary flag. It WILL be removed in the future.
warning | SecurityDefinedSpecAndConfig | OpenAPI spec has a security definition but autorest security config is defined. Security config from autorest will be used.
C:\Users\v-diya\repository\AutorestSdkSupport\autorest.powershell\powershell\dist\plugins\sdk-generate.js - FAILURE {"path":"C:\\Users\\v-diya\\repository\\AutorestSdkSupport\\autorest.powershell\\powershell\\resources\\templates\\azureServiceClient.ejs"}
fatal | TypeError: C:\Users\v-diya\repository\AutorestSdkSupport\autorest.powershell\powershell\resources\templates\azureServiceClient.ejs:20
18| {
19| <%# ToDo: add ServiceClientBodyTemplate -%>
>> 20| <%- include('serviceClientBody', {project: project}) -%>
21| /// <summary>
22| /// An optional partial-method to perform custom initialization.
23| /// </summary>
C:\Users\v-diya\repository\AutorestSdkSupport\autorest.powershell\powershell\resources\templates\serviceClientBody.ejs:14
12| /// </summary>
13| public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; }
>> 14| <% project.model.globalParameters.filter(p=>p.language.default.name != '$host').forEach(function(parameter) {-%>
15| /// <summary>
16| /// <%=parameter.language.default.description%>
17| /// </summary>
Cannot read property 'filter' of undefined
fatal | Process() cancelled due to failure
error | Error: Plugin generate reported failure.
error | Autorest completed with an error. If you think the error message is unclear, or is a bug, please declare an issues at https://github.com/Azure/autorest/issues with the error message you are seeing.
autorest --use:..\..\..\..\autorest.powershell --tag=provider-containerRegistry.powershell
AutoRest code generation utility [cli version: 3.6.2; node: v14.20.1]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
info | Loading AutoRest core 'C:\Users\v-diya\.autorest\@autorestcore@3.9.3\nodemodules\@autorest\core\dist' (3.9.3)
info |
The default version of @autorest/powershell has been bumped from 2.1+ to 3.0+.
> If you still want to use 2.1+ version, please specify it with --use:@autorest/powershell@2.1.{x}, e.g 2.1.401.
info | Loading local AutoRest extension '@autorest/powershell' (C:\Users\v-diya\repository\AutorestSdkSupport\autorest.powershell)
info | Loading AutoRest extension '@autorest/modelerfour' (4.23.1->4.23.1)
error | DiscriminatorNotRequired | Semantic violation: Discriminator must be a required property. (components > schemas > RunRequest)
discriminator: { propertyName: 'type' }
- https://github.com/Azure/azure-rest-api-specs/blob/5035a36bcd5b0543a9a65ee21f03bd12e301ea72/specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2019-04-01/containerregistry_build.json:684:5
fatal | Process() cancelled due to failure
error | DiscriminatorNotRequired | Semantic violation: Discriminator must be a required property. (components > schemas > TaskStepProperties)
discriminator: { propertyName: 'type' }
- https://github.com/Azure/azure-rest-api-specs/blob/5035a36bcd5b0543a9a65ee21f03bd12e301ea72/specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2019-04-01/containerregistry_build.json:1252:5
error | DiscriminatorNotRequired | Semantic violation: Discriminator must be a required property. (components > schemas > TaskStepUpdateParameters)
discriminator: { propertyName: 'type' }
- https://github.com/Azure/azure-rest-api-specs/blob/5035a36bcd5b0543a9a65ee21f03bd12e301ea72/specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2019-04-01/containerregistry_build.json:1721:5
error | Error: Semantic validation failed. There was some errors
error | Autorest completed with an error. If you think the error message is unclear, or is a bug, please declare an issues at https://github.com/Azure/autorest/issues with the error message you are seeing.
### Tag: {testcase}.csharp
```yaml $(tag) == '{testcase}.csharp'
csharp: true
input-file:
- .\{testcase}\swagger.json
namespace: Microsoft.Azure.Sample
output-folder: {testcase}\csharp
isSdkGenerator: true
powershell: true
input-file:
- .\{testcase}\swagger.json
namespace: Microsoft.Azure.Sample
output-folder: {testcase}\powershell
Tasks