Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a powershell script updating my solution:

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

When I execute it with SP 2010 management shell (without Add-PSSnapin of course) it runs ok, but when I try to execute it with nant command:

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

I get an error:

     [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'.

So it looks like the argument i'm passing is not parsed, which is strange, because Write-Host in both cases (with management shell and nant) displays the correct path. Any ideas why the $args[0] in Update-SPSolution is not converted to actual argument when running with nant?

share|improve this question

2 Answers 2

up vote 0 down vote accepted

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)

share|improve this answer

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

share|improve this answer
    
the 'file not found' occurs because it tries to exec Identity PkbInfo.SP.wsp -literalpath $args[0] -GACDeployment, so obviously i do not have a file named '$args[0]' ;) –  matt137 Jul 9 '12 at 6:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.