gpt4 book ai didi

powershell - 获取VS2015中的Nuget软件包的许可证

转载 作者:行者123 更新时间:2023-12-03 00:48:19 26 4
gpt4 key购买 nike

有什么方法可以下载Nuget软件包许可证?我知道这已经受到质疑/回答,但我想在VS2015 Update 2中使用。有一个Powershell脚本检查我的项目,然后创建.txt文件,其文件名带有许可证URL。

最佳答案

我已经设法通过Visual Studio 2015 Update 2获得了许可证列表:

Split-Path -parent $dte.Solution.FileName | cd; New-Item -ItemType Directory -Force -Path ".\licenses"; @( Get-Project -All | ? { $_.ProjectName } | % { Get-Package -ProjectName $_.ProjectName | ? { $_.LicenseUrl } } ) | Sort-Object Id -Unique | % { $pkg = $_; Try { if ($_.Id -notlike 'microsoft*' -and $_.LicenseUrl.StartsWith('http')) { Write-Host ("Download license for package" + $pkg.Id + " from " + $pkg.LicenseUrl); (New-Object System.Net.WebClient).DownloadFile($_.LicenseUrl, (Join-Path (pwd) 'licenses\') + $_.Id + ".html"); } } Catch [system.exception] { Write-Host ("Could not download license for" + $pkg.Id) }  }

您可能需要修改下载路径,当前它会在解决方案文件夹中创建许可证子文件夹并在此处下载。它还过滤掉所有Microsoft软件包,但是如果您需要它们,可以轻松修改代码。

此代码基于 this帖子中的代码。而且我确信它可以改进,因为我对Powershell的了解并不多。

关于powershell - 获取VS2015中的Nuget软件包的许可证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37034860/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com