Skip to content

Commit 957a274

Browse files
committed
introduced devcontainers for cross-platform development
1 parent e0e2ccb commit 957a274

File tree

4 files changed

+112
-10
lines changed

4 files changed

+112
-10
lines changed

.devcontainer/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM mcr.microsoft.com/devcontainers/base:bullseye
2+
3+
# Install .NET SDK 2.1
4+
RUN apt-get update \
5+
&& apt-get install -y wget curl git \
6+
&& wget https://dot.net/v1/dotnet-install.sh -O /tmp/dotnet-install.sh \
7+
&& chmod +x /tmp/dotnet-install.sh \
8+
&& /tmp/dotnet-install.sh --channel 2.1 --install-dir /usr/share/dotnet \
9+
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
10+
&& apt-get clean \
11+
&& rm -rf /var/lib/apt/lists/* /tmp/*.sh
12+
13+
# Set up nvs (Node Version Switcher) for vscode user
14+
ARG USERNAME=vscode
15+
USER ${USERNAME}
16+
ENV NVS_HOME="/home/${USERNAME}/.nvs"
17+
18+
# Install nvs and Node.js 20.19.0
19+
RUN git clone https://github.com/jasongin/nvs "${NVS_HOME}" \
20+
&& . "${NVS_HOME}/nvs.sh" install \
21+
&& nvs add 20.19.0 \
22+
&& nvs use 20.19.0 \
23+
&& nvs link 20.19.0
24+
25+
# Install Rush globally
26+
RUN . "${NVS_HOME}/nvs.sh" \
27+
&& npm install -g @microsoft/[email protected]
28+
29+
# Add nvs to shell profiles
30+
RUN echo 'export NVS_HOME="$HOME/.nvs"' >> ~/.bashrc \
31+
&& echo '[ -s "$NVS_HOME/nvs.sh" ] && . "$NVS_HOME/nvs.sh"' >> ~/.bashrc \
32+
&& echo 'export NVS_HOME="$HOME/.nvs"' >> ~/.zshrc \
33+
&& echo '[ -s "$NVS_HOME/nvs.sh" ] && . "$NVS_HOME/nvs.sh"' >> ~/.zshrc
34+
35+
USER root

.devcontainer/devcontainer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "AutoRest PowerShell",
3+
"build": {
4+
"context": "..",
5+
"dockerfile": "Dockerfile"
6+
},
7+
"features": {
8+
"ghcr.io/devcontainers/features/powershell:1": {
9+
"version": "latest"
10+
}
11+
},
12+
"postCreateCommand": "bash .devcontainer/postcreate.sh",
13+
"customizations": {
14+
"vscode": {
15+
"extensions": [
16+
"ms-vscode.powershell",
17+
"dbaeumer.vscode-eslint"
18+
]
19+
}
20+
}
21+
}

.devcontainer/postcreate.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Dev container setup complete!"
5+
echo ""
6+
echo "Installed versions:"
7+
echo " Node: $(node -v 2>/dev/null || echo 'Run: source ~/.bashrc')"
8+
echo " npm: $(npm -v 2>/dev/null || echo 'Run: source ~/.bashrc')"
9+
echo " Rush: $(rush --version 2>/dev/null | head -n1 || echo 'Run: source ~/.bashrc')"
10+
echo " .NET: $(dotnet --version)"
11+
echo " PowerShell: $(pwsh -v)"
12+
echo ""
13+
echo "If node/npm/rush are not found, run: source ~/.bashrc"
14+
echo ""
15+
echo "Ready to build: rush sync-versions && rush update && rush rebuild"

docs/development.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
# AutoRest PowerShell Generator - Development
22

3+
## Getting Started with Dev Containers (Recommended)
4+
5+
The easiest way to get started is using the provided Dev Container configuration, which automatically sets up all required tools and dependencies.
6+
7+
### Prerequisites
8+
- [Docker](https://www.docker.com/get-started) or [Podman](https://podman.io/)
9+
- [Visual Studio Code](https://code.visualstudio.com/) with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
10+
11+
### Setup
12+
1. Clone the repository:
13+
```powershell
14+
git clone https://github.com/azure/autorest.powershell
15+
cd autorest.powershell
16+
```
17+
18+
2. Open in VS Code and reopen in container:
19+
- Open the folder in VS Code
20+
- When prompted, click "Reopen in Container" (or press `F1` and select "Dev Containers: Reopen in Container")
21+
- Wait for the container to build and initialize (this may take a few minutes on first run)
22+
23+
3. Once the container is ready, all tools are pre-installed and configured:
24+
- Node.js 20.19.0
25+
- Rush 5.112.2
26+
- PowerShell 7.5+
27+
- .NET SDK 2.1
28+
29+
4. Build the project:
30+
```powershell
31+
rush update
32+
rush rebuild
33+
```
34+
335
## Requirements
436

537
Use of this project requires the following:
@@ -14,7 +46,7 @@ Use of this project requires the following:
1446

1547
## Cloning this repository
1648

17-
``` powershell
49+
```powershell
1850
# clone recursively
1951
git clone https://github.com/azure/autorest.powershell
2052
@@ -27,14 +59,14 @@ npm install
2759

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

30-
``` powershell
62+
```powershell
3163
# install nodejs modules for all projects in the monorepo
3264
rush update
3365
```
3466

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

37-
``` powershell
69+
```powershell
3870
# ensure all projects are using the same versions
3971
rush sync-versions
4072
@@ -46,15 +78,15 @@ rush update
4678

4779
Rush is used to build `autorest.powershell`
4880

49-
``` powershell
81+
```powershell
5082
# build everything
5183
rush rebuild
5284
```
5385

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

57-
``` powershell
89+
```powershell
5890
# start watching
5991
rush watch
6092
```
@@ -63,15 +95,14 @@ rush watch
6395

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

66-
``` powershell
67-
# using a local build
68-
> autorest --use:c:/work/autorest.powershell <...arguments>
69-
98+
```powershell
99+
# using a local build (adjust path for your platform)
100+
autorest --use:/path/to/autorest.powershell <...arguments>
70101
```
71102

72103
### Debugging
73104

74-
1. Start generating: `autorest --use:C:\path\to\local\autorest.powershell --powershell.debugger`. It will wait for debugger to attach.
105+
1. Start generating: `autorest --use:/path/to/local/autorest.powershell --powershell.debugger`. It will wait for debugger to attach.
75106
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.
76107

77108
### Testing

0 commit comments

Comments
 (0)