0

1: install-spsolution Solution.wsp -webapplication "webapplication" -GACDeployment –force

2: install-spsolution Solution.wsp -GACDeployment –force

Which of above is best practice?

2 Answers 2

2

You can only deploy a package using -WebApplication if the artifacts in the solution has WebApplication scope. When packaging the solution package Visual Studio will handle this for you detecting the scope of the artifacts.

You will get an error in PowerShell if you try to deploy a solution that has WebApplication scoped artifacts at farm scope and vice versa.

To check if a solution has one scope or another do this

Get-SPSolution <yoursolution.wsp> | Select ContainsWebApplicationResource

3
  • I have 4 project solutions scoped at Farm, WebApplication, Site and Web level respectively... Can you tell me the powershell to be used. Do you mean to say that on the the project with scope as WebApplication must be installed using -WebApplication and this must be omitted from other solutions?
    – variable
    Commented Feb 6, 2014 at 9:47
  • Yep that is correct. Solutions can only have Farm and WebApplication scope. Features can have Farm, WebApplication, Site and Web scope Commented Feb 6, 2014 at 14:37
  • Normally timer job based solutions (provided they don't have Web Parts) are candidate for globally deployed solutions. Commented Feb 6, 2014 at 23:37
1
SPSolution.ContainsWebApplicationResource can be used to check whether solution contains web application resources or not. In PowerShell scripts, you can use following commands:

# Deploy solution
$Solution = Get-SPSolution | ? {($_.Name -eq $SolutionPackageName) -and ($_.Deployed -eq $false)}
if($Solution -ne $null)
{
    if($Solution.ContainsWebApplicationResource)   
    {
        Install-SPSolution -Identity $SolutionPackageName -WebApplication $WebApplication -GACDeployment -Confirm:$false
    }
    else
    {
        Install-SPSolution -Identity $SolutionPackageName -GACDeployment -Confirm:$false
    }  
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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