자바스크립트를 활성화 해주세요

p020 Goormide Ubuntu에서 Pwsh를 Build해 보았습니다

 ·  ☕ 5 min read

goormide의 empty ubuntu 프로젝트에서 build해 보았습니다. 전반적인 순서는 다음과 같습니다. # 윈도우즈에서도 다르지 않습니다.

  • pwsh 설치
  • download pwsh code repository
  • Start-PSBootstrap
  • Start-Build
  • Start-PSPester

바로 가보겠습니다.

먼저 pwsh 설치

우선 pwsh이 설치되어 있어야 합니다. 다음의 커맨드를 사용해서 설치합니다.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
apt-get install build-essential
# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of products
sudo apt-get update
# Enable the "universe" repositories
sudo add-apt-repository universe
# Install PowerShell
sudo apt-get install -y powershell
# Start PowerShell
pwsh

pwsh 코드 다운받기

1
2
3
4
5
6
7
8
git clone https://github.com/PowerShell/PowerShell.git
cd PowerShell
pwsh
import-module ./build.psm1
Get-Module
gcm -module build
Start-PSBuild
(Get-Command -Module Build).Name

download 받은 결과

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
root@goorm:~# cd
root@goorm:~# git clone https://github.com/PowerShell/PowerShell.git
Cloning into 'PowerShell'...
remote: Enumerating objects: 91833, done.
remote: Total 91833 (delta 0), reused 0 (delta 0), pack-reused 91833
Receiving objects: 100% (91833/91833), 66.00 MiB | 4.23 MiB/s, done.
Resolving deltas: 100% (68282/68282), done.
Checking out files: 100% (2479/2479), done.
root@goorm:~#
root@goorm:~# cd PowerShell
root@goorm:~/PowerShell(master)#
root@goorm:~/PowerShell(master)# pwsh
PowerShell 7.0.3
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/powershell
Type 'help' to get help.

