簡體   English   中英

如何使用nuget.exe命令行獲取特定Visual Studio解決方案的軟件包列表

[英]How to get list of packages of a particular Visual Studio solution with nuget.exe command line

運行nuget restore命令后,我想獲得Visual Studio解決方案的軟件包列表。 如何從命令行或Powershell(取代Visual Studio)中進行操作?

您可以運行以下PowerShell腳本來列出解決方案中所有已安裝的軟件包。 請修改$ SOLUTIONROOT作為您的解決方案路徑。

#This will be the root folder of all your solutions - we will search all  children of this folder
$SOLUTIONROOT = "D:\Visual Studio 2015 Project\SO Case Sample\PackageSource"

Function ListAllPackages ($BaseDirectory)
{
    Write-Host "Starting Package List - This may take a few minutes ..."
    $PACKAGECONFIGS = Get-ChildItem -Recurse -Force $BaseDirectory -ErrorAction SilentlyContinue | 
        Where-Object { ($_.PSIsContainer -eq $false) -and  ( $_.Name -eq "packages.config")}
    ForEach($PACKAGECONFIG in $PACKAGECONFIGS)
        {
            $path = $PACKAGECONFIG.FullName
            $xml = [xml]$packages = Get-Content $path
                            foreach($package in $packages.packages.package)
                            {
                                 Write-Host $package.id
                             }

        }
}

ListAllPackages $SOLUTIONROOT
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM