powershell 完整的Sharepoint Framework SPFX Bundle使用Gulp和Powershell构建上载部署过程
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 完整的Sharepoint Framework SPFX Bundle使用Gulp和Powershell构建上载部署过程相关的知识,希望对你有一定的参考价值。
<# place deploy.ps1 in root of SPFx project #>
cls
Write-Host "Removing SHAREPOINT and TEMP directories..." -foregroundcolor "green"
$spFolderExists = test-path -Path .\sharepoint
$tempFolderExists = test-path -Path .\temp
if ($spFolderExists) {
Remove-Item .\sharepoint -Force -Recurse
Write-Host "Deleted SharePoint solution folders..." -foregroundcolor "green"
}
if ($tempFolderExists){
Remove-Item .\temp -Force -Recurse
Write-Host "Deleted temp folders..." -foregroundcolor "green"
}
Write-Host "Auto-incrementing SPFx Solution Version..." -foregroundcolor "green"
# The following auto-increments the version number of the SPFx solution
$tokens = $null
$config = Get-Content '.\config\package-solution.json' -raw | ConvertFrom-Json
$tokens = $config."solution".version.Split(".")
$major = [int]( $tokens[0])
$minor = [int]( $tokens[1])
$patch = [int]( $tokens[2])
$fix = [int]( $tokens[3])
$new_fix = $fix + 1 # updates patch... must update below
$Version = ([string] $major)+"."+ ([string] $minor ) +"." + ([string]$patch)+"." + ([string]$new_fix)
$config.update | % {
$config."solution".version = $version
Write-Host "Updated to" $Version
}
$config | ConvertTo-Json | set-content '.\config\package-solution.json'
# Bundling, packaging, uploading, deploying, etc
gulp bundle --ship
Write-Host "Bundling app..." -foregroundcolor "green"
gulp package-solution --ship
Write-Host "Packaging app..." -foregroundcolor "green"
$site = "https://mlmins.sharepoint.com"
$username = "svcdirsync@mlmins.onmicrosoft.com"
$password = "Kofo5273"
$encpassword = convertto-securestring -String $password -AsPlainText -Force
$creds = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $encpassword
Connect-PnPOnline -Url $site -Credentials $creds
Write-Host "Connected to:" $site
$pkgPath = "./sharepoint/solution/"
$apppkg = Get-ChildItem $pkgPath -Filter *.sppkg
$path = $pkgPath + $apppkg
Add-PnPApp -Path $path -Publish -Overwrite
Write-Host $apppkg "uploaded and deployed" -foregroundcolor "green"
Write-Host "Completed" -foregroundcolor "green"
以上是关于powershell 完整的Sharepoint Framework SPFX Bundle使用Gulp和Powershell构建上载部署过程的主要内容,如果未能解决你的问题,请参考以下文章
使用 Powershell 插入 Sharepoint 凭据
powershell 此SharePoint PowerShell为SharePoint中的每个内容数据库获取内容数据库大小(以GB为单位)。
powershell SharePoint Powershell在SharePoint模式下测试Analysis服务。这用于解决SharePoin中的Analysis服务问题
将SharePoint Online Client组件(Microsoft.SharePoint.Client)与powershell 2.0一起使用
PowerShell - 读取 SharePoint 文件属性(修改日期等)
powershell Powershell用于将Powershell与SharePoint 2007一起使用