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

时间:2021-05-14 02:09:29

I'm attempting to get the license URLs for each package in a project programmatically using the techniques described here and here.

我正在尝试使用此处和此处描述的技术以编程方式获取项目中每个包的许可URL。

The output of Get-Package | Select-Object Id,LicenseUrl seems like it should work, but LicenseUrl is empty:

Get-Package的输出Select-Object Id,LicenseUrl似乎应该可以工作,但LicenseUrl是空的:

PM> Get-Package | Select-Object Id,LicenseUrl

Id                                                                                                  LicenseUrl                                                                                         
--                                                                                                  ----------                                                                                                                                                                                                                                                        
Castle.Core                                                                                                                                                                                            
CommonServiceLocator                                                                                                                                                                                   
Microsoft.AspNet.Mvc                                                                                                                                                                                   
Microsoft.AspNet.Razor                                                                                                                                                                                 
Microsoft.AspNet.WebApi                                                                                                                                                                                
Microsoft.AspNet.WebApi.Client                                                                                                                                                                         
Microsoft.AspNet.WebApi.Core                                                                                                                                                                           
Microsoft.AspNet.WebApi.WebHost                                                                                                                                                                        
Microsoft.AspNet.WebPages                                                                                                                                                                              
Microsoft.Web.DistributedCache                                                                                                                                                                         
Microsoft.Web.Infrastructure        

Is there something I'm missing? Has the schema of these package objects changed?

有什么我想念的吗?这些包对象的架构是否已更改?

2 个解决方案

#1


1  

The LicenseUrl is back in Visual Studio 2015 Update 2. 在VS包管理器控制台中使用Get-Package时,LicenseUrl显示为空

LicenseUrl返回Visual Studio 2015 Update 2。

If you use Visual Sutio 2015 Update 1 with Nuget Package Manager 3.3.0, the LicenseUrl property is unavailable, but there is still a way to get license URLs. This script works for me:

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

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

Here's the reference for Open-PackagePage cmdlet parameters: https://docs.nuget.org/consume/package-manager-console-powershell-reference

以下是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.

The help page warns that this command will be deprecated after NuGet 3.0 RTM. The script displays warning about deprecated command (highlighted below) but it still works.

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

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

#2


0  

Your PowerShell script works fine in Visual Studio 2013.

您的PowerShell脚本在Visual Studio 2013中正常工作。

I am guessing you are using Visual Studio 2015.

我猜你正在使用Visual Studio 2015。

In Visual Studio 2015 the package object returned is not the same as it is in NuGet v2 and various properties and methods are no longer available. If you run the following powershell command you can see the properties that are available in NuGet 3.

在Visual Studio 2015中,返回的包对象与NuGet v2中的包对象不同,并且各种属性和方法不再可用。如果运行以下powershell命令,则可以看到NuGet 3中可用的属性。

Get-Package | Get-Member

Just looking at the properties available in NuGet 3 we have:

只要看看NuGet 3中的可用属性,我们就有:

AllVersions
AsyncLazyVersions
Id
ProjectName
Version
Versions

So there is no LicenseUrl available in NuGet 3.

因此NuGet 3中没有可用的LicenseUrl。

#1


1  

The LicenseUrl is back in Visual Studio 2015 Update 2. 在VS包管理器控制台中使用Get-Package时,LicenseUrl显示为空

LicenseUrl返回Visual Studio 2015 Update 2。

If you use Visual Sutio 2015 Update 1 with Nuget Package Manager 3.3.0, the LicenseUrl property is unavailable, but there is still a way to get license URLs. This script works for me:

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

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

Here's the reference for Open-PackagePage cmdlet parameters: https://docs.nuget.org/consume/package-manager-console-powershell-reference

以下是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.

The help page warns that this command will be deprecated after NuGet 3.0 RTM. The script displays warning about deprecated command (highlighted below) but it still works.

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

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

#2


0  

Your PowerShell script works fine in Visual Studio 2013.

您的PowerShell脚本在Visual Studio 2013中正常工作。

I am guessing you are using Visual Studio 2015.

我猜你正在使用Visual Studio 2015。

In Visual Studio 2015 the package object returned is not the same as it is in NuGet v2 and various properties and methods are no longer available. If you run the following powershell command you can see the properties that are available in NuGet 3.

在Visual Studio 2015中,返回的包对象与NuGet v2中的包对象不同,并且各种属性和方法不再可用。如果运行以下powershell命令,则可以看到NuGet 3中可用的属性。

Get-Package | Get-Member

Just looking at the properties available in NuGet 3 we have:

只要看看NuGet 3中的可用属性,我们就有:

AllVersions
AsyncLazyVersions
Id
ProjectName
Version
Versions

So there is no LicenseUrl available in NuGet 3.

因此NuGet 3中没有可用的LicenseUrl。