加入Infopath表单模板包含了代码,部署到Farm中需要一些特殊的步骤,具体如下两种方式:代码、PowerShell形式

代码形式

http://nader.elshehabi.com/2011/08/how-to-really-deploy-infopath-2010-forms-with-code-behind-as-a-feature/

http://sandeepnakarmi.com.np/2011/03/sharepoint-solution-to-deploy-infopath-form-template-as-administrator-approved-form-template/

PowerShell形式

为了方便使用,可以采用如下的形式

dp.bat s 安装表单

dp.bat a 激活表单

dp.bat r 删除表单

根据自己的站点和表单名称修改dp.bat的对应名称即可,具体内容如下:

dp.bat

@echo off
setlocal enabledelayedexpansion
cls

if ""%1"" == """" goto done

rem 模板名称和站点集
SET SiteUrl=http://demo
set FormName=工作单.xsn
SET FormPath=%~dp0工作单.xsn

::echo %SiteUrl%
::echo %FormName%
::echo %FormPath%

if %1 == s (
  echo 模板的安装
  powershell -Command "& {.\SetupForm.ps1 %FormPath%}" -NoExit
)

if %1 == a (
  echo 模板激活到站点集

  powershell -Command "& {.\ActiveForm.ps1 %SiteUrl% %FormName%}" -NoExit
)

if %1 == r (
  echo 模板的删除
  rem 是否删除在管理中心查看
  rem http://localhost:1513/_admin/ManageFormTemplates.aspx
  rem http://localhost:1513/_admin/Timer.aspx

  powershell -Command "& {.\RemoveForm.ps1 %SiteUrl% %FormName%}" -NoExit

)

:done

pause

SetupForm.ps1

Write-Host "Num Args:" $args.Length;
#foreach ($arg in $args)
#{
#  Write-Host "Arg: $arg";
#}
#$SiteUrl = $args[0]
$Form = $args[0]

# check to ensure Microsoft.SharePoint.PowerShell is loaded
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
if ($snapin -eq $null) {
Write-Host "Loading SharePoint Powershell Snapin"
Add-PSSnapin "Microsoft.SharePoint.Powershell"
}

Test-SPInfoPathFormTemplate -Path $Form
Install-SPInfoPathFormTemplate -Path $Form

ActiveForm.ps1

Write-Host "Num Args:" $args.Length;
#foreach ($arg in $args)
#{
#  Write-Host "Arg: $arg";
#}
$SiteUrl = $args[0]
$Form = $args[1]

# check to ensure Microsoft.SharePoint.PowerShell is loaded
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
if ($snapin -eq $null) {
Write-Host "Loading SharePoint Powershell Snapin"
Add-PSSnapin "Microsoft.SharePoint.Powershell"
}

Enable-SPInfoPathFormTemplate -Identity $Form -Site $SiteUrl

RemoveForm.ps1

Write-Host "Num Args:" $args.Length;
#foreach ($arg in $args)
#{
#  Write-Host "Arg: $arg";
#}
$SiteUrl = $args[0]
$Form = $args[1]

# check to ensure Microsoft.SharePoint.PowerShell is loaded
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
if ($snapin -eq $null) {
Write-Host "Loading SharePoint Powershell Snapin"
Add-PSSnapin "Microsoft.SharePoint.Powershell"
}

Disable-SPInfoPathFormTemplate -Identity $Form -Site $SiteUrl
Uninstall-SPInfoPathFormTemplate -Identity $Form