惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
N
Netflix TechBlog - Medium
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
F
Full Disclosure
G
Google Developers Blog
罗磊的独立博客
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
A
About on SuperTechFans
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
GbyAI
GbyAI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
The Register - Security
The Register - Security
U
Unit 42
D
Docker
Martin Fowler
Martin Fowler
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
博客园_首页
Google DeepMind News
Google DeepMind News

博客园 - Andy Yang

SharePoint中Event Handler的触发 扩展SharePoint链接字段 树莓派的连接 树莓派版的家用NAS服务器 修改树莓派更新源及设置代理配置 开启树莓派的硬件看门狗功能 树莓派上安装2.8寸TFT触摸屏 树莓派上使用蚂蚁矿机挖矿 如何编译树莓派内核 代码导出Reporting Services报表文件 Bit-Coin收入的一分钱 如何在树莓派上运行雷神之锤III 新树莓派入手 将SharePoint 2010的快速启动改成弹出菜单样式 在SharePoint 2010的Team Site首页上显示Flash文件 SharePoint 2010搜索起步(下) SharePoint 2010搜索起步(上) 2009上班第一天 软件开发与心理张力
如何通过PowerShell在Visual Studio的Post-build中预热SharePoint站点
Andy Yang · 2013-08-11 · via 博客园 - Andy Yang

问题现象

Visual Studio在开发SharePoint的时候,发布部署包后,首次打开及调试站点页面的时候会非常的慢

解决方案

使用PowerShell脚本,加载SharePoint插件后遍历所有的网站集,用以模拟用户自动点击页面

具体步骤

  • 制作"64位版本"的PowerShell

由于SharePoint运行的是64位的PowerShell,而Visual Studio的Post-build event中默认运行的32位的PowerShell,需要找到一个变通的方式

新建一个Console程序,其中代码如下

using System;

using System.Diagnostics;

namespace ConsoleApplicationExample

{

class Program

{

static int Main(string[] args)

{

Process process = Process.Start("PowerShell.exe", String.Join(" ", args));

process.WaitForExit();

return process.ExitCode;

}

}

}

同时找到VS目录下64位的CMD,运行如下命令生成PowerShell的64位版本

csc Path to cs file\Program.cs /platform:x64

到目录c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC中找到Program.exe,并重命名为PowerShell64.exe

  • 制作遍历脚本

机器上运行PowerShell需要开启权限,运行以下脚本(注意:需要开启64位的权限)

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

%SystemRoot%\sysWOW64\WindowsPowerShell\v1.0\powershell.exe

Set-ExecutionPolicy Unrestricted

在PowerShell中操作SharePoint对象(遍历网站)

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;

}

  • 配置Visual Studio

$(ProjectDir)\PowerShell\PowerShell64.exe -File $(ProjectDir)\PowerShell\warmupAllSharePointSites.ps1