- 追加された行はこの色です。
- 削除された行はこの色です。
「[[マイクロソフト系技術情報 Wiki>http://techinfoofmicrosofttech.osscons.jp/]]」は、「[[Open棟梁Project>https://github.com/OpenTouryoProject/]]」,「[[OSSコンソーシアム .NET開発基盤部会>https://www.osscons.jp/dotNetDevelopmentInfrastructure/]]」によって運営されています。
-戻る
--[[Windows Subsystem for Linux]]
--[[.NET Coreの開発]]
--[[ASP.NET Coreの開発]]
* 目次 [#rdb7338f]
#contents
*概要 [#ua00ab1b]
-Windows Subsystem for Linux (WSL)を使用した、[[.NET Core]], [[ASP.NET Core]]開発が可能。
-手軽に動作確認を行うなどの用途では、WSLは非常に便利だと思う。
-ただし、所詮、エミュレーションなので、実機確認を行う場合は、[[Docker>https://dotnetdevelopmentinfrastructure.osscons.jp/index.php?Docker]]などを使用すべきと考える。
**[[.NET Coreの開発]] [#d6efbd4a]
-WSLをインストールし、
-[[Windows上で開発して>.NET Coreの開発]]
-[[検証手順>.NET Coreのデプロイ#fbabb769]]と同様に、WSL上にデプロイする。
***dotnet new [#v014f0f4]
dotnet new コマンドを使用した、テンプレート準備とビルド・実行。
Installing, this may take a few minutes...
Installation successful!
Please create a default UNIX user account. The username does not need to match your Windows 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 "sudo <command>".
See "man sudo_root" for details.
seigi@nishino:~$ curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 983 100 983 0 0 319 0 0:00:03 0:00:03 --:--:-- 319
seigi@nishino:~$ sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
[sudo] password for seigi:
seigi@nishino:~$ sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
seigi@nishino:~$ sudo apt-get update
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:3 https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial InRelease [2,845 B]
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [7,532 kB]
Get:7 https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial/main amd64 Packages [38.1 kB]
Get:8 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [484 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/main Translation-en [209 kB]
Get:10 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [7,224 B]
Get:11 http://security.ubuntu.com/ubuntu xenial-security/restricted Translation-en [2,152 B]
Get:12 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [344 kB]
Get:13 http://archive.ubuntu.com/ubuntu xenial/universe Translation-en [4,354 kB]
Get:14 http://security.ubuntu.com/ubuntu xenial-security/universe Translation-en [129 kB]
Get:15 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3,464 B]
Get:16 http://security.ubuntu.com/ubuntu xenial-security/multiverse Translation-en [1,744 B]
Get:17 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [144 kB]
Get:18 http://archive.ubuntu.com/ubuntu xenial/multiverse Translation-en [106 kB]
Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [769 kB]
Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [319 kB]
Get:21 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [7,560 B]
Get:22 http://archive.ubuntu.com/ubuntu xenial-updates/restricted Translation-en [2,272 B]
Get:23 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [624 kB]
Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [252 kB]
Get:25 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [16.4 kB]
Get:26 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse Translation-en [8,344 B]
Get:27 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [4,844 B]
Get:28 http://archive.ubuntu.com/ubuntu xenial-backports/main Translation-en [3,220 B]
Get:29 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [7,400 B]
Get:30 http://archive.ubuntu.com/ubuntu xenial-backports/universe Translation-en [3,996 B]
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 no longer required:
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.0 dotnet-runtime-2.0.0 dotnet-runtime-deps-2.1.0-rc1 libcurl3
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.0 dotnet-runtime-2.0.0 dotnet-runtime-deps-2.1.0-rc1
dotnet-sdk-2.0.0 libcurl3 liblttng-ust-ctl2 liblttng-ust0 libunwind8 liburcu4
0 upgraded, 11 newly installed, 0 to remove and 135 not upgraded.
Need to get 108 MB of archives.
After this operation, 309 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu xenial/universe amd64 liburcu4 amd64 0.9.1-3 [47.3 kB]
Get:2 https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial/main amd64 aspnetcore-store-2.0.0 amd64 2.0.0-1 [18.1 MB]
Get:3 http://archive.ubuntu.com/ubuntu xenial/universe amd64 liblttng-ust-ctl2 amd64 2.7.1-1 [72.2 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial/universe amd64 liblttng-ust0 amd64 2.7.1-1 [127 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcurl3 amd64 7.47.0-1ubuntu2.7 [187 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64 libunwind8 amd64 1.1-4.1 [46.5 kB]
Get:7 https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial/main amd64 dotnet-runtime-deps-2.1.0-rc1 amd64 2.1.0-rc1-1 [2,622 B]
Get:8 https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial/main amd64 dotnet-host amd64 2.1.0-rc1-1 [34.4 kB]
Get:9 https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial/main amd64 dotnet-hostfxr-2.0.0 amd64 2.0.0-1 [135 kB]
Get:10 https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial/main amd64 dotnet-runtime-2.0.0 amd64 2.0.0-1 [18.6 MB]
Get:11 https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial/main amd64 dotnet-sdk-2.0.0 amd64 2.0.0-1 [70.3 MB]
Fetched 108 MB in 1min 39s (1,078 kB/s)
Selecting previously unselected package aspnetcore-store-2.0.0.
(Reading database ... 25532 files and directories currently installed.)
Preparing to unpack .../aspnetcore-store-2.0.0_2.0.0-1_amd64.deb ...
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-ctl2:amd64.
Preparing to unpack .../liblttng-ust-ctl2_2.7.1-1_amd64.deb ...
Unpacking liblttng-ust-ctl2:amd64 (2.7.1-1) ...
Selecting previously unselected package liblttng-ust0:amd64.
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-deps-2.1.0-rc1.
Preparing to unpack .../dotnet-runtime-deps-2.1.0-rc1_2.1.0-rc1-1_amd64.deb ...
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.deb ...
Unpacking dotnet-host (2.1.0-rc1-1) ...
Selecting previously unselected package dotnet-hostfxr-2.0.0.
Preparing to unpack .../dotnet-hostfxr-2.0.0_2.0.0-1_amd64.deb ...
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.deb ...
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.0.0.
Preparing to unpack .../dotnet-runtime-2.0.0_2.0.0-1_amd64.deb ...
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.deb ...
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 use of the software, and send that to Microsoft.
Please visit http://aka.ms/dotnet-cli-eula for more information.
Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
.NET Core Tools Telemetry
--------------
The .NET Core Tools include a telemetry feature that collects usage information. It is important that the .NET Team understands how the tools are being used so that we can improve them.
The data collected is anonymous and will be published in an aggregated form for use by both Microsoft and community engineers under the Creative Commons Attribution License.
The .NET Core Tools telemetry feature is enabled by default. You can opt-out of the telemetry feature by setting an environment variable DOTNET_CLI_TELEMETRY_OPTOUT (for example, 'export' on macOS/Linux, 'set' on Windows) to true (for example, 'true', 1). You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry.
Installation Note
--------------
A command will be run during the install process that will improve project restore speed and enable offline access. It will take up to a minute to complete.
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. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
Getting ready...
The template "Console Application" was created successfully.
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.nuget.g.props.
Generating MSBuild file /home/seigi/obj/seigi.csproj.nuget.g.targets.
Restore completed in 236.36 ms for /home/seigi/seigi.csproj.
Restore succeeded.
seigi@nishino:~$ dotnet publish -f netcoreapp2.0
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
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/netcoreapp2.0/seigi.dll
Hello World!
seigi@nishino:~$
***dotnet publish [#zc5721da]
[[Visual Studio]]で作成したものを「/mnt/c」[[※ 1>#eefd5e3f]] を経由で、
-ビルド(dotnet publish)
-実行([[dotnet>#ob2ac8a7]])
cd /mnt/c/ConsoleApp1/ConsoleApp1
dotnet publish -c Release -r ubuntu.16.04-x64 --self-contained
cd bin/Release/netcoreapp2.0/ubuntu.16.04-x64
dotnet ConsoleApp1.dll
Hello World!
※ [[SCD>.NET Coreのデプロイ#w88a1ee1]]
***dotnet [#ob2ac8a7]
[[Visual Studio]]で作成・ビルドしたものを「/mnt/c」[[※ 1>#eefd5e3f]] を経由して実行~
dotnet /mnt/c/ConsoleApp1/ConsoleApp1/bin/Debug/netcoreapp2.0/ConsoleApp1.dll
Hello World!
※ [[FDD>.NET Coreのデプロイ#yfb796bd1]]
**[[ASP.NET Coreの開発]] [#r6a90b09]
-WSLをインストールし、
-[[Windows上で開発して>ASP.NET Coreの開発]]
-[[検証手順>ASP.NET Coreのデプロイ#ac95e514]]と同様に、WSL上にデプロイする。
***dotnet new [#ea9494e7]
dotnet new コマンドを使用した、準備と確認。
seigi@nishino:~$ dotnet new mvc
Creating this template will make changes to existing files:
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-Controller)" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/template-3pn for details.
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.csproj.
Generating MSBuild file /home/seigi/obj/seigi.csproj.nuget.g.targets.
Restore completed in 3.83 sec for /home/seigi/seigi.csproj.
Restore succeeded.
seigi@nishino:~$ dotnet run
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {89022286-2fdf-47e0-85d2-0047907c89b1} may be persisted to storage in unencrypted form.
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]
...。
***dotnet run [#y62ae3c4]
[[Visual Studio]]で作成・ビルドしたものを「/mnt/c」[[※ 1>#eefd5e3f]] を経由して実行~
seigi@nishino:~$ cd /mnt/c/WebApplication1/WebApplication1/
seigi@nishino:/mnt/c/WebApplication1/WebApplication1$ dotnet run
Using launch settings from /mnt/c/WebApplication1/WebApplication1/Properties/launchSettings.json...
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using '/home/seigi/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
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:53336/
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
Executing action method WebApplication1.Controllers.HomeController.Index (WebApplication1) with arguments ((null)) - ModelState is Valid
info: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[1]
Executing ViewResult, running view at path /Views/Home/Index.cshtml.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
Executed action WebApplication1.Controllers.HomeController.Index (WebApplication1) in 6636.097ms
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:53336/css/site.css
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:53336/lib/bootstrap/dist/css/bootstrap.css
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:53336/lib/jquery/dist/jquery.js
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 7032.349ms 200 text/html; charset=utf-8
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
Sending file. Request path: '/lib/jquery/dist/jquery.js'. Physical path: '/mnt/c/WebApplication1/WebApplication1/wwwroot/lib/jquery/dist/jquery.js'
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
Sending file. Request path: '/css/site.css'. Physical path: '/mnt/c/WebApplication1/WebApplication1/wwwroot/css/site.css'
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
Sending file. Request path: '/lib/bootstrap/dist/css/bootstrap.css'. Physical path: '/mnt/c/WebApplication1/WebApplication1/wwwroot/lib/bootstrap/dist/css/bootstrap.css'
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/javascript
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:53336/lib/bootstrap/dist/js/bootstrap.js
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:53336/js/site.js?v=ji3-IxbEzYWjzzLCGkF1KDjrT2jLbbrSYXw-AhMPNIA
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
Sending file. Request path: '/lib/bootstrap/dist/js/bootstrap.js'. Physical path: '/mnt/c/WebApplication1/WebApplication1/wwwroot/lib/bootstrap/dist/js/bootstrap.js'
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
Sending file. Request path: '/js/site.js'. Physical path: '/mnt/c/WebApplication1/WebApplication1/wwwroot/js/site.js'
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:53336/images/banner1.svg
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
Sending file. Request path: '/images/banner1.svg'. Physical path: '/mnt/c/WebApplication1/WebApplication1/wwwroot/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:53336/images/banner2.svg
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 3.301ms 200 application/javascript
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost:53336/images/banner3.svg
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
Sending file. Request path: '/images/banner2.svg'. Physical path: '/mnt/c/WebApplication1/WebApplication1/wwwroot/images/banner2.svg'
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
Sending file. Request path: '/images/banner3.svg'. Physical path: '/mnt/c/WebApplication1/WebApplication1/wwwroot/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:53336/images/banner4.svg
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 6.833ms 200 application/javascript
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
Sending file. Request path: '/images/banner4.svg'. Physical path: '/mnt/c/WebApplication1/WebApplication1/wwwroot/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:53336/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
Sending file. Request path: '/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2'. Physical path: '/mnt/c/WebApplication1/WebApplication1/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2'
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:53336/favicon.ico
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
Sending file. Request path: '/favicon.ico'. Physical path: '/mnt/c/WebApplication1/WebApplication1/wwwroot/favicon.ico'
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バージョンの確認>Visual Studio Tools for Docker#u6c27f49]] [#j5258403]
以下のような感じ。
OperatingSystem os = Environment.OSVersion;
if (os.Platform == PlatformID.Win32NT)
{
・・・
*詳細 [#fd286380]
Open棟梁を動かしてみる。
**デバッグ [#d81d6983]
**C/C++ [#d81d6983]
***WSLのリモートデバッグ設定 [#o5abb403]
-パッケージリストが古いと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.jp/index.php?vi]]」エディタで開く
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
***Visual Studioの設定 [#jb072390]
**Console [#hc8a9948]
-Visual Studio 2017のインストーラーで[C++ による Linux 開発]コンポーネントにチェック
**ASP.NET [#t0a50f2b]
-[Visual C++]-[クロス プラットフォーム]-[Linux]を選択し、~
中央のテンプレート一覧から「コンソール アプリケーション (Linux)」を選択する。
-コンパイルを実行すると、WSLへの接続ダイアログが表示される
--[Host name:]欄には「localhost」
--[User name:]欄と[Password]欄に(Ubuntuの)ユーザ / パスワード
--[Connect]ボタンをクリックしてWSLに接続。
**.NET Core [#hc8a9948]
***WSLのリモートデバッグ設定 [#s03bb12c]
-次のコマンドを実行してVSDBGをインストールする。~
「~/vsdbg」の「~」部分は、任意のパスを指定する。
curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v vs2017u5 -l ~/vsdbg
-トランスポートには、[[前述>#o5abb403]]と同様にSSHを使用できる。
***Visual Studioの設定 [#jdf58d89]
-デバッグ対象のプロジェクトはポータブルPDBを指定。
-Windows上でビルドが通ったら、Linux上でdotnet publishする。
-ファイルを共有については、「/mnt/c」[[※ 1>#eefd5e3f]] を経由で、
-起動構成ファイル(launch.json)を作成する。
--Visual Studioにデバッグ方法を指示する
--プロジェクトを起動するlaunch.jsonファイルの例を次に示す。
{
"version": "n.n.n",
"adapter": "c:\\...\\plink.exe",
"adapterArgs": "-i c:\\...\\ssh-key.ppk xxxx@yyyy -batch -T ~/vsdbg/vsdbg --interpreter=vscode",
"configurations": [
{
"name": ".NET Core Launch",
"type": "coreclr",
"cwd": "~/xxxx",
"program": "bin/Debug/netcoreappn.n/xxxx.dll",
"request": "launch"
}
]
}
--adapter~
トランスポートとしてSSHを使用
---SSHクライアントはPuTTY(plink.exe)を使用する。
---SSHサーバーを経由してvsdbgに接続する。
--adapterArgs~
PuTTY(plink.exe)のコマンドライン引数
---プライベートSSHキーへのパス
---SSH Linuxボックスに接続するように指示
---vsdbgディレクトリから実行可能vsdbgを実行
--program
---Linux上の、実行可能ファイルへのパスを指定。
---(vsdbgはdotnetコマンドで実行可能ファイルを実行)
*参考 [#ida97117]
-Windows Subsystem for Linuxを使って「開発」をしてみよう~
http://www.buildinsider.net/enterprise/wsl/02
-OSのバージョンを取得する、OSの種類を判別する - .NET Tips (VB.NET,C#...)~
https://dobon.net/vb/dotnet/system/osversion.html
**C/C++ [#b8823428]
-Windows Subsystem for Linuxを使って「開発」をしてみよう - Build Insider~
http://www.buildinsider.net/enterprise/wsl/02
-WSL その75 - Visual Studio + Ubuntu on WindowsでUbuntuのソフトウェアが開発可能に - kledgeb~
https://kledgeb.blogspot.com/2017/02/wsl-75-visual-studio-ubuntu-on.html
**.NET Core [#w6692b65]
-VisualStudio 2017 RC3 から .NET Core on RHEL にリモートデバッグする - 銀の光と碧い空~
https://tech.tanaka733.net/entry/remote-debug-dotnetcore-on-rhel-from-vs2017rc3
-RaspberryPi(Raspbian)上で動く.NET Core2.1アプリをリモートデバッグする - Qiita~
https://qiita.com/HiroyukiSakoh/items/ec947802dd2f69a38e8b
-Offroad Debugging of .NET Core on Linux OSX from Visual Studio · microsoft/MIEngine Wiki~
https://github.com/Microsoft/MIEngine/wiki/Offroad-Debugging-of-.NET-Core-on-Linux---OSX-from-Visual-Studio
**※ 1 [#eefd5e3f]
[[DrvFsのVFSファイルシステムプラグイン。>Windows Subsystem for Linux#ve679160]]
----
Tags: [[:.NET開発]], [[:.NET Core]], [[:Windows]], [[:Linux]], [[:Linuxサブシステム]], [[:仮想化]]