我想将许多PowerShell脚本发布为构建系统上使用的Nuget包.
我想使用PowerShellGet为我和版本管理做安装工作.
我不希望这些脚本成为任何Visual Studio解决方案的一部分,而是作为独立脚本.
在任何系统上,配置的Nuget提供程序用户执行:
Install-Module MyModule
Run Code Online (Sandbox Code Playgroud)
从那时起,该模块的所有导出将永久可供该用户使用.用户也可以再次调用该命令来更新这些脚本的版本.
你可以在这里找到当前的包状态:GitHub
我已将Nuget提供程序添加并配置到我们的本地Nuget服务器
要做这个电话Get-PackageProvider -Name NuGet -ForceBootstrap和Set-PSRepository -Name My_Nuget_Repo -SourceLocation http://my-nuget/api -InstallationPolicy Trusted
Import-Module我可以通过Install-Modulecmdlet 安装该软件包,稍后我会在Get-InstalledModule列表中看到它.
但是,没有可用的功能.
此外,无论如何,但Install-Module不从我的包中调用任何脚本:
ScriptsToProcess从MyModule.psd1Install.ps1从tools文件夹调用Init.ps1从tools文件夹调用Import-Module(从Visual Studios安装时,相同的包正常工作Install-Package MyModule,调用脚本,导入PowerShell模块).
因为PowerShellGet基于OneGet它似乎问题是在Install-Packagecmdlet(在cmdlet中调用Install-Module). …
在Windows 11月更新(PackageManagement以及PowerShellGet1.0.0.1版本的模块)之后,我无法再将HTTPS NuGet服务器注册为PSRepository:
Register-PSRepository -Name test -SourceLocation https://some-nuget/api/v2
Run Code Online (Sandbox Code Playgroud)
它返回错误:
# Register-PSRepository : The specified Uri 'https://some-nuget/api/v2' for parameter 'SourceLocation' is an invalid Web Uri. Please ensure that it meets the Web Uri requirements.
Run Code Online (Sandbox Code Playgroud) 我试过Install-Package nodejs,这似乎做了一些事情:
PS C:\WINDOWS\system32> Install-Package nodejs
The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'chocolatey'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
Name Version Source Summary
---- ------- ------ -------
nodejs.install 11.10.0 chocolatey Node JS - Evented I/O for v8 JavaScript.
nodejs 11.10.0 chocolatey Node JS - Evented I/O for v8 …Run Code Online (Sandbox Code Playgroud) 几年前,有一个名为PackageManagement(又名 OneGet)的 Microsoft 包管理器,它似乎基于 PowerShell 命令约定,并且是可扩展的。
最近,微软推出了另一个名为winget的包管理器工具,该工具仍被视为预发布版本。似乎没有使用 PowerShell 约定。
这两者之间是什么关系呢?
WinGet 是否会取代 OneGet,或者是否会存在某种互操作性?
这是我在互联网上找到的常见解决方案无法解决的常见错误。
无法运行 Get-PsRepository、Install-Module 和相关 (OneGet?) 命令,否则它们会抛出“无法找到模块提供程序 (PowerShellGet)”错误。这似乎是 NuGet 包管理器模块的问题,但我不知道如何恢复。安装的包提供程序似乎有效
症状模式:
C:> [Net.ServicePointManager]::SecurityProtocol
Tls12
Run Code Online (Sandbox Code Playgroud)
获取-PSRepository
PackageManagement\Get-PackageSource : Unable to find module providers (PowerShellGet).
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4496 char:31
+ ... ckageSources = PackageManagement\Get-PackageSource @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...etPackageSource:GetPackageSource) [Get-PackageSource
], Exception
+ FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageSource
Run Code Online (Sandbox Code Playgroud)
注册-PSRepository -Default -Verbose
VERBOSE: PowerShell meta provider initialization failed.
VERBOSE: No match was found for the specified search criteria and provider name 'PowerShellGet'. Try
'Get-PackageProvider -ListAvailable' to see if the provider exists on the …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Powershell-Install-Package 从此处安装Microsoft.Experimental.IO库:https : //www.nuget.org/packages/Microsoft.Experimental.IO/1.0.0在Windows 10上。
我已经加入了nuget.org回购,当我使用命令“找到包-包含实验 ” Powershell的发现包,但是当我尝试安装它,我收到以下错误。
install-package Microsoft.Experimental.IO -verbose
VERBOSE: Skipping package provider provider 'NuGet'-- missing required option 'Destination'
VERBOSE: Skipping package provider provider 'NuGet'-- missing required option 'Destination'
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is 'NuGet'.
install-package : No match was found for the specified search criteria …Run Code Online (Sandbox Code Playgroud) 我已经ChocolateyGet在Powershell中添加了提供程序,因此我可以将它与PackageManagement(OneGet)一起使用,它可以工作,但我尝试安装的每个软件包都会发出警告:
https://www.chocolatey.org不是受信任的包源
然后要求确认.它还询问我是否同意该包的许可.
我想制作一个脚本来自动安装一些软件包,但是我需要这个脚本无人值守,现在不可能,因为它询问了前两个问题.
反正是否有规避/自动回复这些确认?像y或yesLinux上的命令?