0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

.Net 6.0.0 Preview 2 を Visual Studio Code から Docker 利用してみた

Posted at

背景と目的

.Net 6.0.0 Preview 2 を使ってみたいが、ローカル環境を汚したくない。

Microsoft が公開している Docker イメージに .Net 6.0 Preview タグがついているものがあったので、これを Visual Studio Code から利用する。

前提条件

実施環境は、Mac + Visual Studio Code + Docker Desktop です。

zsh
% sw_vers
ProductName:    macOS
ProductVersion: 11.2.3
BuildVersion:   20D91

% code --version
1.54.2
fd6f3bce6709b121a895d042d343d71f317d74e7
arm64

% docker --version
Docker version 20.10.3, build 48d30b5

実施内容

vscode-dev-containers を参考に必要なファイルをダウンロードする。

zsh
% mkdir -p dotnet6/.devcontainer/library-scripts
% cd dotnet6 
% curl -s https://raw.githubusercontent.com/microsoft/vscode-dev-containers/master/containers/dotnet/.devcontainer/base.Dockerfile \
  -o .devcontainer/Dockerfile
% curl -s https://raw.githubusercontent.com/microsoft/vscode-dev-containers/master/containers/dotnet/.devcontainer/devcontainer.json \
  -o .devcontainer/devcontainer.json
% curl -s https://raw.githubusercontent.com/microsoft/vscode-dev-containers/master/containers/dotnet/.devcontainer/library-scripts/common-debian.sh \
  -o .devcontainer/library-scripts/common-debian.sh
% curl -s https://raw.githubusercontent.com/microsoft/vscode-dev-containers/master/containers/dotnet/.devcontainer/library-scripts/node-debian.sh \
  -o .devcontainer/library-scripts/node-debian.sh
% curl -s https://raw.githubusercontent.com/microsoft/vscode-dev-containers/master/containers/dotnet/.devcontainer/library-scripts/azcli-debian.sh \
  -o .devcontainer/library-scripts/azcli-debian.sh

Docker イメージのバージョンを「 6.0 」に変更する。

zsh
% sed -ie 's/"VARIANT": "5.0"/"VARIANT": "6.0"/g' \
  .devcontainer/devcontainer.json

Visual Studio Code の command + shift + p で「 Remote-Containers: Open Folder in Container... 」から、先ほど作成した dotnet6 フォルダを選択すると Docker イメージの作成が始まる。

実施結果

Docker イメージが自動的に起動されたら、Visual Studio Code のターミナルを開いて dotnet --info を実行し、「 .Net 6.0.0 Preview 2 」環境を確認する。

bash
vscode ➜ /workspaces/dotnet6 $ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100-preview.2.21155.3
 Commit:    1a9103db2d

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.04
 OS Platform: Linux
 RID:         ubuntu.20.04-arm64
 Base Path:   /usr/share/dotnet/sdk/6.0.100-preview.2.21155.3/

Host (useful for support):
  Version: 6.0.0-preview.2.21154.6
  Commit:  3eaf1f316b

.NET SDKs installed:
  6.0.100-preview.2.21155.3 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0-preview.2.21154.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0-preview.2.21154.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

参考

Official images for the .NET SDK

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?