12
23

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 5 years have passed since last update.

Windows10のパッケージ管理

Last updated at Posted at 2019-02-12

みなさん、こんにちは。
ノンプログラマーの(@cogome )です。

私は今までMacを愛用していましたが、諸事情によりWindowsPCを使用することになりました。
今回はWindowsPCの開発環境を整えるため、PackageManagementを導入した際の備忘録です。

概要

OSをクリーンインストール後、Windows Update済みの状態からパッケージをインストールします。

#ExecutionPolicyをRemoteSignedに設定

PowerShell
PS C:\WINDOWS\system32> Get-ExecutionPolicy
Restricted
PS C:\WINDOWS\system32> Set-ExecutionPolicy RemoteSigned

実行ポリシーの変更
実行ポリシーは、信頼されていないスクリプトからの保護に役立ちます。実行ポリシーを変更すると、about_Execution_Policies
のヘルプ トピック (https://go.microsoft.com/fwlink/?LinkID=135170)
で説明されているセキュリティ上の危険にさらされる可能性があります。実行ポリシーを変更しますか?
[Y] はい(Y)  [A] すべて続行(A)  [N] いいえ(N)  [L] すべて無視(L)  [S] 中断(S)  [?] ヘルプ (既定値は "N"): y

再起動

再起動します。

PowerShellGetのアップデート

PowerShell
PS C:\WINDOWS\system32> Get-Module PowerShellGet,PackageManagement -ListAvailable


    ディレクトリ: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}


PS C:\WINDOWS\system32> Install-Module PowerShellGet -Scope CurrentUser -Force -AllowClobber

続行するには NuGet プロバイダーが必要です
PowerShellGet  NuGet ベースのリポジトリを操作するには、'2.8.5.201' 以降のバージョンの NuGet
プロバイダーが必要です。NuGet プロバイダーは 'C:\Program Files\PackageManagement\ProviderAssemblies' または
'C:\Users\cogome\AppData\Local\PackageManagement\ProviderAssemblies' に配置する必要があります。'Install-PackageProvider
 -Name NuGet -MinimumVersion 2.8.5.201 -Force' を実行して NuGet プロバイダーをインストールすることもできます。今すぐ
PowerShellGet  NuGet プロバイダーをインストールしてインポートしますか?
[Y] はい(Y)  [N] いいえ(N)  [S] 中断(S)  [?] ヘルプ (既定値は "Y"): y
PS C:\WINDOWS\system32> Get-Module PowerShellGet,PackageManagement -ListAvailable


    ディレクトリ: C:\Users\cogome\Documents\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.3.1      PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script     2.0.4      PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCap...


    ディレクトリ: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}

再起動

再起動します。

PackageProviderの導入

PowerShell
PS C:\WINDOWS\system32> Get-PackageProvider

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet            2.0.4.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent


PS C:\WINDOWS\system32> Find-PackageProvider

Name                           Version          Source           Summary
----                           -------          ------           -------
nuget                          2.8.5.208        https://onege... NuGet provider for the OneGet meta-package manager
psl                            1.0.0.210        https://onege... psl provider for the OneGet meta-package manager
chocolatey                     2.8.5.130        https://onege... ChocolateyPrototype provider for the OneGet meta-pa...
PowerShellGet                  2.0.4            PSGallery        PowerShell module with commands for discovering, in...
ContainerImage                 0.6.4.0          PSGallery        This is a PackageManagement provider module which h...
NanoServerPackage              1.0.1.0          PSGallery        A PackageManagement provider to  Discover, Save and...
GitLabProvider                 1.3.8            PSGallery        GitLab PackageManagement provider
DockerMsftProvider             1.0.0.5          PSGallery        PowerShell module with commands for discovering, in...
ChocolateyGet                  1.0.0.1          PSGallery        An PowerShell OneGet provider that discovers packag...
DockerMsftProviderInsider      1.0.0.2          PSGallery        PowerShell module with commands for discovering, in...
DockerProvider                 0.0.0.3          PSGallery        PowerShell module with commands for discovering, in...
GistProvider                   0.6              PSGallery        Gist-as-a-Package - PackageManagement  PowerShell P...
GitHubProvider                 0.5              PSGallery        GitHub-as-a-Package - PackageManagement PowerShell ...
TSDProvider                    0.2              PSGallery        PowerShell PackageManager provider to search & inst...
OfficeProvider                 1.0.0.1          PSGallery        OfficeProvider allows users to install Microsoft Of...
MyAlbum                        0.1.2            PSGallery        MyAlbum provider discovers the photos in your remot...
0install                       2.16.3           PSGallery        OneGet Package Provider for Zero Install
AppxGet                        0.1.0.1          PSGallery        Powershell Package Management (OneGet) Provider for...
WSAProvider                    1.0.0.4          PSGallery        Provider to Discover, Install and inventory windows...
ChocoOneGet                    0.4.0            PSGallery        OneGet provider for Chocolatey


PS C:\WINDOWS\system32> Install-PackageProvider ChocolateyGet

The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'PSGallery'?
[Y] はい(Y)  [A] すべて続行(A)  [N] いいえ(N)  [L] すべて無視(L)  [S] 中断(S)  [?] ヘルプ (既定値は "N"): y

Name                           Version          Source           Summary
----                           -------          ------           -------
ChocolateyGet                  1.0.0.1          PSGallery        An PowerShell OneGet provider that discovers packag...


PS C:\WINDOWS\system32> Get-PackageProvider

Name                     Version          DynamicOptions
----                     -------          --------------
ChocolateyGet            1.0.0.1          AdditionalArguments
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet            2.0.4.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

パッケージのインストール

PowerShell
PS C:\WINDOWS\system32> Find-Package GoogleChrome -ProviderName ChocolateyGet

Choco.exe is required to continue
ChocolateyGet is built on Choco.exe. Do you want ChocolateyGet to install Choco.exe from
'https://chocolatey.org/install.ps1' now?
[Y] はい(Y)  [N] いいえ(N)  [S] 中断(S)  [?] ヘルプ (既定値は "Y"): y

Name                           Version          Source           Summary
----                           -------          ------           -------
GoogleChrome                   72.0.3626.96     https://www.c...


PS C:\WINDOWS\system32> Install-Package GoogleChrome -ProviderName ChocolateyGet

The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'https://www.chocolatey.org'?
[Y] はい(Y)  [A] すべて続行(A)  [N] いいえ(N)  [L] すべて無視(L)  [S] 中断(S)  [?] ヘルプ (既定値は "N"): y

Are you sure you want to perform this action?
Installing package 'GoogleChrome'. By Installing you accept licenses for the package(s). The package possibly needs to
run 'chocolateyInstall.ps1'.
[Y] はい(Y)  [N] いいえ(N)  [S] 中断(S)  [?] ヘルプ (既定値は "Y"): y

Name                           Version          Source           Summary
----                           -------          ------           -------
GoogleChrome                   v72.0.3626.96    https://www.c...

まとめ

  1. ExecutionPolicyをRemoteSignedに設定
  2. 再起動
  3. PowerShellGetのアップデート
  4. 再起動
  5. PackageProviderの導入
  6. パッケージのインストール

謝辞

12
23
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
12
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?