Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit db512a8

Browse files
authored
Merge pull request #120 from adamralph/dotnetcore-2.2
add dotnetcore-2.2 container
2 parents d012802 + 763ccbf commit db512a8

File tree

9 files changed

+223
-0
lines changed

9 files changed

+223
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#-------------------------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
4+
#-------------------------------------------------------------------------------------------------------------
5+
6+
FROM mcr.microsoft.com/dotnet/core/sdk:2.2
7+
8+
# Avoid warnings by switching to noninteractive
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux,
12+
# this user's GID/UID must match your local user UID/GID to avoid permission issues
13+
# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See
14+
# https://aka.ms/vscode-remote/containers/non-root-user for details.
15+
ARG USERNAME=vscode
16+
ARG USER_UID=1000
17+
ARG USER_GID=$USER_UID
18+
19+
# Configure apt and install packages
20+
RUN apt-get update \
21+
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
22+
#
23+
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
24+
&& apt-get -y install git iproute2 procps lsb-release \
25+
#
26+
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
27+
&& groupadd --gid $USER_GID $USERNAME \
28+
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
29+
# [Optional] Add sudo support for the non-root user
30+
&& apt-get install -y sudo \
31+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
32+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
33+
#
34+
# Clean up
35+
&& apt-get autoremove -y \
36+
&& apt-get clean -y \
37+
&& rm -rf /var/lib/apt/lists/*
38+
39+
# Switch back to dialog for any ad-hoc use of apt-get
40+
ENV DEBIAN_FRONTEND=
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "C# (.NET Core 2.2)",
3+
"dockerFile": "Dockerfile",
4+
5+
// Uncomment the next line if you want to publish any ports.
6+
// "appPort": [],
7+
8+
// Uncomment the next line if you want to add in default container specific settings.json values
9+
// "settings": { "workbench.colorTheme": "Quiet Light" },
10+
11+
// Uncomment the next line to run commands after the container is created.
12+
// "postCreateCommand": "dotnet restore"
13+
14+
// Uncomment the next line to use a non-root user. On Linux, this will prevent
15+
// new files getting created as root, but you may need to update the USER_UID
16+
// and USER_GID in .devcontainer/Dockerfile to match your user if not 1000.
17+
// "runArgs": [ "-u", "vscode" ],
18+
19+
"extensions": [
20+
"ms-vscode.csharp"
21+
]
22+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
README.md
2+
test-project
3+
.vscode
4+
.npmignore
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": ".NET Core Launch (web)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"program": "dotnet",
12+
"args": ["run"],
13+
"cwd": "${workspaceFolder}/test-project",
14+
}
15+
]
16+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"razor.disabled": true
3+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/test-project/aspnetapp.csproj"
11+
],
12+
"problemMatcher": "$tsc"
13+
},
14+
{
15+
"label": "publish",
16+
"command": "dotnet",
17+
"type": "process",
18+
"args": [
19+
"publish",
20+
"${workspaceFolder}/test-project/aspnetapp.csproj"
21+
],
22+
"problemMatcher": "$tsc"
23+
},
24+
{
25+
"label": "watch",
26+
"command": "dotnet",
27+
"type": "process",
28+
"args": [
29+
"watch",
30+
"run",
31+
"${workspaceFolder}/test-project/aspnetapp.csproj"
32+
],
33+
"problemMatcher": "$tsc"
34+
}
35+
]
36+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# C# (.NET Core 2.2)
2+
3+
## Summary
4+
5+
*Develop C# and .NET Core 2.2 based applications. Includes all needed SDKs, extensions, and dependencies.*
6+
7+
| Metadata | Value |
8+
|----------|-------|
9+
| *Contributors* | The VS Code Team |
10+
| *Definition type* | Dockerfile |
11+
| *Languages, platforms* | .NET Core, C# |
12+
13+
## Using this definition with an existing folder
14+
15+
Note that only the integrated terminal is supported by the Remote - Containers extension. You may need to modify `launch.json` configurations to include the following value if an external console is used.
16+
17+
```json
18+
"console": "integratedTerminal"
19+
```
20+
21+
Beyond that, just follow these steps to use the definition:
22+
23+
1. If this is your first time using a development container, please follow the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started) to set up your machine.
24+
25+
2. To use VS Code's copy of this definition:
26+
1. Start VS Code and open your project folder.
27+
2. Press <kbd>F1</kbd> select and **Remote-Containers: Add Development Container Configuration Files...** from the command palette.
28+
3. Select the C# (.NET Core 2.2) definition.
29+
30+
3. To use latest-and-greatest copy of this definition from the repository:
31+
1. Clone this repository.
32+
2. Copy the contents of `containers/dotnetcore-2.2/.devcontainer` to the root of your project folder.
33+
3. Start VS Code and open your project folder.
34+
35+
4. After following step 2 or 3, the contents of the `.devcontainer` folder in your project can be adapted to meet your needs.
36+
37+
5. Finally, press <kbd>F1</kbd> and run **Remote-Containers: Reopen Folder in Container** to start using the definition.
38+
39+
## Testing the definition
40+
41+
This definition includes some test code that will help you verify it is working as expected on your system. Follow these steps:
42+
43+
1. If this is your first time using a development container, please follow the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started) to set up your machine.
44+
2. Clone this repository.
45+
3. Start VS Code, press <kbd>F1</kbd>, and select **Remote-Containers: Open Folder in Container...**
46+
4. Select the `containers/dotnetcore-2.2` folder.
47+
5. After the folder has opened in the container, if prompted to restore packages in a notification, click "Restore".
48+
6. After packages are restored, press <kbd>F5</kbd> to start the project.
49+
7. Once the project is running, press <kbd>F1</kbd> and select **Remote-Containers: Forward Port from Container...**
50+
8. Select port 8090 and click the "Open Browser" button in the notification that appears.
51+
9. You should see "Hello remote world from ASP.NET Core!" after the page loads.
52+
10. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing.
53+
54+
## License
55+
56+
Copyright (c) Microsoft Corporation. All rights reserved.
57+
58+
Licensed under the MIT License. See [LICENSE](https://github.com/Microsoft/vscode-dev-containers/blob/master/LICENSE).
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*-------------------------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
4+
*-------------------------------------------------------------------------------------------------------------*/
5+
6+
using System;
7+
using System.Linq;
8+
using Microsoft.AspNetCore.Hosting;
9+
using Microsoft.AspNetCore.Builder;
10+
using Newtonsoft.Json;
11+
using Microsoft.AspNetCore.Http;
12+
using System.IO;
13+
14+
namespace aspnetapp
15+
{
16+
public class Program
17+
{
18+
public static void Main(string[] args)
19+
{
20+
var host = new WebHostBuilder()
21+
.UseKestrel()
22+
.UseUrls("http://0.0.0.0:8090")
23+
.Configure(app => app.Run(async context => {
24+
await context.Response.WriteAsync("Hello remote world from ASP.NET Core!");
25+
}))
26+
.Build();
27+
28+
host.Run();
29+
}
30+
31+
}
32+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<UserSecretsId>31051026529000467138</UserSecretsId>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Microsoft.AspNetCore.App" />
10+
</ItemGroup>
11+
12+
</Project>

0 commit comments

Comments
 (0)