在VS包管理器控制台中使用Get-Package时,LicenseUrl显示为空

时间:2015-09-17 19:39:12

标签: visual-studio nuget visual-studio-2015 nuget-package

我尝试使用herehere所述的技术以编程方式获取项目中每个包的许可URL。

select LPAD(trim(id), 2) from table 的输出似乎应该有效,但LicenseUrl为空:

Get-Package | Select-Object Id,LicenseUrl

我有什么遗失的东西吗?这些包对象的架构是否已更改?

1 个答案:

答案 0 :(得分:1)

LicenseUrl 返回Visual Studio 2015 Update 2 enter image description here

如果您对Nuget Package Manager 3.3.0使用Visual Sutio 2015 Update 1 ,则 LicenseUrl 属性不可用,但仍有办法获取许可证URL。这个脚本适合我:

PM> Get-Package | % { $pkg = $_.Id ; Write-Host $_.ProjectName "-" $pkg;
        $url = Open-PackagePage $pkg -License -WhatIf -PassThru; 
        Write-Host "License URL: " $url }

以下是Open-PackagePage cmdlet参数的参考:https://docs.nuget.org/consume/package-manager-console-powershell-reference

-License
    Indicates the cmdlet should open the LicenseUrl of the specified package. If neither LicenseUrl nor ReportAbuseUrl 
    is set, the cmdlet will open the Proje
    ctUrl by default.

-PassThru
    If specified, the cmdlet will return the value of the requested URL.

帮助页面警告在NuGet 3.0 RTM之后将弃用此命令。该脚本显示有关已弃用命令的警告(在下面突出显示),但它仍然有效。

enter image description here