Step by step procedure to deploy WSP solution using TFS Continuous Delivery process

Sriram
 
Technology Specialist
May 30, 2018
 
Rate this article
 
Views
5084

In our previous article, we have seen how to build the SharePoint solution from TFS.

In this article, we will see how to automate the deployment once the build is successful.

What is Continuous Delivery?

Continuous Deployment (CD) is the process to build, test, configure and deploy from a build to a production environment. Multiple testing or staging environments create a Release Pipeline to automate the creation of infrastructure and deployment of a new build. Successive environments support progressively longer-running activities of integration, load, and user acceptance testing. Continuous Integration starts the CD process and the pipeline stages each successive environment the next upon successful completion of tests.

Continuous Delivery may sequence multiple deployment “rings” for progressive exposure (also known as “controlling the blast radius”). Progressive exposure groups users who get to try new releases to monitor their experience in “rings.”  The first deployment ring is often a “canary” used to test new versions in production before a broader rollout. CD automates deployment from one ring to the next and may optionally depend on an approval step, in which a decision maker signs off on the changes electronically. CD may create an auditable record of the approval in order to satisfy regulatory procedures or other control objectives.

Deployment Process

 

Prerequisites

1. Make sure the user account that you’re going to use has permission to create Release Definition. User should be part of Basic or Advanced Group.

clip_image002

2. Enable PSRemoting – PSRemoting Configuration process

Enable PSRemoting will enable SharePoint servers to accept remote call from build servers.

Below are the steps we need to follow to enable PSRemoting.

On the SharePoint server:

    1. Open the SharePoint Management Shell with elevated administrative permission, by selecting ‘Run as administrator’
    2. Enable PowerShell remoting by running the following cmdlet: Enable-PSRemoting
    3. Enable the server to accept credentials using CredSSP: Enable-WSManCredSSP –Role Server
    4. Raise the PowerShell memory level to 1GB: Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1024

On the TFS build agent server(s):

ü Open the Windows PowerShell prompt with elevated administrative permission by selecting ‘Run as administrator’

ü If not previously done on this server, set the PowerShell execution policy to allow scripts to be run – at a minimum, the policy must be RemoteSigned:
Set-ExecutionPolicy RemoteSigned

ü Enable the server to pass credentials using CredSSP – replace the sample name with the name of your SharePoint server:
Enable-WSManCredSSP -Role client -DelegateComputer “MySharePointServer”  – Note that other permissible values for the DelegateComputer parameter include “*.mydomain.com” and “*”. However, a security best practice would be to limit the credential delegation to as small a scope as possible

Test PowerShell remoting and CredSSP authentication:

    • On the TFS build agent server, test remoting by starting a remote session to the SharePoint server: Enter-PSSession -ComputerName “MySharePointServer”    A successful test is one where the command prompt location changes to [MySharePointServer]: PS C:\Users\<username>
    • Type exit to close the remote session
    • Also on the TFS build agent server, test CredSSP authentication with the following cmdlet: Enter-PSSession -ComputerName “MySharePointServer” -Authentication CredSSP –Credential Get-Credential – This will force an authentication prompt to enter a username and password – specify a domain account which has permissions to the SharePoint server. As before, a successful test is one where the location of the command prompt changes.

3. Create Release Definition

Below are the steps to create Release Definition:

1. After successful build, go to Release tab in TFS server and click on Create Release Definition.

2. Select Empty Definition.

clip_image004

3. Provide Release Name.

4. Click on Link to Build Definition and select the latest build which you want to deploy.

5. We can add environments for Dev, Stg, Prod.

6. First let’s define task for the Dev environment then we can clone the definition to staging and production.

7. Click on (…) near the environment name and in the dropdown you can find below option.

clip_image006

8. Using the above option we can configure pre deployment and post deployment approvals and automate release once build successful.

9. In the right side click on “Add Tasks” to define the action.

10. Select Windows Machine File Copy and PowerShell option to copy the Artifacts to Destination server. We will be having below Tasks in Release option.

clip_image008

11. In Windows Machine File Copy option provide server details and destination details as mentioned below.

clip_image010

12. To Deploy WSP provide PowerShell script path from TFS in the PowerShell Tasks.

clip_image012

13. Clone the Dev environment and create staging and production and then do the necessary changes.

4. PowerShell scripts

We need two PowerShell script file in the solution folder

1. Scripts file to install/deploy solution in SharePoint. As we are going to run the PS script from windows PowerShell, add below line on top of the script.

if ( (Get-PSSnapin -Name Microsoft.Sharepoint.Powershell -ErrorAction SilentlyContinue) -eq $null )

{

Add-PsSnapin Microsoft.Sharepoint.Powershell

}

2. Scripts file to connect to SharePoint server remotely.

Sample:

New-PSSession -ComputerName “ServereName”;

Enter-PSSession -computername ” ServereName “;

Invoke-Command -computername ” ServereName ” -scriptblock{D: \Solution\WebDeploy.ps1 -solutionNames @(“parameter1”)};

Deployment

Now, when we run release, it will move all the necessary files to SharePoint server and then deploy the WSP. We will get status as below.

clip_image013

Common Deployment Issues

1. Error:

No artifacts are available in the build. Make sure that the build is publishing an artifact and try again.

Solution:

Need to provide /p:IsPackaging=True in MSBuild Arguments it will create Build Artificates fot the solution, if not solution will be built but it wont create packages

2. Error:

Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.

Solution:

