我會使用包配置文件
建設的路徑自己
# Get solution folder
$PathToSolution = "C:\Some\Path\SolutionFolder"
# find all packages under the solution folder
$configs = gci $PathToSolution -Filter packages.config -recurse
# get content of every package config file
$configs.fullname | %{[xml]$packages = Get-Content $_;
$packages.packages.package | foreach{
# Get pacakge attributes
$packageId=$_.id;
$packageVersion=$_.version;
# Build the path from the build attributes
$Path="$PathToSolution\packages\$packageId.$PackageVersion";
Write-output $Path}}
我想補充的唯一事情是包路徑的唯一性檢查,因爲很有可能你使用的是包在一個以上項目