PS /root/PowerShell> import-module ./build.psm1
PS /root/PowerShell> get-module build
PS /root/PowerShell> get-module build

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     0.0                   build                               {Clear-PSRepo, Compress-TestContent, 


PS /root/PowerShell> (Get-Command -Module Build).Name
Clear-PSRepo
Compress-TestContent
Convert-TxtResourceToXml
ConvertFrom-PesterLog
Copy-PSGalleryModules
Find-Dotnet
Get-EnvironmentInformation
Get-ExperimentalFeatureTests
Get-PesterTag
Get-PSCommitId
Get-PSLatestTag
Get-PSOptions
Get-PSOutput
Get-PSVersion
Get-RedHatPackageManager
Get-UniquePackageFolderName
Install-Dotnet
Merge-TestLogs
New-NugetConfigFile
New-PSOptions
New-PSOptionsObject
New-TestPackage
precheck
Publish-PSTestTools
Publish-TestResults
Restore-PSModuleToBuild
Restore-PSOptions
Restore-PSPackage
Restore-PSPester
Save-PSOptions
Set-PSOptions
Show-PSPesterError
Start-CrossGen
Start-DevPowerShell
Start-NativeExecution
Start-PSBootstrap
Start-PSBuild
Start-PSPester
Start-PSxUnit
Start-ResGen
Start-TypeGen
Start-UnelevatedProcess
Sync-PSTags
Test-IsPreview
Test-IsReleaseCandidate
Test-PSPesterResults
Test-XUnitTestResults
Use-MSBuild
Write-Log
PS /root/PowerShell>

Start-PSBuild

나열된 명령어중에 Start-PSBuild가 있어서 우선 Start-PSBuild를 실행해 보았습니다.

1
2
3
4
PS /root/PowerShell> Start-PSBuild
WARNING: Could not find 'dotnet', appending /root/.dotnet to PATH.
WARNING: Still could not find 'dotnet', restoring PATH.
WARNING: Build dependency 'dotnet' not found in PATH. Run Start-PSBootstrap. Also see: https://dotnet.github.io/getting-started/

닷넷이 설치가 안되어 있다고 불평합니다.

read Build PowerShell on Linux를 읽고 디펜던시 설치하는 방법을 찾아보았습니다. Start-PSBootstrap 해야 하는 것이었네요. 내친 김에 최신의 dotnet core도 함께 설치합니다.

Start-PSBootstrap

1
2
Import-Module ./build.psm1
Start-PSBootstrap

결과

PS /root/PowerShell> Start-PSBootstrap
Installing PowerShell build dependencies
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://
cli-assets.heroku.com/apt ./ InRelease: 다음 서명들은 공개키가 없기 때문에 인증할 수 없습니다: NO_PUBKEY 5DC22404A6F9F1CA
W: https://cli-assets.heroku.com/apt/./InRelease 파일을 받는데 실패했습니다  다음 서명들은 공개키가 없기 때문에 인증할 수 없습니다: NO_PUBKEY 5DC224
04A6F9F1CA
W: Some index files failed to download. They have been ignored, or old ones used instead.
debconf: 프론트엔드를 초기화할 수 없음: Dialog
debconf: (dialog나 그와 비슷한 프로그램을 설치하지 않았으므로, 다이얼로그 프론트엔드는 사용할 수 없습니다. at /usr/share/perl5/Debconf/FrontEnd/Dial
og.pm line 76, <> line 11.)
debconf: 다음 프론트엔드를 대신 사용: Readline
Selecting previously unselected package liblzo2-2:amd64.
(데이터베이스 읽는중 ... 현재 51075개의 파일과 디렉터리가 설치되어 있습니다.)
Preparing to unpack .../00-liblzo2-2_2.08-1.2_amd64.deb ...
Unpacking liblzo2-2:amd64 (2.08-1.2) ...
Preparing to unpack .../01-libicu60_60.2-3ubuntu3.1_amd64.deb ...
Preparing to unpack .../02-cmake-data_3.10.2-1ubuntu2.18.04.1_all.deb ...
Unpacking cmake-data (3.10.2-1ubuntu2.18.04.1) ...
Selecting previously unselected package libarchive13:amd64.
Preparing to unpack .../03-libarchive13_3.2.2-3.1ubuntu0.6_amd64.deb ...
Unpacking libarchive13:amd64 (3.2.2-3.1ubuntu0.6) ...
Preparing to unpack .../04-curl_7.58.0-2ubuntu3.9_amd64.deb ...
Unpacking curl (7.58.0-2ubuntu3.9) over (7.58.0-2ubuntu3.8) ...
Preparing to unpack .../05-libcurl4_7.58.0-2ubuntu3.9_amd64.deb ...
Unpacking libcurl4:amd64 (7.58.0-2ubuntu3.9) over (7.58.0-2ubuntu3.8) ...
Selecting previously unselected package libjsoncpp1:amd64.
Preparing to unpack .../06-libjsoncpp1_1.7.4-3_amd64.deb ...
Unpacking libjsoncpp1:amd64 (1.7.4-3) ...
Selecting previously unselected package librhash0:amd64.
Preparing to unpack .../07-librhash0_1.3.6-2_amd64.deb ...
Unpacking librhash0:amd64 (1.3.6-2) ...
Selecting previously unselected package libuv1:amd64.
Preparing to unpack .../08-libuv1_1.18.0-3_amd64.deb ...
Unpacking libuv1:amd64 (1.18.0-3) ...
Selecting previously unselected package cmake.
Preparing to unpack .../09-cmake_3.10.2-1ubuntu2.18.04.1_amd64.deb ...
Unpacking cmake (3.10.2-1ubuntu2.18.04.1) ...
Selecting previously unselected package libunwind8:amd64.
Preparing to unpack .../10-libunwind8_1.2.1-8_amd64.deb ...
Unpacking libunwind8:amd64 (1.2.1-8) ...
libicu60:amd64 (60.2-3ubuntu3.1) 설정하는 중입니다 ...
libuv1:amd64 (1.18.0-3) 설정하는 중입니다 ...
libcurl4:amd64 (7.58.0-2ubuntu3.9) 설정하는 중입니다 ...
cmake-data (3.10.2-1ubuntu2.18.04.1) 설정하는 중입니다 ...
librhash0:amd64 (1.3.6-2) 설정하는 중입니다 ...
libunwind8:amd64 (1.2.1-8) 설정하는 중입니다 ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
liblzo2-2:amd64 (2.08-1.2) 설정하는 중입니다 ...
libjsoncpp1:amd64 (1.7.4-3) 설정하는 중입니다 ...
curl (7.58.0-2ubuntu3.9) 설정하는 중입니다 ...
libarchive13:amd64 (3.2.2-3.1ubuntu0.6) 설정하는 중입니다 ...
cmake (3.10.2-1ubuntu2.18.04.1) 설정하는 중입니다 ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
WARNING: Could not find 'dotnet', appending /root/.dotnet to PATH.
WARNING: Still could not find 'dotnet', restoring PATH.
dotnet not present.  Installing dotnet.
Unable to find dotnet installation to remove.
dotnet_install: Warning: Unable to locate zlib. Probable prerequisite missing; install zlib.
dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.100-preview.7.20366.15/dotnet-sdk-5.0.100-preview.7.20366.15-linux-
x64.tar.gz
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.100-preview.7.20366.15/dotnet-sdk-5.0.100-preview.7.20366.15-linu
x-x64.tar.gz
dotnet-install: Adding to current process PATH: `/root/.dotnet`. Note: This change will be visible only when sourcing script.
dotnet-install: Installation finished successfully.
PS /root/PowerShell>

다시 Start-PSBuild

1
2
Import-Module ./build.psm1
Start-PSBuild

결과


PS /root/PowerShell> Start-PSBuild
WARNING: Could not find 'dotnet', appending /root/.dotnet to PATH.
VERBOSE: Using configuration 'Debug'
VERBOSE: Using framework 'net5.0'
VERBOSE: Using runtime 'linux-x64'
VERBOSE: Top project directory is /root/PowerShell/src/powershell-unix
Run dotnet restore /root/PowerShell/src/powershell-unix --runtime linux-x64 /property:SDKToUse=Microsoft.NET.Sdk --verbosity quiet

Welcome to .NET 5.0!
---------------------
SDK Version: 5.0.100-preview.7.20366.15

원격 분석
---------
.NET Core 도구는 사용자 환경 개선을 위해 사용량 데이터를 수집합니다. 데이터는 익명입니다. Microsoft에서 데이터를 수집하여 커뮤니티와 공유합니다. 원
하는 셸에서 DOTNET_CLI_TELEMETRY_OPTOUT 환경 변수를 '1' 또는 'true'로 설정하여 원격 분석을 옵트아웃할 수 있습니다.

.NET Core CLI 도구 원격 분석에 대한 자세한 내용은 https://aka.ms/dotnet-cli-telemetry를 참조하세요.

----------------
ASP.NET Core HTTPS 개발 인증서를 설치했습니다.
인증서를 신뢰하려면 'dotnet dev-certs https --trust'를 실행합니다(Windows 및 macOS만).
HTTPS에 대한 자세한 정보: https://aka.ms/dotnet-https
----------------
첫 번째 앱 작성: https://aka.ms/dotnet-hello-world
새로운 기능 확인: https://aka.ms/dotnet-whats-new
설명서 살펴보기: https://aka.ms/dotnet-docs
GitHub에서 문제 보고 및 소스 찾기: https://github.com/dotnet/core
사용 가능한 명령을 보려면 'dotnet --help'를 사용하거나 https://aka.ms/dotnet-cli를 방문하세요.
--------------------------------------------------------------------------------------

이렇게 출력된 후 부터는 시간이 좀 걸립니다. 느긋하게 빌드를 즐기세요. 한글로 빌드를 즐기는 것도 오랫만입니다. goormide니까 즐길 수 있는 거겠죠.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Done restoring /root/PowerShell/src/powershell-unix
Run dotnet restore /root/PowerShell/src/TypeCatalogGen --runtime linux-x64 /property:SDKToUse=Microsoft.NET.Sdk --verbosity quiet
Done restoring /root/PowerShell/src/TypeCatalogGen
Run dotnet restore /root/PowerShell/src/ResGen --runtime linux-x64 /property:SDKToUse=Microsoft.NET.Sdk --verbosity quiet
Done restoring /root/PowerShell/src/ResGen
Run dotnet restore /root/PowerShell/src/Modules --runtime linux-x64 /property:SDKToUse=Microsoft.NET.Sdk --verbosity quiet
Run dotnet restore /root/PowerShell/src/Modules --runtime linux-x64 /property:SDKToUse=Microsoft.NET.Sdk --verbosity quiet
Done restoring /root/PowerShell/src/Modules
Run ResGen (generating C# bindings for resx files)
Run TypeGen (generating CorePsTypeCatalog.cs)
Run dotnet publish --no-restore /property:GenerateFullPaths=true /property:IsWindows=false --configuration Debug --framework net5.0 --runtime linux-
x64 /property:SDKToUse=Microsoft.NET.Sdk.WindowsDesktop from /root/PowerShell/src/powershell-unix
.NET용 Microsoft (R) Build Engine 버전 16.7.0-preview-20360-03+188921e2f
Copyright (C) Microsoft Corporation. All rights reserved.

  System.Management.Automation -> /root/PowerShell/src/System.Management.Automation/bin/Debug/net5.0/System.Management.Automation.dll
  Microsoft.PowerShell.Security -> /root/PowerShell/src/Microsoft.PowerShell.Security/bin/Debug/net5.0/Microsoft.PowerShell.Security.dll
  Microsoft.PowerShell.Commands.Management -> /root/PowerShell/src/Microsoft.PowerShell.Commands.Management/bin/Debug/net5.0/Microsoft.PowerShell.Co
mmands.Management.dll
  Microsoft.PowerShell.MarkdownRender -> /root/PowerShell/src/Microsoft.PowerShell.MarkdownRender/bin/Debug/net5.0/Microsoft.PowerShell.MarkdownRend
er.dll
  Microsoft.PowerShell.Commands.Utility -> /root/PowerShell/src/Microsoft.PowerShell.Commands.Utility/bin/Debug/net5.0/Microsoft.PowerShell.Commands
.Utility.dll
  Microsoft.PowerShell.ConsoleHost -> /root/PowerShell/src/Microsoft.PowerShell.ConsoleHost/bin/Debug/net5.0/Microsoft.PowerShell.ConsoleHost.dll
  Microsoft.PowerShell.SDK -> /root/PowerShell/src/Microsoft.PowerShell.SDK/bin/Debug/net5.0/Microsoft.PowerShell.SDK.dll
  powershell-unix -> /root/PowerShell/src/powershell-unix/bin/Debug/net5.0/linux-x64/pwsh.dll
  powershell-unix -> /root/PowerShell/src/powershell-unix/bin/Debug/net5.0/linux-x64/publish/
PowerShell output: /root/PowerShell/src/powershell-unix/bin/Debug/net5.0/linux-x64/publish/pwsh
Restore PowerShell modules to /root/PowerShell/src/powershell-unix/bin/Debug/net5.0/linux-x64/publish
Name='PowerShellGet', Version='2.2.4', Destination='/root/PowerShell/src/powershell-unix/bin/Debug/net5.0/linux-x64/publish/Modules'
Name='PackageManagement', Version='1.4.7', Destination='/root/PowerShell/src/powershell-unix/bin/Debug/net5.0/linux-x64/publish/Modules'
Name='Microsoft.PowerShell.Archive', Version='1.2.5', Destination='/root/PowerShell/src/powershell-unix/bin/Debug/net5.0/linux-x64/publish/Modules'
Name='PSReadLine', Version='2.0.2', Destination='/root/PowerShell/src/powershell-unix/bin/Debug/net5.0/linux-x64/publish/Modules'
Name='ThreadJob', Version='2.0.3', Destination='/root/PowerShell/src/powershell-unix/bin/Debug/net5.0/linux-x64/publish/Modules'
Name='PSDesiredStateConfiguration', Version='2.0.5', Destination='/root/PowerShell/src/powershell-unix/bin/Debug/net5.0/linux-x64/publish/Modules'
PS /root/PowerShell>

Start-PSPester

Pester는 Powershell의 UnitTest Framework입니다.

1
Start-PSPester

Start-PSPester의 결과까지 전부 싣는 것은 생략하겠습니다. 내용이 너무 많고 시간도 많이 걸립니다. # goormide에서는 1시간도 더 걸립니다.

이로써 최신 버전의 pwsh을 goorm ide의 ubuntu에 함께 빌드해 보았습니다. 저는 퍼포먼스 엔지니어는 아니지만, 비용-속도-기능 중에서 둘 만을 선택할 수 있다고 알고 있습니다. 성능을 좀 무시해도 저비용으로 확실한 기능을 오퍼레이션이라면, Powershell이 최적인 것 같습니다.

이번 편은 build log와 같은 내용이었습니다. 다음 편!

레퍼런스

공유하기

tkim
글쓴이
tkim
Software Engineer