When executing PowerShell script, if we need to remove existing wsp file, it will ask for confirmation, as Windows PowerShell is in NonInteractive mode it throws this error message. To avoid this error add -Confirm:$False; on that particular line.

Eg. Remove-SPSolution visualwebpartproject1.wsp -Confirm:$False;

Author Info

Sriram
 
Technology Specialist
 
Rate this article
 
Sriram T has been working in IT industry for over 6 years He holds Bachelor's degree in Computer Science Engineering. Sriram write articles and blogs related to SharePoint 2013, SharePoint ...read more
 

Delete the TFS Credentials from the Virtual Machine or Login to the TFS using Different Account

Sathish Nadarajan
 
Solution Architect
June 17, 2017
 
Rate this article
 
Views
4111

In general, it’s a common problem that in a particular VM, I have opened the Visual Studio and connected to a TFS. Let us see the Scenarios in which we require this article to be handy.

Scenario 1: While connecting to the TFS, I would have given my username and password. Later, someone else will be login into the VM using the same Service Account. But, when he tries to open the TFS, it will be automatically connected with my credentials.

Scenario 2: The TFS is opened with my credentials. I changed password from some other machine or in the AD password reset has happened. In that case, the TFS will be prompting with the credentials. But, if we give some invalid (old) password, then the Account will be locked.

To avoid these scenarios, a handy note is, always the TFS passwords were saved in the “Manage Windows Credentials”

1. Go to Control Panel.

clip_image002

2. Click on User Accounts

clip_image004

3. Click on “Manage Windows Credentials”

clip_image006

4. All the Windows Credentials Saved were listed here. Delete it appropriately.

Happy Coding,

Sathish Nadarajan.

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

How to migrate the test cases from an excel to TFS

Tarun Kumar Chatterjee
 
Net – Technology Specialist
February 26, 2016
 
Rate this article
 
Views
18373

In one of my project requirement it was said to upload all the test cases to TFS, I had an excel version. After doing a round of research found a way out of using a free 3rd party tool to achieve the requirement & the tool named is “Test Case Migrator Plus”. Thought of sharing with you if it helps anyone.

I downloaded the exe from: https://tcmimport.codeplex.com/releases/

Let’s see the steps to import the test cases from excel to TFS

Open the TFS and create a folder (not necessary) where you want to upload the test cases (for e.g.Test Plan)

Add a test plan named as “Test Site Test Plan”

clip_image001

Here is the dummy specie of test cases excel sheet I used.

clip_image003

One important field is ‘Path’ which will contain the folder name (or Test Plan name) and the other is ‘Date’.

Now in Test Case Migrator Tool and click on next.

clip_image005

Select the test case excel & next.

Directly downloaded “TestCaseMigrationPlus” software also was not working in our case, it was throwing below error:

clip_image007

Now as a solution what I did:

Downloaded the source code and apply the patches from: https://tcmimport.codeplex.com/SourceControl/list/patches. Rebuild the application and then import the excel again.

clip_image009

Click on next and confirm at the end and test cases would be uploaded at the TFS URL where you want it.

clip_image011

Click on next.

clip_image013

Now mapped the fields accordingly. Please note that it’s not necessary to mapped all the fields but make sure that you mapped the mandatory fields (Title & Changed Date). Also, need to select Test suits as “Path”. You can refer the below screen shot for reference.

clip_image015

Click on next.

clip_image017

Click on next & unselect Create links between work items.

clip_image019

Click on next.

clip_image021

Click on next.

clip_image023

Click on Save and migrate.

clip_image025

Refresh the TFS link, the test cases will be imported to TFS successfully.

clip_image027

Open any one of the test case & check if the Action & expected result showing the data properly.

clip_image029

To run the test case you will have to right click on test case & run. To make it Pass you will have to select the test case & click on the “Pass test” button.

clip_image031

Hence go to the TFS and check that test cases are uploaded or not. On successful upload repeat the same process for other test cases.

 

Happy Coding

Tarun Kumar Chatterjee

Category : .Net

Author Info

Tarun Kumar Chatterjee
 
Net – Technology Specialist
 
Rate this article
 
Tarun has been working in IT Industry for over 12+ years. He holds a B-tech degree. He is passionate about learning and sharing the tricks and tips in Azure, .Net ...read more
 

How to sign up TFS online for free until 5 users

Sarath Babu Koneti
 
SharePoint Consultant
October 20, 2013
 
Rate this article
 
Views
14246

We can avail this TFS online even if we are not a MSDN subscriber.

There is no need to zip and mail the code to anyone who doesn’t have access to TFS any more.

Code reviews made easy as well.

#1 Go to

http://tfs.visualstudio.com/en-us/tfs-welcome.aspx

#2 Click sign up for free

clip_image002

#3 Fill in the account URL details

clip_image003

#4 Enter your name, email id and country and click continue

clip_image005

Setting up TFS is done and is free for 5 users.

clip_image007

We would have got a confirmation email from MS regarding the URL and details.

clip_image009

You can create a new team project with any of the 3 process templates.(Scrum 3 or MSF for agile or MSF for CMMI.

clip_image011

We can enjoy this functionality until MS changes its mood to fee based stuff.

Happy Coding!

Sarath Babu Koneti

Yes Labs Pty Ltd

Author Info

Sarath Babu Koneti
 
SharePoint Consultant
 
Rate this article
 
Working as a Sharepoint Consultant ~ Yes Labs Pty Ltd, Sydney ...read more
 

Leave a comment