Skip to content
Merged
Show file tree
Hide file tree
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
36 changes: 36 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/base:bullseye

# Install .NET SDK 2.1
RUN apt-get update \
&& apt-get install -y wget curl git \
&& wget https://dot.net/v1/dotnet-install.sh -O /tmp/dotnet-install.sh \
&& chmod +x /tmp/dotnet-install.sh \
&& /tmp/dotnet-install.sh --channel 2.1 --install-dir /usr/share/dotnet \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/*.sh

# Set up nvs (Node Version Switcher) for vscode user
ARG USERNAME=vscode
USER ${USERNAME}
ENV NVS_HOME="/home/${USERNAME}/.nvs"

# Install nvs and Node.js 20.19.0
RUN git clone https://github.com/jasongin/nvs "${NVS_HOME}" \
&& . "${NVS_HOME}/nvs.sh" install \
&& nvs add 20.19.0 \
&& nvs use 20.19.0 \
&& nvs link 20.19.0

# Install Rush and AutoRest globally
RUN . "${NVS_HOME}/nvs.sh" \
&& npm install -g @microsoft/[email protected] \
&& npm install -g autorest@latest

# Add nvs to shell profiles
RUN echo 'export NVS_HOME="$HOME/.nvs"' >> ~/.bashrc \
&& echo '[ -s "$NVS_HOME/nvs.sh" ] && . "$NVS_HOME/nvs.sh"' >> ~/.bashrc \
&& echo 'export NVS_HOME="$HOME/.nvs"' >> ~/.zshrc \
&& echo '[ -s "$NVS_HOME/nvs.sh" ] && . "$NVS_HOME/nvs.sh"' >> ~/.zshrc

USER root
21 changes: 21 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "AutoRest PowerShell",
"build": {
"context": "..",
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/powershell:1": {
"version": "latest"
}
},
"postCreateCommand": "bash .devcontainer/postcreate.sh",
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.powershell",
"dbaeumer.vscode-eslint"
]
}
}
}
15 changes: 15 additions & 0 deletions .devcontainer/postcreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e

echo "Dev container setup complete!"
echo ""
echo "Installed versions:"
echo " Node: $(node -v 2>/dev/null || echo 'Run: source ~/.bashrc')"
echo " npm: $(npm -v 2>/dev/null || echo 'Run: source ~/.bashrc')"
echo " Rush: $(rush --version 2>/dev/null | head -n1 || echo 'Run: source ~/.bashrc')"
echo " .NET: $(dotnet --version)"
echo " PowerShell: $(pwsh -v)"
echo ""
echo "If node/npm/rush are not found, run: source ~/.bashrc"
echo ""
echo "Ready to build: rush sync-versions && rush update && rush rebuild"
51 changes: 41 additions & 10 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# AutoRest PowerShell Generator - Development

## Getting Started with Dev Containers (Recommended)

The easiest way to get started is using the provided Dev Container configuration, which automatically sets up all required tools and dependencies.

### Prerequisites
- [Docker](https://www.docker.com/get-started) or [Podman](https://podman.io/)
- [Visual Studio Code](https://code.visualstudio.com/) with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)

### Setup
1. Clone the repository:
```powershell
git clone https://github.com/azure/autorest.powershell
cd autorest.powershell
```

2. Open in VS Code and reopen in container:
- Open the folder in VS Code
- When prompted, click "Reopen in Container" (or press `F1` and select "Dev Containers: Reopen in Container")
- Wait for the container to build and initialize (this may take a few minutes on first run)

3. Once the container is ready, all tools are pre-installed and configured:
- Node.js 20.19.0
- Rush 5.112.2
- PowerShell 7.5+
- .NET SDK 2.1

4. Build the project:
```powershell
rush update
rush rebuild
```

## Requirements

Use of this project requires the following:
Expand All @@ -14,7 +46,7 @@ Use of this project requires the following:

## Cloning this repository

``` powershell
```powershell
# clone recursively
git clone https://github.com/azure/autorest.powershell

Expand All @@ -27,14 +59,14 @@ npm install

This repository is built as a 'monorepo' using [RushJS](https://rushjs.io/) - which manages multiple nodejs projects in a single repository.

``` powershell
```powershell
# install nodejs modules for all projects in the monorepo
rush update
```

Rush is used to make sure that package versions are consistent between sub-projects

``` powershell
```powershell
# ensure all projects are using the same versions
rush sync-versions

Expand All @@ -46,15 +78,15 @@ rush update

Rush is used to build `autorest.powershell`

``` powershell
```powershell
# build everything
rush rebuild
```

You can use `watch` to compile when a file is changed, which will rebuild dependencies automatically.
Just kill the process with ctrl-c to stop it.

``` powershell
```powershell
# start watching
rush watch
```
Expand All @@ -63,15 +95,14 @@ rush watch

To use the locally built version of the plugin, add `--use:<path>` to the command line

``` powershell
# using a local build
> autorest --use:c:/work/autorest.powershell <...arguments>

```powershell
# using a local build (adjust path for your platform)
autorest --use:/path/to/autorest.powershell <...arguments>
```

### Debugging

1. Start generating: `autorest --use:C:\path\to\local\autorest.powershell --powershell.debugger`. It will wait for debugger to attach.
1. Start generating: `autorest --use:/path/to/local/autorest.powershell --powershell.debugger`. It will wait for debugger to attach.
1. Start debugging: open autorest.powershell repo in vscode; press `F5`. You will see "Debugger attached." in your autorest console, then you can start debugging.

### Testing
Expand Down
Loading