PowerShell 스크립트를 통해 NuGet 설치
NuGet은 Visual Studio 확장으로 설치되는 것으로 알고 있습니다.
http://docs.nuget.org/docs/start-here/installing-nuget
그러나 VS가 설치되지 않은 시스템에 NuGet이 필요한 경우에는 어떻게 합니까?
특히 파워쉘 스크립트로 NuGet을 설치하고 싶습니다.
- 관리자 권한으로 Powershell 실행
- TLS12에 대해 아래 PowerShell 보안 프로토콜 명령을 입력합니다.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
다음은 PowerShell 스크립트로 예상되는 작업을 수행할 수 있는 간단한 방법은 다음과 같습니다.
$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$targetNugetExe = "$rootPath\nuget.exe"
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
Set-Alias nuget $targetNugetExe -Scope Global -Verbose
참고:Invoke-WebRequest
cmdlet은 PowerShell v3.0과 함께 도착했습니다.이 기사는 아이디어를 줍니다.
이것도 할 수 있을 것 같습니다.PS 예제:
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Visual Studio 없이 Nuget: http://nuget.org/nuget.exe 에서 Nuget을 이용할 수 있습니다.
이를 사용한 명령줄 실행은 다음을 확인하십시오. http://docs.nuget.org/docs/reference/command-line-reference
파워셸에 관해서는, 그냥 누제를 복사해요.기계로 이동합니다.설치할 필요는 없으며, 위 설명서의 명령을 사용하여 실행하기만 하면 됩니다.
PowerShell을 사용하지만 스크립트를 작성할 필요가 없는 경우:
Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile Nuget.exe
위의 어떤 해결책도 저에게 도움이 되지 않았고, 저는 그 문제를 설명하는 기사를 발견했습니다.시스템의 보안 프로토콜이 더 이상 사용되지 않으므로 Provider Package와 일치하는 항목을 찾을 수 없다는 오류 메시지가 표시됩니다.
보안 프로토콜을 업그레이드하기 위한 기본 단계는 다음과 같습니다.
두 cmdlet을 모두 실행하여 설정합니다.NET Framework 강력한 암호화 레지스트리 키.그런 다음 PowerShell을 재시작하고 보안 프로토콜 TLS 1.2가 추가되었는지 확인합니다.마지막으로 PowerShellGet 모듈을 설치합니다.
첫 번째 cmdlet은 64비트에 강력한 암호화를 설정하는 것입니다.Net Framework(버전 4 이상).
[PS] C:\>Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
1
[PS] C:\>Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
The second cmdlet is to set strong cryptography on 32 bit .Net Framework (version 4 and above).
[PS] C:\>Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
1
[PS] C:\>Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
Restart Powershell and check for supported security protocols.
[PS] C:\>[Net.ServicePointManager]::SecurityProtocol
Tls, Tls11, Tls12
1
2
[PS] C:\>[Net.ServicePointManager]::SecurityProtocol
Tls, Tls11, Tls12
Run the command Install-Module PowershellGet -Force and press Y to install NuGet provider, follow with Enter.
[PS] C:\>Install-Module PowershellGet -Force
NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\administrator.EXOIP\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install
and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
[PS] C:\>Install-Module PowershellGet -Force
NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\administrator.EXOIP\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install
and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
언급URL : https://stackoverflow.com/questions/16657778/install-nuget-via-powershell-script
'programing' 카테고리의 다른 글
파일에 NS 로그인하는 방법 (0) | 2023.09.15 |
---|---|
PowerShell 원격에서 "액세스 거부" 오류가 발생했습니다. (0) | 2023.09.10 |
CSS에서 패딩 속성의 폭이나 높이가 변경되지 않도록 하려면 어떻게 해야 합니까? (0) | 2023.09.10 |
MariaDB 계정이 데이터베이스에 대한 로컬 및 원격 액세스 권한을 가질 수 있습니까? (0) | 2023.09.10 |
Spring 3 / Thymeleaf에서 매개변수를 사용하여 지역화 메시지를 표시하는 방법 (0) | 2023.09.10 |