我正在寻找一种自动化方法,用于将 添加 和 部署 SPFX 解决方案包 (*.sppkg) 到 SharePoint 2019(非在线)应用程序目录中。这是原因并使用 azure devops (CI/CD) 发布管道进行部署。
我找到了以下两个用于添加此包的任务:
如果您遇到过这种情况并使用 PnP 或其他方式解决它,请感谢您的支持。
微软官方文档描述了一种使用Azure DevOps进行持续部署的方法。您可以单击使用 Azure DevOps 实施持续集成和持续部署了解详细信息。使用此方法无需编写 PNP 脚本。
使用 SharePoint 设置 Azure DevOps 以进行持续部署 框架解决方案需要以下步骤:
创建发布定义
链接构建工件
创造环境
安装NodeJS
安装适用于 Microsoft 365 的 CLI
连接到应用程序目录
将解决方案包添加到应用程序目录
部署应用程序
设置环境变量
如果您只想使用 Azure DevOps CD 而不想使用 CI,则可以跳过第二步,直接将构建工件上传到存储库,然后在发布管道中使用它们。
使用管道有一些基本场景:
因此,azure 允许您将自己的管道代理添加到环境中。例如,自托管 Windows 代理。
所以,我认为您的情况的解决方案是:
此方案允许您部署 sppkg 解决方案,而无需将应用程序目录发布到互联网,因为您的自托管代理将作为您的共享点场位于保存网络中。
Azure 管道部署步骤允许在目标计算机上运行 powershell
先决条件 此任务使用 Windows 远程管理 (WinRM) 访问本地物理计算机或虚拟计算机 已加入域或已加入工作组。
Steps to deploy .sppkg files to SharePoint On-prem Server as follows.
1.Install SharePointPnPPowerShell2019 module in Powershell
2.Import SharePointPnPPowerShell2019 module
3. Use connect-pnponline command and provide username and password to connect
4. Use Add-PnPApp and Publish-PnPApp to deploy the application to the App catalog
Below is the script that does the work.
Import-Module -Name SharePointPnPPowerShell2019;
$username= "test_user";
$password="test_pass" | ConvertTo-SecureString -AsPlainText -Force; [pscredential]$cred= New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username,$password; $test=connect-pnponline -Url "https://test-onpremsite.test_domain.com" -Credentials $cred ;
$AppFilePath ="C:\temp\test.sppkg";
$App = Add-PnPApp -Path $AppFilePath -Overwrite #-Scope Site;
$App;
Publish-PnPApp -Identity $App.ID -Scope Site;