WSL上での.NET Core開発
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
「[[マイクロソフト系技術情報 Wiki>http://techinfoofmicros...
-戻る
--[[Windows Subsystem for Linux]]
--[[.NET Coreの開発]]
--[[ASP.NET Coreの開発]]
* 目次 [#rdb7338f]
#contents
*概要 [#ua00ab1b]
-[[WSL>Windows Subsystem for Linux]]を使用した、[[.NET Co...
-手軽に動作確認を行うなどの用途では、WSLは非常に便利だと...
-ただし、所詮、エミュレーションなので、実機確認を行う場合...
*準備 [#iba2e597]
**WSL [#y54441e3]
***インストール [#r78a3a71]
[[コチラ>Windows Subsystem for Linux#o393cbb1]]を参照。
***設定 [#kacd3cc0]
-hostname : nishino
-username : seigi
-username@hostname : seigi@nishino
Installing, this may take a few minutes...
Installation successful!
Please create a default UNIX user account. The username ...
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: seigi
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Default UNIX user set to: seigi
To run a command as administrator (user "root"), use "su...
See "man sudo_root" for details.
**dotnet [#hcb1de96]
***2.n [#vb66787e]
sudo apt-get update
sudo apt-get install openssh-server unzip curl
curl https://packages.microsoft.com/keys/microsoft.asc |...
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.micr...
sudo apt-get update
sudo apt-get install dotnet-sdk-2.n
dotnet --version
***3.n [#o319f285]
...
**[[.NET Coreの開発]] [#d6efbd4a]
-[[Windows上で開発して>.NET Coreの開発]]
-[[検証手順>.NET Coreのデプロイ#fbabb769]]と同様に、WSL上...
***dotnet new [#v014f0f4]
dotnet new コマンドを使用した、テンプレート準備とビルド・...
seigi@nishino:~$ curl https://packages.microsoft.com/key...
% Total % Received % Xferd Average Speed Time ...
Dload Upload Total ...
100 983 100 983 0 0 319 0 0:00:03 ...
seigi@nishino:~$ sudo mv microsoft.gpg /etc/apt/trusted....
[sudo] password for seigi:
seigi@nishino:~$ sudo sh -c 'echo "deb [arch=amd64] http...
seigi@nishino:~$ sudo apt-get update
Get:1 http://security.ubuntu.com/ubuntu xenial-security ...
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:3 https://packages.microsoft.com/repos/microsoft-ubu...
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates In...
Get:5 http://archive.ubuntu.com/ubuntu xenial-backports ...
Get:6 http://archive.ubuntu.com/ubuntu xenial/universe a...
Get:7 https://packages.microsoft.com/repos/microsoft-ubu...
Get:8 http://security.ubuntu.com/ubuntu xenial-security/...
Get:9 http://security.ubuntu.com/ubuntu xenial-security/...
Get:10 http://security.ubuntu.com/ubuntu xenial-security...
Get:11 http://security.ubuntu.com/ubuntu xenial-security...
Get:12 http://security.ubuntu.com/ubuntu xenial-security...
Get:13 http://archive.ubuntu.com/ubuntu xenial/universe ...
Get:14 http://security.ubuntu.com/ubuntu xenial-security...
Get:15 http://security.ubuntu.com/ubuntu xenial-security...
Get:16 http://security.ubuntu.com/ubuntu xenial-security...
Get:17 http://archive.ubuntu.com/ubuntu xenial/multivers...
Get:18 http://archive.ubuntu.com/ubuntu xenial/multivers...
Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/m...
Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/m...
Get:21 http://archive.ubuntu.com/ubuntu xenial-updates/r...
Get:22 http://archive.ubuntu.com/ubuntu xenial-updates/r...
Get:23 http://archive.ubuntu.com/ubuntu xenial-updates/u...
Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/u...
Get:25 http://archive.ubuntu.com/ubuntu xenial-updates/m...
Get:26 http://archive.ubuntu.com/ubuntu xenial-updates/m...
Get:27 http://archive.ubuntu.com/ubuntu xenial-backports...
Get:28 http://archive.ubuntu.com/ubuntu xenial-backports...
Get:29 http://archive.ubuntu.com/ubuntu xenial-backports...
Get:30 http://archive.ubuntu.com/ubuntu xenial-backports...
Fetched 15.7 MB in 16s (944 kB/s)
Reading package lists... Done
seigi@nishino:~$ sudo apt-get install dotnet-sdk-2.0.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is...
libfreetype6
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
aspnetcore-store-2.0.0 dotnet-host dotnet-hostfxr-2.0....
liblttng-ust-ctl2 liblttng-ust0 libunwind8 liburcu4
The following NEW packages will be installed:
aspnetcore-store-2.0.0 dotnet-host dotnet-hostfxr-2.0....
dotnet-sdk-2.0.0 libcurl3 liblttng-ust-ctl2 liblttng-u...
0 upgraded, 11 newly installed, 0 to remove and 135 not ...
Need to get 108 MB of archives.
After this operation, 309 MB of additional disk space wi...
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu xenial/universe a...
Get:2 https://packages.microsoft.com/repos/microsoft-ubu...
Get:3 http://archive.ubuntu.com/ubuntu xenial/universe a...
Get:4 http://archive.ubuntu.com/ubuntu xenial/universe a...
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/ma...
Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64...
Get:7 https://packages.microsoft.com/repos/microsoft-ubu...
Get:8 https://packages.microsoft.com/repos/microsoft-ubu...
Get:9 https://packages.microsoft.com/repos/microsoft-ubu...
Get:10 https://packages.microsoft.com/repos/microsoft-ub...
Get:11 https://packages.microsoft.com/repos/microsoft-ub...
Fetched 108 MB in 1min 39s (1,078 kB/s)
Selecting previously unselected package aspnetcore-store...
(Reading database ... 25532 files and directories curren...
Preparing to unpack .../aspnetcore-store-2.0.0_2.0.0-1_a...
Unpacking aspnetcore-store-2.0.0 (2.0.0-1) ...
Selecting previously unselected package liburcu4:amd64.
Preparing to unpack .../liburcu4_0.9.1-3_amd64.deb ...
Unpacking liburcu4:amd64 (0.9.1-3) ...
Selecting previously unselected package liblttng-ust-ctl...
Preparing to unpack .../liblttng-ust-ctl2_2.7.1-1_amd64....
Unpacking liblttng-ust-ctl2:amd64 (2.7.1-1) ...
Selecting previously unselected package liblttng-ust0:am...
Preparing to unpack .../liblttng-ust0_2.7.1-1_amd64.deb ...
Unpacking liblttng-ust0:amd64 (2.7.1-1) ...
Selecting previously unselected package dotnet-runtime-d...
Preparing to unpack .../dotnet-runtime-deps-2.1.0-rc1_2....
Unpacking dotnet-runtime-deps-2.1.0-rc1 (2.1.0-rc1-1) ...
Selecting previously unselected package dotnet-host.
Preparing to unpack .../dotnet-host_2.1.0-rc1-1_amd64.de...
Unpacking dotnet-host (2.1.0-rc1-1) ...
Selecting previously unselected package dotnet-hostfxr-2...
Preparing to unpack .../dotnet-hostfxr-2.0.0_2.0.0-1_amd...
Unpacking dotnet-hostfxr-2.0.0 (2.0.0-1) ...
Selecting previously unselected package libcurl3:amd64.
Preparing to unpack .../libcurl3_7.47.0-1ubuntu2.7_amd64...
Unpacking libcurl3:amd64 (7.47.0-1ubuntu2.7) ...
Selecting previously unselected package libunwind8.
Preparing to unpack .../libunwind8_1.1-4.1_amd64.deb ...
Unpacking libunwind8 (1.1-4.1) ...
Selecting previously unselected package dotnet-runtime-2...
Preparing to unpack .../dotnet-runtime-2.0.0_2.0.0-1_amd...
Unpacking dotnet-runtime-2.0.0 (2.0.0-1) ...
Selecting previously unselected package dotnet-sdk-2.0.0.
Preparing to unpack .../dotnet-sdk-2.0.0_2.0.0-1_amd64.d...
Unpacking dotnet-sdk-2.0.0 (2.0.0-1) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up aspnetcore-store-2.0.0 (2.0.0-1) ...
Setting up liburcu4:amd64 (0.9.1-3) ...
Setting up liblttng-ust-ctl2:amd64 (2.7.1-1) ...
Setting up liblttng-ust0:amd64 (2.7.1-1) ...
Setting up dotnet-runtime-deps-2.1.0-rc1 (2.1.0-rc1-1) ...
Setting up dotnet-host (2.1.0-rc1-1) ...
Setting up dotnet-hostfxr-2.0.0 (2.0.0-1) ...
Setting up libcurl3:amd64 (7.47.0-1ubuntu2.7) ...
Setting up libunwind8 (1.1-4.1) ...
Setting up dotnet-runtime-2.0.0 (2.0.0-1) ...
Setting up dotnet-sdk-2.0.0 (2.0.0-1) ...
This software may collect information about you and your...
Please visit http://aka.ms/dotnet-cli-eula for more info...
Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs....
.NET Core Tools Telemetry
--------------
The .NET Core Tools include a telemetry feature that col...
The data collected is anonymous and will be published in...
The .NET Core Tools telemetry feature is enabled by defa...
Installation Note
--------------
A command will be run during the install process that wi...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
seigi@nishino:~$ dotnet --version
2.0.0
seigi@nishino:~$ which dotnet
/usr/bin/dotnet
seigi@nishino:~$ dotnet new console
Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs....
Telemetry
--------------
The .NET Core tools collect usage data in order to impro...
You can opt out of telemetry by setting a DOTNET_CLI_TEL...
You can read more about .NET Core tools telemetry @ http...
Getting ready...
The template "Console Application" was created successfu...
Processing post-creation actions...
Running 'dotnet restore' on /home/seigi/seigi.csproj...
Restoring packages for /home/seigi/seigi.csproj...
Generating MSBuild file /home/seigi/obj/seigi.csproj.n...
Generating MSBuild file /home/seigi/obj/seigi.csproj.n...
Restore completed in 236.36 ms for /home/seigi/seigi.c...
Restore succeeded.
seigi@nishino:~$ dotnet publish -f netcoreapp2.0
Microsoft (R) Build Engine version 15.3.409.57025 for .N...
Copyright (C) Microsoft Corporation. All rights reserved.
seigi -> /home/seigi/bin/Debug/netcoreapp2.0/seigi.dll
seigi -> /home/seigi/bin/Debug/netcoreapp2.0/publish/
seigi@nishino:~$ dotnet /home/seigi/bin/Debug/netcoreapp...
Hello World!
seigi@nishino:~$
***dotnet publish [#zc5721da]
[[Visual Studio]]で作成したものを「/mnt/c」[[※ 1>#eefd5e3...
-ビルド(dotnet publish)
-実行([[dotnet *.dll>#ob2ac8a7]])
cd /mnt/c/ConsoleApp1/ConsoleApp1
dotnet publish -c Release -r ubuntu.16.04-x64 --self-con...
cd bin/Release/netcoreapp2.0/ubuntu.16.04-x64
dotnet ConsoleApp1.dll
Hello World!
※ [[SCD>.NET Coreのデプロイ#w88a1ee1]]
***dotnet *.dll [#ob2ac8a7]
[[Visual Studio]]で作成・ビルドしたものを「/mnt/c」[[※ 1>...
dotnet /mnt/c/ConsoleApp1/ConsoleApp1/bin/Debug/netcorea...
Hello World!
※ [[FDD>.NET Coreのデプロイ#yfb796bd1]]
**[[ASP.NET Coreの開発]] [#r6a90b09]
-[[Windows上で開発して>ASP.NET Coreの開発]]
-[[検証手順>ASP.NET Coreのデプロイ#ac95e514]]と同様に、WS...
***dotnet new [#ea9494e7]
dotnet new コマンドを使用した、準備と確認。
seigi@nishino:~$ dotnet new mvc
Creating this template will make changes to existing fil...
Overwrite seigi.csproj
Overwrite Program.cs
Rerun the command and pass --force to accept and create.
seigi@nishino:~$
seigi@nishino:~$ dotnet new mvc --force
The template "ASP.NET Core Web App (Model-View-Controlle...
This template contains technologies from parties other t...
Processing post-creation actions...
Running 'dotnet restore' on /home/seigi/seigi.csproj...
Restoring packages for /home/seigi/seigi.csproj...
Restoring packages for /home/seigi/seigi.csproj...
Restore completed in 2.09 sec for /home/seigi/seigi.cs...
Generating MSBuild file /home/seigi/obj/seigi.csproj.n...
Restore completed in 3.83 sec for /home/seigi/seigi.cs...
Restore succeeded.
seigi@nishino:~$ dotnet run
warn: Microsoft.AspNetCore.DataProtection.KeyManagement....
No XML encryptor configured. Key {89022286-2fdf-47...
Hosting environment: Production
Content root path: /home/seigi
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
^CApplication is shutting down...
seigi@nishino:~$
#ref(mvc1.png,left,nowrap,mvcの実行1,60%)
***dotnet publish [#v85949da]
[[同上>#zc5721da]]
***dotnet run [#y62ae3c4]
[[Visual Studio]]で作成・ビルドしたものを「/mnt/c」[[※ 1>...
seigi@nishino:~$ cd /mnt/c/WebApplication1/WebApplicatio...
seigi@nishino:/mnt/c/WebApplication1/WebApplication1$ do...
Using launch settings from /mnt/c/WebApplication1/WebApp...
info: Microsoft.AspNetCore.DataProtection.KeyManagement....
User profile is available. Using '/home/seigi/.asp...
Hosting environment: Development
Content root path: /mnt/c/WebApplication1/WebApplication1
Now listening on: http://localhost:53336
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Mvc.Internal.ControllerAction...
Executing action method WebApplication1.Controller...
info: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.Vie...
Executing ViewResult, running view at path /Views/...
info: Microsoft.AspNetCore.Mvc.Internal.ControllerAction...
Executed action WebApplication1.Controllers.HomeCo...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 7032.349ms 200 text/html; char...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/lib/jquery/dist/jque...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/css/site.css'. Physi...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/lib/bootstrap/dist/c...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 544.652ms 200 text/css
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 551.471ms 200 text/css
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 554.874ms 200 application/java...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/lib/bootstrap/dist/j...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/js/site.js'. Physica...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/images/banner1.svg'....
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 0.714ms 200 image/svg+xml
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 3.301ms 200 application/javasc...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/images/banner2.svg'....
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/images/banner3.svg'....
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 0.348ms 200 image/svg+xml
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 0.485ms 200 image/svg+xml
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 6.833ms 200 application/javasc...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/images/banner4.svg'....
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 1.35ms 200 image/svg+xml
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/lib/bootstrap/dist/f...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 0.757ms 200 font/woff2
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/favicon.ico'. Physic...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 1.081ms 200 image/x-icon
#ref(mvc2.png,left,nowrap,mvcの実行2,60%)
**OSバージョンの確認 [#j5258403]
以下のような感じ。
OperatingSystem os = Environment.OSVersion;
if (os.Platform == PlatformID.Win32NT)
{
・・・
*リモートデバッグ [#fd286380]
**C/C++ [#d81d6983]
***WSLのリモートデバッグ設定 [#o5abb403]
以下は、すべて、WSL(Ubuntu)上の設定。
-パッケージリストが古いと404になるので、以下を実行してか...
sudo apt-get update
-コンパイラー、リモートデバッガ、SSHサーバのインストール...
sudo apt install -y build-essential
sudo apt install -y gdbserver
sudo apt install -y openssh-server
-/etc/ssh/sshd_configファイルを編集
--「[[vi>https://dotnetdevelopmentinfrastructure.osscons....
sudo vi /etc/ssh/sshd_config
--パスワード認証を有効にする。
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes
-SSHの鍵を作成する
sudo ssh-keygen -A
-SSHサーバを起動する
sudo service ssh start
-SSHサーバの状態を確認する。
sudo service ssh status
***[[Visual Studio]]の設定 [#jb072390]
以下は、すべて、Windows上の設定。
-[[Visual Studio]] 2017のインストーラーで、~
[C++ による Linux 開発]コンポーネントにチェック
-[Visual C++]-[クロス プラットフォーム]-[Linux]を...
テンプレート一覧から「コンソール アプリケーション (Linux)...
-F5でデバッグ実行すると、WSLへの接続ダイアログが表示され...
--[Host name:]欄には「localhost」
--[User name:]欄と[Password]欄に(Ubuntuの)ユーザ / ...
--[Connect]ボタンをクリックしてWSLに接続。
-「gdbを起動できませんでした」と言うエラーが発生する場合、~
プロジェクトのプロパティの[デバッグ]→[デバッグ モード]を、~
gdb モードから、gdbserver モードへ、変更する。
**.NET Core [#hc8a9948]
仕組みとしては、
><Windows>~
[[Visual Studio]] → DebugAdapterHost → [[PuTTY]]~
~
↓ ↓ ↓(SSH)↑ ↑ ↑~
~
<Linux>~
openssh-server → vsdbg → dotnet (XXXX.dll)
みたいな感じで、
-debuggerをattachした~
remote processと
-client IDEが
通信してdebugする感じ。
***WSLのリモートデバッグ設定 [#s03bb12c]
-WSL(Ubuntu)上の設定。
--[[前述の手順>#o5abb403]]と同様に、~
SSHサーバのインストールと設定を実施しておく。
--unzipをインストールする(vsdbgのインストールで必要だっ...
sudo apt-get install unzip
--次のコマンドを実行してvsdbgをインストールする。~
「-l」には、任意のインストール・パスを指定する。
curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v...
--トランスポートには、[[前述>#o5abb403]]と同様にSSHを使用...
-Windows上の設定。
--[[PuTTY]]をインストールして、
--[[PuTTY]]でSSHサーバを接続する。
***[[Visual Studio]]の設定 [#jdf58d89]
-デバッグ対象のプロジェクトはポータブルPDBを指定。
-Windows上でビルドが通ったら、
--そのまま次のステップに進む(FDD)
--Linux上で[[dotnet publish>#zc5721da]]する(SCD)~
ファイルを共有については、「/mnt/c」[[※ 1>#eefd5e3f]] を...
>※ [[FDDがイイのか?SCDがイイのか?>.NET Coreのデプロイ#o...
-起動構成ファイル(launch.json)を作成する。
--[[Visual Studio]]にデバッグ方法を指示する
--プロジェクトを起動するlaunch.jsonファイルの例を次に示す。
{
"version": "1.0.0",
"adapter": "C:\\Program Files\\PuTTY\\plink.exe",
"adapterArgs": "-i c:\\private.ppk seigi@nishino -batc...
"configurations": [
{
"name": ".NET Core Launch",
"type": "coreclr",
"cwd": "/mnt/c/xxxx",
"program": "bin/Debug/netcoreappn.n/.../xxxx.dll",
"request": "launch"
}
]
}
※ コレは、SCDのパターンか。
--adapter~
トランスポートとしてSSHを使用
---SSHクライアントは[[PuTTY]](plink.exe)を使用する。
---SSHサーバーを経由してvsdbgに接続する。
--adapterArgs~
[[PuTTY]](plink.exe)のコマンドライン引数
---プライベートSSHキーへのパス
---SSH Linuxボックスに接続するように指示
---vsdbgインストール・ディレクトリから、~
vsdbg実行可能ファイルを実行
--configurations~
vsdbgに渡す設定値
---cwd~
・Linux上の、プロジェクトのルート・ディレクトリ~
・若しくは、実行可能ファイルの配置先ディレクトリ
---program~
・Linux上の、実行可能ファイルへのパス~
・若しくは、実行可能ファイル名~
・(vsdbgはdotnetコマンドで実行可能ファイルを実行)
***デバッグ実行を開始 [#j88e5db1]
-冒頭に書いた通り、DebugAdapterHost経由で、デバッグ実行を...
--[表示] メニュー > [その他のウィンドウ] > [コマンド ウィ...
--以下のコマンドを、[[Visual Studio]]のコマンドウィンドウ...
DebugAdapterHost.Launch /LaunchJson:"launch.jsonファイル...
>※ ファイル名は「launch.json」でなくてもイイもよう。
-以下の様に、リモートデバッグが実行される。~
https://twitter.com/openhishopjpo/status/1163729300383682...
**ASP.NET Core [#neb6d639]
***WSLのリモートデバッグ設定 [#v0f5c559]
-WSL(Ubuntu)上の設定。
--以下を除き、[[.NET Core>#s03bb12c]]と同じ。
--dotnet2.1以上。
-Windows上の設定。
--以下を除き、[[.NET Core>#s03bb12c]]と同じ。
--dotnet2.1以上。
***[[Visual Studio]]の設定 [#r82ae9c8]
以下を除き、[[.NET Core>#jdf58d89]]と同じ。
-以下をProgram.Mainメソッドに追加する。~
(リモートデバッグではブラウザが自動起動しないのでポート...
CreateWebHostBuilder(args).UseUrls("http://*:5000").Buil...
***デバッグ実行を開始 [#g3a8eddb]
以下を除き、[[.NET Core>#j88e5db1]]と同じ。
-上記のUseUrlsで指定したポート(5000)のリスニングを許可...
-WWWブラウザから「http://localhost:5000/」にアクセスする。
-以下の様に、リモートデバッグが実行される。~
https://twitter.com/openhishopjpo/status/1167284051515887...
**[[Visual Studio]]からデバッガをアタッチする方法 [#b8ef5...
***WSLのリモートデバッグ設定 [#v01311f3]
-以下を除き、[[.NET Core>#hc8a9948]]、[[ASP.NET Core>#neb...
-事前に、アプリケーションを起動しておく(自動でLaunchしな...
dotnet /.../xxxx.dll
-ConsoleAppでは、アプリケーションが瞬時に終了してしまうた...
必要に応じて、Console.ReadKeyなどで止める必要はある。
***[[Visual Studio]]の設定 [#l10cd6cd]
-以下を除き、[[ASP.NET Core>#r82ae9c8]]と同じ。
--launch.jsonを自作する必要はない。
--SSHクライアントの[[PuTTY]]も不要(OS組込のモノを使用す...
-[[Visual Studio]]のメニューから~
[ツール] → [オプション] → [オプション]ダイアログ~
→ [クロスプラットフォーム] → [接続マネージャー] → [追加]~
→ [リモートシステムへの接続]ダイアログにて下記の情報を入...
--ホスト名 : localhost (任意)
--ポート : 22
--ユーザー名 : seigi
--認証の種類 : パスワード or 秘密鍵
***デバッグ実行を開始 [#j84bacd5]
-事前に、アプリケーションを起動しておく。
-[[Visual Studio]]のメニューから~
[デバッグ] → [プロセスにアタッチ] → [プロセスにアタッチ]...
--接続の種類 : SSH
--接続先 : seigi@localhost (検索して選択)
--アタッチ先 : [Maneged(.NET Core for Unix) コード]
-[使用可能なプロセス]から選択し、[アタッチ]ボタンを押下
--プロセスが dotnet
--タイトルが dotnet /.../xxxx.dll
-デバッグ対象ファイルを開いて、ブレークポイントを指定する。
-起動したアプリケーションを実行する。
--ConsoleApp~
キーを押下し、Console.ReadKeyを通過させる。
--MvcApplication~
WWWブラウザから「http://localhost:5000/」にアクセスする。
-以下の様に、リモートデバッグが実行される。~
https://twitter.com/openhishopjpo/status/1167284051515887...
**[[WSL2では何がどう変わったのか?>WSL → WSL2#t061a41a]] ...
*参考 [#ida97117]
-OSのバージョンを取得する、OSの種類を判別する - .NET Tips...
https://dobon.net/vb/dotnet/system/osversion.html
**※ 1 [#eefd5e3f]
[[DrvFsのVFSファイルシステムプラグイン。>WSLでのWindowsと...
**[[トレースによるデバッグ>dotnetコマンド#b7716dc9]] [#yc...
リモートデバッグが難しい場合はコチラ。
**リモートデバッグ [#gb2063cd]
***C/C++ [#b8823428]
-Windows Subsystem for Linuxを使って「開発」をしてみよう ...
http://www.buildinsider.net/enterprise/wsl/02
-WSL その75 - Visual Studio + Ubuntu on WindowsでUbuntuの...
https://kledgeb.blogspot.com/2017/02/wsl-75-visual-studio...
***.NET Core [#w6692b65]
-Visual Studio 2017 RC3 から .NET Core on RHEL にリモート...
https://tech.tanaka733.net/entry/remote-debug-dotnetcore-...
-Offroad Debugging of .NET Core on Linux OSX from Visual ...
https://github.com/Microsoft/MIEngine/wiki/Offroad-Debugg...
**OSSコンソーシアム [#he6e9ac0]
***開発基盤部会 Blog [#u2616003]
-ASP.NET CoreのLinux開発環境についての考察(WSL or Docker)~
https://www.osscons.jp/jotmuz8dq-537/
-WSL開発環境、大方、出来上がった感。最新の開発環境につい...
--① : https://www.osscons.jp/joroqfht0-537/
--② : https://www.osscons.jp/jo1ocsdgb-537/
----
Tags: [[:.NET開発]], [[:.NET Core]], [[:Windows]], [[:Lin...
終了行:
「[[マイクロソフト系技術情報 Wiki>http://techinfoofmicros...
-戻る
--[[Windows Subsystem for Linux]]
--[[.NET Coreの開発]]
--[[ASP.NET Coreの開発]]
* 目次 [#rdb7338f]
#contents
*概要 [#ua00ab1b]
-[[WSL>Windows Subsystem for Linux]]を使用した、[[.NET Co...
-手軽に動作確認を行うなどの用途では、WSLは非常に便利だと...
-ただし、所詮、エミュレーションなので、実機確認を行う場合...
*準備 [#iba2e597]
**WSL [#y54441e3]
***インストール [#r78a3a71]
[[コチラ>Windows Subsystem for Linux#o393cbb1]]を参照。
***設定 [#kacd3cc0]
-hostname : nishino
-username : seigi
-username@hostname : seigi@nishino
Installing, this may take a few minutes...
Installation successful!
Please create a default UNIX user account. The username ...
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: seigi
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Default UNIX user set to: seigi
To run a command as administrator (user "root"), use "su...
See "man sudo_root" for details.
**dotnet [#hcb1de96]
***2.n [#vb66787e]
sudo apt-get update
sudo apt-get install openssh-server unzip curl
curl https://packages.microsoft.com/keys/microsoft.asc |...
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.micr...
sudo apt-get update
sudo apt-get install dotnet-sdk-2.n
dotnet --version
***3.n [#o319f285]
...
**[[.NET Coreの開発]] [#d6efbd4a]
-[[Windows上で開発して>.NET Coreの開発]]
-[[検証手順>.NET Coreのデプロイ#fbabb769]]と同様に、WSL上...
***dotnet new [#v014f0f4]
dotnet new コマンドを使用した、テンプレート準備とビルド・...
seigi@nishino:~$ curl https://packages.microsoft.com/key...
% Total % Received % Xferd Average Speed Time ...
Dload Upload Total ...
100 983 100 983 0 0 319 0 0:00:03 ...
seigi@nishino:~$ sudo mv microsoft.gpg /etc/apt/trusted....
[sudo] password for seigi:
seigi@nishino:~$ sudo sh -c 'echo "deb [arch=amd64] http...
seigi@nishino:~$ sudo apt-get update
Get:1 http://security.ubuntu.com/ubuntu xenial-security ...
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:3 https://packages.microsoft.com/repos/microsoft-ubu...
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates In...
Get:5 http://archive.ubuntu.com/ubuntu xenial-backports ...
Get:6 http://archive.ubuntu.com/ubuntu xenial/universe a...
Get:7 https://packages.microsoft.com/repos/microsoft-ubu...
Get:8 http://security.ubuntu.com/ubuntu xenial-security/...
Get:9 http://security.ubuntu.com/ubuntu xenial-security/...
Get:10 http://security.ubuntu.com/ubuntu xenial-security...
Get:11 http://security.ubuntu.com/ubuntu xenial-security...
Get:12 http://security.ubuntu.com/ubuntu xenial-security...
Get:13 http://archive.ubuntu.com/ubuntu xenial/universe ...
Get:14 http://security.ubuntu.com/ubuntu xenial-security...
Get:15 http://security.ubuntu.com/ubuntu xenial-security...
Get:16 http://security.ubuntu.com/ubuntu xenial-security...
Get:17 http://archive.ubuntu.com/ubuntu xenial/multivers...
Get:18 http://archive.ubuntu.com/ubuntu xenial/multivers...
Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/m...
Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/m...
Get:21 http://archive.ubuntu.com/ubuntu xenial-updates/r...
Get:22 http://archive.ubuntu.com/ubuntu xenial-updates/r...
Get:23 http://archive.ubuntu.com/ubuntu xenial-updates/u...
Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/u...
Get:25 http://archive.ubuntu.com/ubuntu xenial-updates/m...
Get:26 http://archive.ubuntu.com/ubuntu xenial-updates/m...
Get:27 http://archive.ubuntu.com/ubuntu xenial-backports...
Get:28 http://archive.ubuntu.com/ubuntu xenial-backports...
Get:29 http://archive.ubuntu.com/ubuntu xenial-backports...
Get:30 http://archive.ubuntu.com/ubuntu xenial-backports...
Fetched 15.7 MB in 16s (944 kB/s)
Reading package lists... Done
seigi@nishino:~$ sudo apt-get install dotnet-sdk-2.0.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is...
libfreetype6
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
aspnetcore-store-2.0.0 dotnet-host dotnet-hostfxr-2.0....
liblttng-ust-ctl2 liblttng-ust0 libunwind8 liburcu4
The following NEW packages will be installed:
aspnetcore-store-2.0.0 dotnet-host dotnet-hostfxr-2.0....
dotnet-sdk-2.0.0 libcurl3 liblttng-ust-ctl2 liblttng-u...
0 upgraded, 11 newly installed, 0 to remove and 135 not ...
Need to get 108 MB of archives.
After this operation, 309 MB of additional disk space wi...
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu xenial/universe a...
Get:2 https://packages.microsoft.com/repos/microsoft-ubu...
Get:3 http://archive.ubuntu.com/ubuntu xenial/universe a...
Get:4 http://archive.ubuntu.com/ubuntu xenial/universe a...
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/ma...
Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64...
Get:7 https://packages.microsoft.com/repos/microsoft-ubu...
Get:8 https://packages.microsoft.com/repos/microsoft-ubu...
Get:9 https://packages.microsoft.com/repos/microsoft-ubu...
Get:10 https://packages.microsoft.com/repos/microsoft-ub...
Get:11 https://packages.microsoft.com/repos/microsoft-ub...
Fetched 108 MB in 1min 39s (1,078 kB/s)
Selecting previously unselected package aspnetcore-store...
(Reading database ... 25532 files and directories curren...
Preparing to unpack .../aspnetcore-store-2.0.0_2.0.0-1_a...
Unpacking aspnetcore-store-2.0.0 (2.0.0-1) ...
Selecting previously unselected package liburcu4:amd64.
Preparing to unpack .../liburcu4_0.9.1-3_amd64.deb ...
Unpacking liburcu4:amd64 (0.9.1-3) ...
Selecting previously unselected package liblttng-ust-ctl...
Preparing to unpack .../liblttng-ust-ctl2_2.7.1-1_amd64....
Unpacking liblttng-ust-ctl2:amd64 (2.7.1-1) ...
Selecting previously unselected package liblttng-ust0:am...
Preparing to unpack .../liblttng-ust0_2.7.1-1_amd64.deb ...
Unpacking liblttng-ust0:amd64 (2.7.1-1) ...
Selecting previously unselected package dotnet-runtime-d...
Preparing to unpack .../dotnet-runtime-deps-2.1.0-rc1_2....
Unpacking dotnet-runtime-deps-2.1.0-rc1 (2.1.0-rc1-1) ...
Selecting previously unselected package dotnet-host.
Preparing to unpack .../dotnet-host_2.1.0-rc1-1_amd64.de...
Unpacking dotnet-host (2.1.0-rc1-1) ...
Selecting previously unselected package dotnet-hostfxr-2...
Preparing to unpack .../dotnet-hostfxr-2.0.0_2.0.0-1_amd...
Unpacking dotnet-hostfxr-2.0.0 (2.0.0-1) ...
Selecting previously unselected package libcurl3:amd64.
Preparing to unpack .../libcurl3_7.47.0-1ubuntu2.7_amd64...
Unpacking libcurl3:amd64 (7.47.0-1ubuntu2.7) ...
Selecting previously unselected package libunwind8.
Preparing to unpack .../libunwind8_1.1-4.1_amd64.deb ...
Unpacking libunwind8 (1.1-4.1) ...
Selecting previously unselected package dotnet-runtime-2...
Preparing to unpack .../dotnet-runtime-2.0.0_2.0.0-1_amd...
Unpacking dotnet-runtime-2.0.0 (2.0.0-1) ...
Selecting previously unselected package dotnet-sdk-2.0.0.
Preparing to unpack .../dotnet-sdk-2.0.0_2.0.0-1_amd64.d...
Unpacking dotnet-sdk-2.0.0 (2.0.0-1) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up aspnetcore-store-2.0.0 (2.0.0-1) ...
Setting up liburcu4:amd64 (0.9.1-3) ...
Setting up liblttng-ust-ctl2:amd64 (2.7.1-1) ...
Setting up liblttng-ust0:amd64 (2.7.1-1) ...
Setting up dotnet-runtime-deps-2.1.0-rc1 (2.1.0-rc1-1) ...
Setting up dotnet-host (2.1.0-rc1-1) ...
Setting up dotnet-hostfxr-2.0.0 (2.0.0-1) ...
Setting up libcurl3:amd64 (7.47.0-1ubuntu2.7) ...
Setting up libunwind8 (1.1-4.1) ...
Setting up dotnet-runtime-2.0.0 (2.0.0-1) ...
Setting up dotnet-sdk-2.0.0 (2.0.0-1) ...
This software may collect information about you and your...
Please visit http://aka.ms/dotnet-cli-eula for more info...
Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs....
.NET Core Tools Telemetry
--------------
The .NET Core Tools include a telemetry feature that col...
The data collected is anonymous and will be published in...
The .NET Core Tools telemetry feature is enabled by defa...
Installation Note
--------------
A command will be run during the install process that wi...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
seigi@nishino:~$ dotnet --version
2.0.0
seigi@nishino:~$ which dotnet
/usr/bin/dotnet
seigi@nishino:~$ dotnet new console
Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs....
Telemetry
--------------
The .NET Core tools collect usage data in order to impro...
You can opt out of telemetry by setting a DOTNET_CLI_TEL...
You can read more about .NET Core tools telemetry @ http...
Getting ready...
The template "Console Application" was created successfu...
Processing post-creation actions...
Running 'dotnet restore' on /home/seigi/seigi.csproj...
Restoring packages for /home/seigi/seigi.csproj...
Generating MSBuild file /home/seigi/obj/seigi.csproj.n...
Generating MSBuild file /home/seigi/obj/seigi.csproj.n...
Restore completed in 236.36 ms for /home/seigi/seigi.c...
Restore succeeded.
seigi@nishino:~$ dotnet publish -f netcoreapp2.0
Microsoft (R) Build Engine version 15.3.409.57025 for .N...
Copyright (C) Microsoft Corporation. All rights reserved.
seigi -> /home/seigi/bin/Debug/netcoreapp2.0/seigi.dll
seigi -> /home/seigi/bin/Debug/netcoreapp2.0/publish/
seigi@nishino:~$ dotnet /home/seigi/bin/Debug/netcoreapp...
Hello World!
seigi@nishino:~$
***dotnet publish [#zc5721da]
[[Visual Studio]]で作成したものを「/mnt/c」[[※ 1>#eefd5e3...
-ビルド(dotnet publish)
-実行([[dotnet *.dll>#ob2ac8a7]])
cd /mnt/c/ConsoleApp1/ConsoleApp1
dotnet publish -c Release -r ubuntu.16.04-x64 --self-con...
cd bin/Release/netcoreapp2.0/ubuntu.16.04-x64
dotnet ConsoleApp1.dll
Hello World!
※ [[SCD>.NET Coreのデプロイ#w88a1ee1]]
***dotnet *.dll [#ob2ac8a7]
[[Visual Studio]]で作成・ビルドしたものを「/mnt/c」[[※ 1>...
dotnet /mnt/c/ConsoleApp1/ConsoleApp1/bin/Debug/netcorea...
Hello World!
※ [[FDD>.NET Coreのデプロイ#yfb796bd1]]
**[[ASP.NET Coreの開発]] [#r6a90b09]
-[[Windows上で開発して>ASP.NET Coreの開発]]
-[[検証手順>ASP.NET Coreのデプロイ#ac95e514]]と同様に、WS...
***dotnet new [#ea9494e7]
dotnet new コマンドを使用した、準備と確認。
seigi@nishino:~$ dotnet new mvc
Creating this template will make changes to existing fil...
Overwrite seigi.csproj
Overwrite Program.cs
Rerun the command and pass --force to accept and create.
seigi@nishino:~$
seigi@nishino:~$ dotnet new mvc --force
The template "ASP.NET Core Web App (Model-View-Controlle...
This template contains technologies from parties other t...
Processing post-creation actions...
Running 'dotnet restore' on /home/seigi/seigi.csproj...
Restoring packages for /home/seigi/seigi.csproj...
Restoring packages for /home/seigi/seigi.csproj...
Restore completed in 2.09 sec for /home/seigi/seigi.cs...
Generating MSBuild file /home/seigi/obj/seigi.csproj.n...
Restore completed in 3.83 sec for /home/seigi/seigi.cs...
Restore succeeded.
seigi@nishino:~$ dotnet run
warn: Microsoft.AspNetCore.DataProtection.KeyManagement....
No XML encryptor configured. Key {89022286-2fdf-47...
Hosting environment: Production
Content root path: /home/seigi
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
^CApplication is shutting down...
seigi@nishino:~$
#ref(mvc1.png,left,nowrap,mvcの実行1,60%)
***dotnet publish [#v85949da]
[[同上>#zc5721da]]
***dotnet run [#y62ae3c4]
[[Visual Studio]]で作成・ビルドしたものを「/mnt/c」[[※ 1>...
seigi@nishino:~$ cd /mnt/c/WebApplication1/WebApplicatio...
seigi@nishino:/mnt/c/WebApplication1/WebApplication1$ do...
Using launch settings from /mnt/c/WebApplication1/WebApp...
info: Microsoft.AspNetCore.DataProtection.KeyManagement....
User profile is available. Using '/home/seigi/.asp...
Hosting environment: Development
Content root path: /mnt/c/WebApplication1/WebApplication1
Now listening on: http://localhost:53336
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Mvc.Internal.ControllerAction...
Executing action method WebApplication1.Controller...
info: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.Vie...
Executing ViewResult, running view at path /Views/...
info: Microsoft.AspNetCore.Mvc.Internal.ControllerAction...
Executed action WebApplication1.Controllers.HomeCo...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 7032.349ms 200 text/html; char...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/lib/jquery/dist/jque...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/css/site.css'. Physi...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/lib/bootstrap/dist/c...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 544.652ms 200 text/css
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 551.471ms 200 text/css
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 554.874ms 200 application/java...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/lib/bootstrap/dist/j...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/js/site.js'. Physica...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/images/banner1.svg'....
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 0.714ms 200 image/svg+xml
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 3.301ms 200 application/javasc...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/images/banner2.svg'....
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/images/banner3.svg'....
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 0.348ms 200 image/svg+xml
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 0.485ms 200 image/svg+xml
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 6.833ms 200 application/javasc...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/images/banner4.svg'....
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 1.35ms 200 image/svg+xml
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/lib/bootstrap/dist/f...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 0.757ms 200 font/woff2
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:533...
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddlew...
Sending file. Request path: '/favicon.ico'. Physic...
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 1.081ms 200 image/x-icon
#ref(mvc2.png,left,nowrap,mvcの実行2,60%)
**OSバージョンの確認 [#j5258403]
以下のような感じ。
OperatingSystem os = Environment.OSVersion;
if (os.Platform == PlatformID.Win32NT)
{
・・・
*リモートデバッグ [#fd286380]
**C/C++ [#d81d6983]
***WSLのリモートデバッグ設定 [#o5abb403]
以下は、すべて、WSL(Ubuntu)上の設定。
-パッケージリストが古いと404になるので、以下を実行してか...
sudo apt-get update
-コンパイラー、リモートデバッガ、SSHサーバのインストール...
sudo apt install -y build-essential
sudo apt install -y gdbserver
sudo apt install -y openssh-server
-/etc/ssh/sshd_configファイルを編集
--「[[vi>https://dotnetdevelopmentinfrastructure.osscons....
sudo vi /etc/ssh/sshd_config
--パスワード認証を有効にする。
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes
-SSHの鍵を作成する
sudo ssh-keygen -A
-SSHサーバを起動する
sudo service ssh start
-SSHサーバの状態を確認する。
sudo service ssh status
***[[Visual Studio]]の設定 [#jb072390]
以下は、すべて、Windows上の設定。
-[[Visual Studio]] 2017のインストーラーで、~
[C++ による Linux 開発]コンポーネントにチェック
-[Visual C++]-[クロス プラットフォーム]-[Linux]を...
テンプレート一覧から「コンソール アプリケーション (Linux)...
-F5でデバッグ実行すると、WSLへの接続ダイアログが表示され...
--[Host name:]欄には「localhost」
--[User name:]欄と[Password]欄に(Ubuntuの)ユーザ / ...
--[Connect]ボタンをクリックしてWSLに接続。
-「gdbを起動できませんでした」と言うエラーが発生する場合、~
プロジェクトのプロパティの[デバッグ]→[デバッグ モード]を、~
gdb モードから、gdbserver モードへ、変更する。
**.NET Core [#hc8a9948]
仕組みとしては、
><Windows>~
[[Visual Studio]] → DebugAdapterHost → [[PuTTY]]~
~
↓ ↓ ↓(SSH)↑ ↑ ↑~
~
<Linux>~
openssh-server → vsdbg → dotnet (XXXX.dll)
みたいな感じで、
-debuggerをattachした~
remote processと
-client IDEが
通信してdebugする感じ。
***WSLのリモートデバッグ設定 [#s03bb12c]
-WSL(Ubuntu)上の設定。
--[[前述の手順>#o5abb403]]と同様に、~
SSHサーバのインストールと設定を実施しておく。
--unzipをインストールする(vsdbgのインストールで必要だっ...
sudo apt-get install unzip
--次のコマンドを実行してvsdbgをインストールする。~
「-l」には、任意のインストール・パスを指定する。
curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v...
--トランスポートには、[[前述>#o5abb403]]と同様にSSHを使用...
-Windows上の設定。
--[[PuTTY]]をインストールして、
--[[PuTTY]]でSSHサーバを接続する。
***[[Visual Studio]]の設定 [#jdf58d89]
-デバッグ対象のプロジェクトはポータブルPDBを指定。
-Windows上でビルドが通ったら、
--そのまま次のステップに進む(FDD)
--Linux上で[[dotnet publish>#zc5721da]]する(SCD)~
ファイルを共有については、「/mnt/c」[[※ 1>#eefd5e3f]] を...
>※ [[FDDがイイのか?SCDがイイのか?>.NET Coreのデプロイ#o...
-起動構成ファイル(launch.json)を作成する。
--[[Visual Studio]]にデバッグ方法を指示する
--プロジェクトを起動するlaunch.jsonファイルの例を次に示す。
{
"version": "1.0.0",
"adapter": "C:\\Program Files\\PuTTY\\plink.exe",
"adapterArgs": "-i c:\\private.ppk seigi@nishino -batc...
"configurations": [
{
"name": ".NET Core Launch",
"type": "coreclr",
"cwd": "/mnt/c/xxxx",
"program": "bin/Debug/netcoreappn.n/.../xxxx.dll",
"request": "launch"
}
]
}
※ コレは、SCDのパターンか。
--adapter~
トランスポートとしてSSHを使用
---SSHクライアントは[[PuTTY]](plink.exe)を使用する。
---SSHサーバーを経由してvsdbgに接続する。
--adapterArgs~
[[PuTTY]](plink.exe)のコマンドライン引数
---プライベートSSHキーへのパス
---SSH Linuxボックスに接続するように指示
---vsdbgインストール・ディレクトリから、~
vsdbg実行可能ファイルを実行
--configurations~
vsdbgに渡す設定値
---cwd~
・Linux上の、プロジェクトのルート・ディレクトリ~
・若しくは、実行可能ファイルの配置先ディレクトリ
---program~
・Linux上の、実行可能ファイルへのパス~
・若しくは、実行可能ファイル名~
・(vsdbgはdotnetコマンドで実行可能ファイルを実行)
***デバッグ実行を開始 [#j88e5db1]
-冒頭に書いた通り、DebugAdapterHost経由で、デバッグ実行を...
--[表示] メニュー > [その他のウィンドウ] > [コマンド ウィ...
--以下のコマンドを、[[Visual Studio]]のコマンドウィンドウ...
DebugAdapterHost.Launch /LaunchJson:"launch.jsonファイル...
>※ ファイル名は「launch.json」でなくてもイイもよう。
-以下の様に、リモートデバッグが実行される。~
https://twitter.com/openhishopjpo/status/1163729300383682...
**ASP.NET Core [#neb6d639]
***WSLのリモートデバッグ設定 [#v0f5c559]
-WSL(Ubuntu)上の設定。
--以下を除き、[[.NET Core>#s03bb12c]]と同じ。
--dotnet2.1以上。
-Windows上の設定。
--以下を除き、[[.NET Core>#s03bb12c]]と同じ。
--dotnet2.1以上。
***[[Visual Studio]]の設定 [#r82ae9c8]
以下を除き、[[.NET Core>#jdf58d89]]と同じ。
-以下をProgram.Mainメソッドに追加する。~
(リモートデバッグではブラウザが自動起動しないのでポート...
CreateWebHostBuilder(args).UseUrls("http://*:5000").Buil...
***デバッグ実行を開始 [#g3a8eddb]
以下を除き、[[.NET Core>#j88e5db1]]と同じ。
-上記のUseUrlsで指定したポート(5000)のリスニングを許可...
-WWWブラウザから「http://localhost:5000/」にアクセスする。
-以下の様に、リモートデバッグが実行される。~
https://twitter.com/openhishopjpo/status/1167284051515887...
**[[Visual Studio]]からデバッガをアタッチする方法 [#b8ef5...
***WSLのリモートデバッグ設定 [#v01311f3]
-以下を除き、[[.NET Core>#hc8a9948]]、[[ASP.NET Core>#neb...
-事前に、アプリケーションを起動しておく(自動でLaunchしな...
dotnet /.../xxxx.dll
-ConsoleAppでは、アプリケーションが瞬時に終了してしまうた...
必要に応じて、Console.ReadKeyなどで止める必要はある。
***[[Visual Studio]]の設定 [#l10cd6cd]
-以下を除き、[[ASP.NET Core>#r82ae9c8]]と同じ。
--launch.jsonを自作する必要はない。
--SSHクライアントの[[PuTTY]]も不要(OS組込のモノを使用す...
-[[Visual Studio]]のメニューから~
[ツール] → [オプション] → [オプション]ダイアログ~
→ [クロスプラットフォーム] → [接続マネージャー] → [追加]~
→ [リモートシステムへの接続]ダイアログにて下記の情報を入...
--ホスト名 : localhost (任意)
--ポート : 22
--ユーザー名 : seigi
--認証の種類 : パスワード or 秘密鍵
***デバッグ実行を開始 [#j84bacd5]
-事前に、アプリケーションを起動しておく。
-[[Visual Studio]]のメニューから~
[デバッグ] → [プロセスにアタッチ] → [プロセスにアタッチ]...
--接続の種類 : SSH
--接続先 : seigi@localhost (検索して選択)
--アタッチ先 : [Maneged(.NET Core for Unix) コード]
-[使用可能なプロセス]から選択し、[アタッチ]ボタンを押下
--プロセスが dotnet
--タイトルが dotnet /.../xxxx.dll
-デバッグ対象ファイルを開いて、ブレークポイントを指定する。
-起動したアプリケーションを実行する。
--ConsoleApp~
キーを押下し、Console.ReadKeyを通過させる。
--MvcApplication~
WWWブラウザから「http://localhost:5000/」にアクセスする。
-以下の様に、リモートデバッグが実行される。~
https://twitter.com/openhishopjpo/status/1167284051515887...
**[[WSL2では何がどう変わったのか?>WSL → WSL2#t061a41a]] ...
*参考 [#ida97117]
-OSのバージョンを取得する、OSの種類を判別する - .NET Tips...
https://dobon.net/vb/dotnet/system/osversion.html
**※ 1 [#eefd5e3f]
[[DrvFsのVFSファイルシステムプラグイン。>WSLでのWindowsと...
**[[トレースによるデバッグ>dotnetコマンド#b7716dc9]] [#yc...
リモートデバッグが難しい場合はコチラ。
**リモートデバッグ [#gb2063cd]
***C/C++ [#b8823428]
-Windows Subsystem for Linuxを使って「開発」をしてみよう ...
http://www.buildinsider.net/enterprise/wsl/02
-WSL その75 - Visual Studio + Ubuntu on WindowsでUbuntuの...
https://kledgeb.blogspot.com/2017/02/wsl-75-visual-studio...
***.NET Core [#w6692b65]
-Visual Studio 2017 RC3 から .NET Core on RHEL にリモート...
https://tech.tanaka733.net/entry/remote-debug-dotnetcore-...
-Offroad Debugging of .NET Core on Linux OSX from Visual ...
https://github.com/Microsoft/MIEngine/wiki/Offroad-Debugg...
**OSSコンソーシアム [#he6e9ac0]
***開発基盤部会 Blog [#u2616003]
-ASP.NET CoreのLinux開発環境についての考察(WSL or Docker)~
https://www.osscons.jp/jotmuz8dq-537/
-WSL開発環境、大方、出来上がった感。最新の開発環境につい...
--① : https://www.osscons.jp/joroqfht0-537/
--② : https://www.osscons.jp/jo1ocsdgb-537/
----
Tags: [[:.NET開発]], [[:.NET Core]], [[:Windows]], [[:Lin...
ページ名: