使用Nuget查找第三方许可证 [英] Finding third party licenses with Nuget

查看:311
本文介绍了使用Nuget查找第三方许可证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是NuGet的新手,来自Maven世界.

I'm a bit of a NuGet newbie and have come from the Maven world.

最近,我一直负责为我们的项目更新第三方许可信息.使用Maven项目,我已经能够使用license:download-licenses插件来获取许可证信息.

Recently I've been tasked with updating the third party licence information for our projects. Working with the Maven projects I've been able to use the license:download-licenses plugin to get the licence information.

我想知道的是,是否有一种使用Nuget来获取此信息的方法?最好使用命令行界面,这样我就可以在CI构建级别上使其自动化.从大型手动预构建步骤中删除它.

What I'm wondering is if there is a way to get this information using Nuget? Preferably by using the command line interface so I can automate it at a CI build level. To remove it from the large manual pre build step.

由于找不到任何实用程序来执行此操作,因此我将 LegSec命令行实用程序放在一起.

Since I wasn't able to find any utilities to do this I put together the LegSec command line utility.

推荐答案

据我所知,作为CI构建的一部分,目前没有任何可直接从命令行直接获取许可证信息的工具.您需要创建一个应用程序以打开.nupkg zip文件,从.nuspec文件中提取许可证URL,然后从该URL下载许可证.

As far as I am aware there is nothing currently available to get the license information directly from the command line as part of a CI build. You would need to create an application to open the .nupkg zip file, extract the license url from the .nuspec file and download the license from this url.

或者,您可以使用Visual Studio内的程序包管理器控制台窗口,并通过一些PowerShell来下载许可证文件.

Alternatively you could use the package manager console window inside Visual Studio and with a bit of PowerShell download the license files.

下面显示了一个简单示例,该示例获取项目中所有软件包的许可证文件.这将需要扩展,以获取解决方案中的所有项目,您应该能够使用Get-Project cmdlet来完成该项目.这仍然需要有人运行脚本来下载许可证.

A simple example that gets the license file for all packages in a project is shown below. This would need to be extended to get all the projects in the solution which you should be able to do with the Get-Project cmdlet. This would still require someone to run the script to download the licenses.

$wc = New-Object System.Net.WebClient
Get-Package -ProjectName YourProject | ForEach-Object {
    $wc.DownloadFile($_.LicenseUrl, 'd:\licenses\' + $_.Id + ".html")
}

这篇关于使用Nuget查找第三方许可证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