Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update process doc #3138

Merged
merged 5 commits into from
Feb 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,33 @@ This document contains some additional [technical details](https://github.com/Az

When the automatic PR is created for azure-sdk-for-net if there are any issues found all other changes to autorest.csharp are blocked until those issues are resolved. This means we should be certain that the changes we are making create the expected result in azure-sdk-for-net prior to merging our PR. In time we should build this into the autorest.csharp CI such that it happens automatically, but in the meantime a few manual steps can help avoid any delays.

- Use `dotnet pack /p:OfficialBuildId=yyyyMMdd.100` to package up a version of the generator
- Run `dotnet pack /p:OfficialBuildId=yyyyMMdd.100` at the root directory of this repository to package up a version of the generator
- Since there can be real versions with the same date starting at `.100` can ensure no conflicts with official builds.
- This will place a nupkg file at this location `[RepoRoot]\artifacts\packages\Debug`
- Edit the nuget configuration file [here](https://github.com/Azure/azure-sdk-for-net/blob/main/NuGet.Config) to have a new source `<add key="DEBUG" value="[RepoRoot]\artifacts\packages\Debug" />`
- This is not intended to be checked in but is a temporary change so `dotnet restore` can find the package
- Update the [Packages.Data.props](https://github.com/Azure/azure-sdk-for-net/blob/main/eng/Packages.Data.props#L156) file to have Microsoft.Azure.AutoRest.Csharp use the new local version you created in step 1
- This is not intended to be checked in but is a temporary change so `dotnet restore` can find the package
- If your generator PR needs to apply to typespec/cadl projects, or your generator PR changes anything in our emitter (the `src\CADL.Extension\Emitter.Csharp` project), you will need to
1. Update the `version` in `src\CADL.Extension\Emitter.Csharp\package.json`
2. Run `npm pack` command in `src\CADL.Extension\Emitter.Csharp` directory. This will produce a pack like `src\CADL.Extension\Emitter.Csharp\azure-tools-cadl-csharp-x.y.z.tgz` where `x.y.z` is the version number you set in step 1.
3. Change the emitter version used in our `azure-sdk-for-net` repo in this file `eng\emitter-package.json` like this:
```diff
{
"main": "dist/src/index.js",
"dependencies": {
- "@azure-tools/cadl-csharp": "0.1.11-beta.20230212.4"
+ "@azure-tools/cadl-csharp": "/absolute/path/to/src/CADL.Extension/Emitter.Csharp/azure-tools-cadl-csharp-x.y.z.tgz"
}
}
```
4. Locate the `dll` file generated for the generator, usually it could be found `autorest.csharp` repository in this directory: `artifacts\bin\AutoRest.CSharp\Debug\net6.0\AutoRest.CSharp.dll`
5. Go to [this file](https://github.com/Azure/azure-sdk-for-net/blob/285cbdc343f01774b2b33e758662222bc8a3a33b/eng/common/scripts/Cadl-Project-Generate.ps1#L80) in your local `azure-sdk-for-net` repository, and change it like this by appending a new option to the emitter invocation:
```diff
-$cadlCompileCommand = "npx cadl compile $mainCadlFile --emit $emitterName$emitterAdditionalOptions"
ArcturusZhang marked this conversation as resolved.
Show resolved Hide resolved
+$cadlCompileCommand = "npx cadl compile $mainCadlFile --emit $emitterName$emitterAdditionalOptions --option @azure-tools/cadl-csharp.csharpGeneratorPath=/absolute/path/to/artifacts/bin/AutoRest.CSharp/Debug/net6.0/AutoRest.CSharp.dll"
```
This process right now is complicated, and the improvement is tracking in [this issue](https://github.com/Azure/azure-sdk-for-net/issues/34357).
- At this point there are several ways to generate but the idea is to generate and test all projects that will be affected by your PR. There are tools such as [this](https://github.com/ArcturusZhang/Regen) which are written to handle specific cases. If you are unsure you should run against all projects to be safe.

To regen and test everything in azure-sdk-for-net after you have updated to use your new local build do the following:
Expand Down Expand Up @@ -114,7 +134,7 @@ When the autorest.csharp PR gets merged there will be an automatic azure-sdk-for
- If there were no conflicts or after they are resolved push the changes to your branch and you can then merge the PR that was previous approved or re-approved in the case of conflicts.
- The autogenerated PR can now simply be closed

## Use in `azure-sdk-net` repo
## Use in `azure-sdk-for-net` repo

Run `dotnet build /t:GenerateCode` in the directory that contains your `.csproj` file.

Expand Down