It's like a continuation of this article. Build a code-server with docker and try to create a C # environment there.
code-server_1 Create the following directory.
python
ls
> Dockerfile code-server docker-compose.yml projects
The Dockerfile and docker-compose.yml look like this. I'm using the official docker-image to install .net core there.
Dockerfile
FROM codercom/code-server:3.8.0
USER root
# Install wget and other module
RUN apt-get update && apt-get install -y \
wget
# Install code-server plugin
#* Extension install from command does not work?
RUN code-server --install-extension ms-dotnettools.csharp
# Install .NET5
ENV DOTNET_ROOT=/usr/share/dotnet
ENV PATH=/usr/share/dotnet:/root/.dotnet/tools:$PATH
#The following environment variables need to be changed
#Details 1: https://github.com/dotnet/core/issues/2186
#Details 2: https://github.com/dotnet/core/blob/master/Documentation/build-and-install-rhel6-prerequisites.md
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true
RUN wget -O dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/a0487784-534a-4912-a4dd-017382083865/be16057043a8f7b6f08c902dc48dd677/dotnet-sdk-5.0.101-linux-x64.tar.gz \
&& wget -O dotnet_runtime.tar.gz https://download.visualstudio.microsoft.com/download/pr/6bea1cea-89e8-4bf7-9fc1-f77380443db1/0fb741b7d587cce798ebee80732196ef/aspnetcore-runtime-5.0.1-linux-x64.tar.gz \
&& dotnet_sha512='398d88099d765b8f5b920a3a2607c2d2d8a946786c1a3e51e73af1e663f0ee770b2b624a630b1bec1ceed43628ea8bc97963ba6c870d42bec064bde1cd1c9edb' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& dotnet_runtime_sha512='fec655aed2e73288e84d940fd356b596e266a3e74c37d9006674c4f923fb7cde5eafe30b7dcb43251528166c02724df5856e7174f1a46fc33036b0f8db92688a' \
&& echo "$dotnet_runtime_sha512 dotnet_runtime.tar.gz" | sha512sum -c - \
&& mkdir -p "/usr/share/dotnet" \
&& mkdir -p "/usr/bin/dotnet" \
&& mkdir -p "/root/.dotnet/tools" \
&& tar zxf dotnet.tar.gz -C "/usr/share/dotnet" \
&& rm dotnet.tar.gz \
&& tar zxf dotnet_runtime.tar.gz -C "/usr/share/dotnet" \
&& rm dotnet_runtime.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& dotnet help
USER coder
docker-compose.yml
version: "3"
services:
code:
build:
context: .
dockerfile: Dockerfile
restart: always
environment:
PUID: 1000
PGID: 1000
PASSWORD: password
ports:
- 20000:8080
volumes:
- ./projects:/home/coder/project
- ./code-server:/home/coder/.local/share/code-server
start up.
docker-compose up -d --build
Access the URL.
I intend to add a C # extension with this command in the Dockerfile. Doesn't it seem like it's in? is. Even if I hit the command in the same way from the terminal, it was not reflected in the UI.
RUN code-server --install-extensions ms-dotnettools.csharp
There is no choice but to add the extension manually. I put in the three main ones.
Let's make a suitable project.
python
dotnet new console -o tutorial
ls
> Program.cs tutorial.csproj
Add files under the tutorial folder. There is an atmosphere that C # extensions can be used, but it did not generate a file.
Since there is no help for it, name it Calc.cs
in normal file creation.
Program.cs and Calc.cs should have the following contents.
Calc.cs
using System;
namespace tutorial2
{
class Calc
{
public static double Add(double a, double b)
{
return a + b;
}
}
}
Program.cs
using System;
using tutorial2;
namespace tutorial
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var ret = Calc.Add(1, 3);
Console.WriteLine($"Cal Result is {ret}");
}
}
}
Try running it from the terminal. I was able to execute it.
How about debugging? Specify .Net Core Launch in launch.json, set a breakpoint and execute it.
??? The following error is displayed in DEBUG CONSOLE.
Looking at this URL, it seems that the debugger is licensed so that it only works with Microsoft's IDE. It is also mentioned in issue on code-server Original debugger? seems to be the only way to do it. .. .. The issue was also closed because the standard debugger could not be used due to licensing issues.
code-server_2
Volunteers made it by putting DotNetCore in linuxserver/code-server
There was image, so I'll put that as well.
git clone https://github.com/ptr727/VSCode-Server-DotNetCore.git
cd VSCode-Server-DotnetCore
docker-compose up -d #Start-up
cloud9 As a bonus, I will try it on cloud9.
The Dockerfile and docker-compose.yml look like this.
I tried to put DotNetCore in linuxserver/cloud9
.
Dockerfile
FROM linuxserver/cloud9:version-1.27.4
RUN mkdir -p /code/projects
# Install wget
RUN apt-get update \
# Install wget
&& apt-get install -y wget
# Install .NET5
ENV DOTNET_ROOT=/usr/share/dotnet
ENV PATH=/usr/share/dotnet:/root/.dotnet/tools:$PATH
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true
RUN wget -O dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/a0487784-534a-4912-a4dd-017382083865/be16057043a8f7b6f08c902dc48dd677/dotnet-sdk-5.0.101-linux-x64.tar.gz \
&& wget -O dotnet_runtime.tar.gz https://download.visualstudio.microsoft.com/download/pr/6bea1cea-89e8-4bf7-9fc1-f77380443db1/0fb741b7d587cce798ebee80732196ef/aspnetcore-runtime-5.0.1-linux-x64.tar.gz \
&& dotnet_sha512='398d88099d765b8f5b920a3a2607c2d2d8a946786c1a3e51e73af1e663f0ee770b2b624a630b1bec1ceed43628ea8bc97963ba6c870d42bec064bde1cd1c9edb' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& dotnet_runtime_sha512='fec655aed2e73288e84d940fd356b596e266a3e74c37d9006674c4f923fb7cde5eafe30b7dcb43251528166c02724df5856e7174f1a46fc33036b0f8db92688a' \
&& echo "$dotnet_runtime_sha512 dotnet_runtime.tar.gz" | sha512sum -c - \
&& mkdir -p "/usr/share/dotnet" \
&& mkdir -p "/usr/bin/dotnet" \
&& mkdir -p "/root/.dotnet/tools" \
&& tar zxf dotnet.tar.gz -C "/usr/share/dotnet" \
&& rm dotnet.tar.gz \
&& tar zxf dotnet_runtime.tar.gz -C "/usr/share/dotnet" \
&& rm dotnet_runtime.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
&& dotnet help
docker-compose.yml
version: "3"
services:
code:
build:
context: .
dockerfile: Dockerfile
restart: always
environment:
- PUID=1000
- PGID=1000
- TZ=Asia/Tokyo
- GITURL=https://github.com/linuxserver/docker-cloud9.git #optional
- USERNAME=user #optional
- PASSWORD=password #optional
ports:
- 50000:8000
volumes:
- ./projects:/code/projects
- ./docker.sock:/var/run/docker.sock #optional
Access the URL.
Like code-server, create a suitable project from the terminal and try it.
I will omit it, but like code-server, I was able to do dotnet run
properly.
cloud9 is good because it has good intellisense and history.
How about debugging? I could set a breakpoint, but I gave up because I didn't know how to make a Runner. .. .. It seems that AWS Cloud9 can do it, but what about this one?
I think the web-ide itself is useful and convenient I got the impression that full-scale development is still difficult because peripheral knowledge is required even after construction and extension functions do not work well. I think it can be done by a higher level person, but I'm a little. .. .. At present, is it safe to develop C # quietly in windows + visual studio? However, there are articles such as python on docker + code-server or cloud9, so can I use it without problems? When I felt like it, I wanted to try it with python + α.
Recommended Posts