Развертывание PowerShell с NANT - проблема с аргументами скрипта
-
09-12-2019 - |
Вопрос
У меня есть скрипт PowerShell обновление моего решения:
Add-PSSnapin Microsoft.SharePoint.PowerShell
write-host $args[0]
Update-SPSolution -Identity PkbInfo.SP.wsp -literalpath $args[0] -GACDeployment
.
Когда я выполняю его с помощью SP 2010 Management Shell (без Add-PSSnapin, конечно), он работает нормально, но когда я пытаюсь выполнить его с помощью команды NANT:
<target name="sp.update">
<exec failonerror="true" program="${powershell.exe}">
<arg value="-noprofile" />
<arg value="-nologo" />
<arg value="-noninteractive" />
<arg value="-command" />
<arg value="${ps.script.name} ${ps.copyto.folder}" />
</exec>
</target>
.
Я получаю ошибку:
[exec] Update-SPSolution : c:\shared\PkbInfo.wsp: The specified file was no
t found.
[exec] At C:\Users\me\Documents\production\sharepoint\nant_powershell
.ps1:5 char
[exec] :18
[exec] + Update-SPSolution <<<< -Identity PkbInfo.SP.wsp -literalpath $arg
s[0] -GACDe
[exec] ployment
[exec] + CategoryInfo : ReadError: (:) [Update-SPSolution], Fi
leNotFound
[exec] Exception
[exec] + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdl
etUpdateSo
[exec] lution
[exec]
[exec] Update-SPSolution : Zgłoszono wyjątek typu 'Microsoft.SharePoint.Pow
erShell.SPC
[exec] mdlet+SkipCurrentRecordException'.
.
Так выглядит как аргумент, который я прохожу, не проанализирован, что странно, потому что хост записи в обоих случаях (с оболочкой управления и NAT) отображается правильный путь. Любые идеи, почему $ args [0] в обновлении-spsolution не преобразуется в фактический аргумент при работе с nant?
Решение
Try and put a $() around your literal path, like so:
Update-SPSolution -Identity PkbInfo.SP.wsp -literalpath $($args[0]) -GACDeployment
You can also use Resolve-Path if your path is relative
On a side note: remember that Update-SPSolution only works as long as you update existing artefacts (eg. no new or deleted modules/features/rootfiles)
Другие советы
You try to run:
Update-SPSolution -Identity PkbInfo.SP.wsp
And you get the error:
[exec] Update-SPSolution : c:\shared\PkbInfo.wsp: The specified file was no
t found.
Check your filename :)
(I know you can have different identity and filename, but nobody ever changes that, right?)