You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -32,18 +29,17 @@ This tutorial has following sections:
32
29
33
30
## Prerequisites
34
31
35
-
- Install VS 2020 (Community or higher) and make sure you have the [latest updates](https://www.visualstudio.com/).
32
+
- Install Visual Studio 2022 (Community or higher) and make sure you have the [latest updates](https://www.visualstudio.com/).
36
33
- Need at least .NET Framework 4.6.1 and 4.7 development tools
37
-
- Install the **.NET Core cross-platform development** workloads in VisualStudio
34
+
- Install the **.NET Core cross-platform development** workloads in Visual Studio
38
35
- Install **.NET 6.0 SDK** for your specific platform. (or a higher version)
39
-
- Install **.NET core 3.1** for your specific platform.
40
36
- Install the latest version of [git](https://git-scm.com/downloads)
41
37
- Install [PowerShell](https://docs.microsoft.com/powershell/scripting/install/installing-powershell), version 7 or higher.
42
38
- Install [NodeJS](https://nodejs.org/) (16.x.x or above).
43
39
44
-
## Setup your repo
40
+
## Setup your repository
45
41
46
-
- Fork and clone an[azure-sdk-for-net](https://github.com/Azure/azure-sdk-for-net)repo. Follow the instructions in the [.NET CONTRIBUTING.md](https://github.com/Azure/azure-sdk-for-net/issues/12903) to fork and clone the `azure-sdk-for-net` repo.
42
+
- Fork and clone the[azure-sdk-for-net](https://github.com/Azure/azure-sdk-for-net)repository. Instructions for doing so can be found in the [.NET CONTRIBUTING.md](https://github.com/Azure/azure-sdk-for-net/blob/main/CONTRIBUTING.md).
47
43
- Create a branch to work in.
48
44
49
45
## Create starter package
@@ -123,60 +119,50 @@ emitters:
123
119
-`clear-output-folder` indicate if you want to clear up the output folder.
124
120
125
121
126
-
#### Create a sdk project folder
122
+
#### Create sdk starter package
127
123
128
-
You can manually create the project folder. Please refer to [Azure.Template](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template)as an example.
124
+
We will use the Azure SDK template [Azure.Template](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template)to create the initial project skeleton.
129
125
130
-
**Note**:
126
+
You can run `eng\scripts\automation\Invoke-CadlDataPlaneGenerateSDKPackage.ps1` to generate the starting SDK client library package directly as following:
131
127
132
-
- Please refer to [sdk-directory-layout](https://github.com/Azure/azure-sdk/blob/main/docs/policies/repostructure.md#sdk-directory-layout) for detail information.
133
-
- remove `autorest.md` from sdk\<service name>\<package name>\src
134
-
- add `cadl-location.yaml` under sdk\<service name>\<package name>\src
135
-
136
-
Modify `cadl-location.yaml` to add some project meta data if needed, Otherwise just add an empty file.
137
-
138
-
e.g. if you want specify cadl project folder in azure-rest-api-spec repo, you can define (directory, commit, repo) to specify the cadl project.
- `<path-to-cadl-file>`- Should be the entrypoint cadl file of the cadl project. e.g. When you define `client.cadl` to customize the client, the `client.cadl` will be the entrypoint cadl file, and you should specify the path to the `client.cadl`.
166
-
167
-
#### Build the library project
146
+
-`-service` takes Azure client service directory name. ie. purview. It equals to the name of the directory in the specification folder of the azure-rest-api-specs repo that contains the REST API definition file.
147
+
- For `- namespace`, please use one of the pre-approved namespace groups on the [.NET Azure SDK Guidelines Approved Namespaces list](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-namespaces-approved-list). This value will also provide the name for the shipped package, and should be of the form `Azure.<group>.<service>`.
148
+
-`-sdkPath` takes the address of the root directory of sdk repo. e.g. /home/azure-sdk-for-net
149
+
-`cadlRelativeFolder` takes the relative path of the cadl project folder in spec repo. e.g. specification/cognitiveservices/AnomalyDetector
150
+
-`-additionalSubDirectories` takes the relative paths of the additional directories needed by the cadl project, such as share library folder, separated by semicolon if there is more than one folder.
151
+
-`-commit` takes the git commit hash (e.g. ac8e06a2ed0fc1c54663c98f12c8a073f8026b90)
152
+
-`-repo` takes the `<owner>/<repo>` of the REST API specification repository. (e.g. Azure/azure-rest-api-specs)
153
+
-`-specRoot` takes the file system path of the spec repo. e.g. /home/azure-rest-api-specs
154
+
- You need to provide one of (`-commit`, `-repo`) pair to refer to an URL path of the cadl project and `-specRoot` parameters. If you provide both, `-specRoot` will be ignored.
168
155
169
-
Run `dotnet build` under project folder ``<sdkPath>/sdk/<service>/<namespace>` to build the project to create the starter package binary.
156
+
When you run `eng\scripts\automation\Invoke-CadlDataPlaneGenerateSDKPackage.ps1`, it will:
170
157
171
-
#### Export the library's public API
158
+
- Create a project folder, install template files from `sdk/template/Azure.Template`, and create `.csproj` and `.sln` files for your new library.
172
159
173
-
You will need to run the `eng\scripts\Export-API.ps1` script to update the public API listing. This will generate a file in the library's directory `<sdkPath>/sdk/<service>/<namespace>/api` similar to the example found in [sdk\template\Azure.Template\api\Azure.Template.netstandard2.0.cs](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template/api/Azure.Template.netstandard2.0.cs).
160
+
These files are created following the guidance for the [Azure SDK Repository Structure](https://github.com/Azure/azure-sdk/blob/master/docs/policies/repostructure.md).
174
161
175
-
e.g. Running the script for a project in `sdk\deviceupdate` would look like this:
162
+
- Generate the library source code files to the directory `<sdkPath>/sdk/<service>/<namespace>/src/Generated`
163
+
- Build the library project to create the starter package binary.
164
+
- Export the library's public API to the directory `<sdkPath>/sdk/<service>/<namespace>/api`
176
165
177
-
```powershell
178
-
eng\scripts\Export-API.ps1 deviceupdate
179
-
```
180
166
181
167
### Use swagger as Input
182
168
@@ -237,7 +223,8 @@ Adding convenience APIs is not required for Azure SDK data plane generated libra
237
223
238
224
You can add convienice APIs by adding a customization layer on top of the generated code. Please see the [autorest.csharp README](https://github.com/Azure/autorest.csharp#setup) for the details of adding the customization layer. This is the preferred method for adding convenience APIs to your generated client.
239
225
240
-
If other modifications are needed to the generated API, you can consider making them directly to the Open API specification, which will have the benefit of making the changes to the library in all languages you generate the library in. As a last resort, you can add modifications with swagger transforms in the `autorest.md` file. [AnomalyDetector autorest.md](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/anomalydetector/Azure.AI.AnomalyDetector/src/autorest.md) shows and example of how this can be accomplished.
226
+
227
+
If other modifications are needed to the generated API, you can consider making them directly to the Open API specification, which will have the benefit of making the changes to the library in all languages you generate the library in. As a last resort, you can add modifications with swagger transforms in the `autorest.md` file. Details for various transforms can be found in [Customizing the generated code](https://github.com/Azure/autorest.csharp#customizing-the-generated-code).
241
228
242
229
Once you've made changes to the public API, you will need to run the `eng\scripts\Export-API.ps1` script to update the public API listing. This will generate a file in the library's directory similar to the example found in [sdk\template\Azure.Template\api\Azure.Template.netstandard2.0.cs](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template/api/Azure.Template.netstandard2.0.cs).
0 commit comments