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 some webparts. All of them has a property to enter the Site URL i.e the URL where the deployment should happen. My server farm contains, multiple zones with different URLs. In order to deploy each webpart I should change the Site URL for each zone before I actually build the application. Could you please let me know an easy way where I can deploy the application once for all the different URLs of webparts?

The same Site URL is taken as webapp URL when deploying the application using Powershell.

function DeployWsp([string]$solutionName, [string[]]$webApplicationList, [bool]$redeploy = $true) {

    $solution = Get-SPSolution $solutionName -ea SilentlyContinue

    # Remove the existing solution if it already exists
    if($solution -ne $null -and $redeploy -eq $true)
    {       
        Write-Host "Solution $solutionName already exists... Removing." -nonewline
        if ($solution.ContainsWebApplicationResource) {
            $solution | Uninstall-SPSolution -AllWebApplications -Confirm:$false
        } else {
            $solution | Uninstall-SPSolution -Confirm:$false
        }       
        while ( $solution.JobExists ){
            write-host "." -nonewline
            sleep 2
        }
        Remove-SPSolution -Identity $solutionName -Confirm:$false
        while ( $solution.JobExists ){
            write-host "." -nonewline
            sleep 2
        }
        Write-Host " Done."
    }

    if ($solution -eq $null -or !$solution.Deployed )
    { 
        Write-Host "Deploying the $solutionName solution" -nonewline    
        $solution = Add-SPSolution "$pwd\$solutionName"

        for ($i=0; $i -lt $webApplicationList.length; $i++)
        {
            $webApplication = $webApplicationList[$i]

            if ($solution.ContainsWebApplicationResource) {
                Write-Host " to $webApplication." -nonewline    
                Install-SPSolution $solutionName -WebApplication $webApplication -GACDeployment:$($solution.ContainsGlobalAssembly) -CASPolicies:$($solution.ContainsCasPolicy) -force
            } else {
                Install-SPSolution $solutionName -GACDeployment:$($solution.ContainsGlobalAssembly) -CASPolicies:$($solution.ContainsCasPolicy) -force
            }
            do {
                Start-Sleep 5
                Write-Host "." -nonewline
            } while ($solution.JobExists)

            Write-Host " Done."
        }
    }

}

share|improve this question
add comment

1 Answer

What you should care about isn't the AAM zones, but the web application default zone. think it would be best to take the .wsp from the package and deploy it to each of the web applications using this Powershell command:

Add-SPSolution "C:\webpart.wsp"
Install-SPSolution –Identity webpart.wsp –AllWebApplications –GACDeployment

This will take care of deploying the wsp out to all the webapplications in the farm. You of course have to enable the feature after you deploy it.

share|improve this answer
    
Thanks for your answer. it does helpful. But, when building the web part application, I should mentioned the Site URL in the property of the web part solution. Otherwise, I am unable to build the webpart solution in VS.NET 2010. Could you please suggest me the best way to deal with this?I want my webpart should be of Web application independent without any broken links in it. –  Ram Mar 8 '13 at 9:26
    
More ever, I got all the abosolute URL's in my Web part application, I should convert them to relative URL's please advice. –  Ram Mar 8 '13 at 9:34
    
You don't need to specify the site url in the webpart solution. That will hardcode the site URL and leave you with a solution that isn't dynamic. Can you post your code that uses the Site URL? –  Mike Mar 8 '13 at 14:56
    
Thanks Mike. I have been struggling to fix this problem for the past one week. I got two solutions one for intranet and other is for branding. The following is the code (code behind for one of the control) for one of the webpart. –  Ram Mar 8 '13 at 15:10
    
public string SiteURL { get; set; } protected override void OnInit(EventArgs e) { base.OnInit(e); // Check properties if (string.IsNullOrEmpty(SiteURL) || string.IsNullOrEmpty(ListName) || string.IsNullOrEmpty(ContentType)) { (this.Parent as WebPart).Hidden = true; return; } –  Ram Mar 8 '13 at 15:13
show 9 more comments

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.