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 |
?
?