Tuesday, May 16, 2017

The Latest of Microsoft Office Developer Tools: Office Add-in Commands and SharePoint 2016 – Visual Studio

 

Office’s message at Build was loud and clear: Office is an open market for developers who want to reinvent productivity, backed by a consumer base of 1.2 billion users. Qi Lu welcomed developers to the Office ecosystem in his Build keynote, and showcased new robust extensibility features that enable you to create custom experiences in Office that look and feel native. A new wave of excitement and growth is sweeping through the Office ecosystem, and there is no better time to be an Office developer. And no better tool than Visual Studio to get started!

As a Visual Studio user, you can get started right away and take advantage of all the new Office extensibility goodness inside the IDE.

We are also pleased to announce Preview 2 of Microsoft Office Developer Tools for Visual Studio 2015. Preview 2 adds the support for SharePoint 2016 solutions and add-in development in Visual Studio 2015, on top of the new features available in Update 2 of Office Developer Tools. For Visual Studio “15,” SharePoint 2016 support is available by default when you install Office Developer Tools.

Now let’s take a closer look at how the Office Developer Tools optimize getting started with add-in development.

Tuesday, May 2, 2017

Sharepoint – Powershell–Deployment script for sharepoint solutions

 

Steps)

       1) Save below scrips in to spdeploy.ps1

       2) Open Sharepoint Manangement shell and run below command.

.\ spdeploy.ps1 –solutionName solution Name-location Location to solution file

 

param(
    [Parameter(Position=0, Mandatory="True",
        HelpMessage="Need the script filename to be tested.")]
    [string]
    # The Script to test
    $solutionName,
    [Parameter(Position=1, Mandatory="True",
        HelpMessage="Need the config filename for this Farm.")]
    [string]
    # Farm Config XML File
    $location
)   

$location = $location

$solutionName = $solutionName +'.wsp'

function solutionStatus([string]$solutionName ,[string]$location)
{
    try
    {
        $s = Get-SPSolution | where-object {$_.Name -eq $solutionName}
            if ($s -ne $null)
              {
                if ($s.Deployed -eq $true -And $s.JobExists -eq $False)
                   {
                     Write-Host -NoNewline $solutionName " found - "  -ForegroundColor Yellow
                     Write-Host -ForegroundColor Green "Updating $solutionName "
                     spUpdate $solutionName $location
                     WaitForSPSolutionJobToComplete $solutionName
                   }
                   else
                   {
                   Write-Host -NoNewline  $solutionName " found - Solution status - not deployed  "  -ForegroundColor Yellow
                   spRemove $solutionName $location
                   Write-Host -ForegroundColor Green "Removing $solutionName "
                   spInstall $solutionName $location
                   WaitForSPSolutionJobToComplete $solutionName
                   }
               }
             else
               {
                 Write-Host -NoNewline $solutionName " not found - "  -ForegroundColor Yellow
                 spInstall $solutionName $location
                 WaitForSPSolutionJobToComplete $solutionName
               }
               Write-Host  $solutionName " successfully deployed"  -ForegroundColor Green
               Write-host  "--------------------------------------------" -ForegroundColor Green
               $s.DeployedServers
        
         }
         catch
         {
          Write-Host  $_.Exception.Message  -ForegroundColor Red
         }
         
}

function spInstall([string]$solutionName ,[string]$location)
{
    $solution = Add-SPSolution -LiteralPath $location'\'$solutionName
         if ($solution.ContainsWebApplicationResource)
            {
            Write-Host -ForegroundColor Green "Deploying $solutionName "
            Install-SPSolution -Identity $solutionName -AllWebApplications -GACDeployment
            }
        else
            {
               Write-Host -ForegroundColor Green "Deploying $solutionName"
               Install-SPSolution -Identity $solutionName -GACDeployment
            }
}

function spUpdate([string]$solutionName ,[string]$location)
{
    Update-SPSolution -Identity $solutionName -LiteralPath $location'\'$solutionName -GACDeployment
}

function spUnInstall([string]$solutionName ,[string]$location)
{
   
}

function spRemove([string]$solutionName ,[string]$location)
{
Remove-SPSolution -Identity $solutionName -Confirm:$false
}

function WaitForSPSolutionJobToComplete([string]$solutionName)
{
    $solution = Get-SPSolution -Identity $solutionName -ErrorAction SilentlyContinue
 
    if ($solution)
    {
        if ($solution.JobExists)
        {
            Write-Host -NoNewLine "Waiting for solution to deploy :- " -ForegroundColor Yellow
            Write-Host  $solutionName -ForegroundColor Red
 
        }
        
        # Check if there is a timer job still associated with this solution and wait until it has finished
        while ($solution.JobExists)
        {
            $jobStatus = $solution.JobStatus
            
            # If the timer job succeeded then proceed
            if ($jobStatus -eq [Microsoft.SharePoint.Administration.SPRunningJobStatus]::Succeeded)
            {
                Write-Host "Solution '$solutionName' timer job suceeded"
                return $true
            }
            
            # If the timer job failed or was aborted then fail
            if ($jobStatus -eq [Microsoft.SharePoint.Administration.SPRunningJobStatus]::Aborted -or
                $jobStatus -eq [Microsoft.SharePoint.Administration.SPRunningJobStatus]::Failed)
            {
                Write-Host "Solution '$solutionName' has timer job status '$jobStatus'."
                return $false
            }
            
            Write-Host -NoNewLine "Waiting for solution to deploy :- " -ForegroundColor Yellow
            Write-Host  $solutionName -ForegroundColor Red
            Sleep 1
        }
        
        # Write a new line to the end of the '.....'
        Write-Host
    }
   
  
}

solutionStatus $solutionName $location