我有以下Powershell脚本:
param(
[Parameter(Mandatory = $true, Position = 1)]$PackageId,
$PackagesDir = "$env:USERPROFILE\.nuget\packages",
$Flavour = 'net462',
$Source)
if (-not (Test-Path "$PackagesDir\nuget.exe"))
{
mkdir $PackagesDir -ErrorAction SilentlyContinue
curl -Uri "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile "$PackagesDir\nuget.exe"
}
if ($Source)
{
$SourceSwitch = "-Source","$Source"
}
&"$PackagesDir\nuget.exe" install $PackageId -OutputDirectory $PackagesDir -NonInteractive $SourceSwitch
$PkgDir = $(&"$PackagesDir\nuget.exe" list $PackageId -source $PackagesDir) -replace ' ','.'
$Base = "$PackagesDir\$PkgDir\lib\$Flavour\$PackageId"
@{
Path = (dir "$Base.dll","$Base.exe" -ErrorAction SilentlyContinue).FullName
}
它执行以下操作:
我希望软件包位于XYZ \ 1.2.3中,而不是XYZ.1.2.3中
我该怎么做?
P.S。
对于脚本的其他改进,我将感到高兴,因为我是nuget的新手,可能做错了所有事情。
答案 0 :(得分:0)
答案是按此处所述使用nuget add命令- https://docs.microsoft.com/en-us/nuget/tools/cli-ref-add
此布局称为分层源。