How to Use powershell to pre-heat SharePoint sites in the Post-Build of Visual Studio

Source: Internet
Author: User

Symptom

Visual Studio is very slow to open and debug the site page for the first time after the deployment package is released during SharePoint development.

?

Solution

Use powershell scripts to load the SharePoint plug-in and traverse all website sets to simulate users' automatic page clicking.

?

Procedure

  • Create powershell for "64-bit version"

Because SharePoint runs 64-bit powershell, and the default 32-bit powershell running in the Post-build event of Visual Studio, you need to find a work ing method.

?

Create a console program with the following code:

Using system;

Using system. diagnostics;

?

Namespace consoleapplicationexample

{

Class Program

{

Static int main (string [] ARGs)

{

Process = process. Start ("powershell.exe", String. Join ("", argS ));

Process. waitforexit ();

Return process. exitcode;

}

}

}

?

Find the 64-bit CMD in the vs directory and run the following command to generate the 64-bit powershell version.

CSC path to CS file \ Program. CS/platform: x64

?

Go to the directory c: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ vcfind program.exeand rename it powershell64.exe

?

  • Create a traversal script

To run powershell on a machine, you must enable the permission and run the following script (Note: You must enable the 64-bit permission)

% SystemRoot % \ system32 \ windowspowershell \ V1.0 \ powershell.exe

% SystemRoot % \ syswow64 \ windowspowershell \ V1.0 \ powershell.exe

?

Set-executionpolicy unrestricted

?

Operate SharePoint objects in powershell (traverse the website)

?

If (get-pssnapin-name Microsoft. Sharepoint. powershell-erroraction silentlycontinue)-EQ $ null)

{

Add-pssnapin Microsoft. Sharepoint. powershell

}

?

Function get-webpage ([String] $ URL)

{

$ WC = new-object net. WebClient;

$ WC. Credentials = [system. net. credentialcache]: defaultcredentials;

$ Pagecontents = $ WC. downloadstring ($ URL );

$ WC. Dispose ();

Return $ pagecontents;

}

?

Get-spalternateurl-zone default | foreach-object {

Write-host $ _. incomingurl;

$ Html = Get-webpage-URL $ _. incomingurl;

}

?

?

  • Configure Visual Studio

$ (Projectdir) \ powershell \ powershell64.exe-File $ (projectdir) \ powershell \ warmupall1_pointsites. PS1

?

?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.