我有一个powershell脚本更新我的解决方案:

Add-PSSnapin Microsoft.SharePoint.PowerShell
write-host $args[0]
Update-SPSolution -Identity PkbInfo.SP.wsp -literalpath $args[0] -GACDeployment 
.

当我用sp 2010管理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'.
.

所以它看起来像是我传递的参数没有解析,这是奇怪的,因为两种情况下的写主机(带管理shell和nant)显示正确的路径。 任何想法为什么在用nant运行时,更新 - spsolution中的$ args [0]不会转换为实际参数?

有帮助吗?

解决方案

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?)

许可以下: CC-BY-SA归因
scroll top