将 SPFX sppkg 解决方案包文件添加和部署到 SharePoint 2019(本地)应用程序目录的自动化方法

问题描述 投票:0回答:3

我正在寻找一种自动化方法,用于将 添加部署 SPFX 解决方案包 (*.sppkg) 到 SharePoint 2019(非在线)应用程序目录中。这是原因并使用 azure devops (CI/CD) 发布管道进行部署。

我找到了以下两个用于添加此包的任务:

  • 第一个仅将文件添加到应用程序目录但没有部署它,效果很好,所以我必须手动完成。
  • 第二个任务可以选择针对 SharePoint 编写 PnP 脚本,但我遇到的问题是,我找到的大多数脚本都适用于 SharePoint Online,而不是本地部署。

如果您遇到过这种情况并使用 PnP 或其他方式解决它,请感谢您的支持。

sharepoint azure-devops spfx sharepoint-2019
3个回答
0
投票

微软官方文档描述了一种使用Azure DevOps进行持续部署的方法。您可以单击使用 Azure DevOps 实施持续集成和持续部署了解详细信息。使用此方法无需编写 PNP 脚本。

使用 SharePoint 设置 Azure DevOps 以进行持续部署 框架解决方案需要以下步骤:

  1. 创建发布定义

  2. 链接构建工件

  3. 创造环境

  4. 安装NodeJS

  5. 安装适用于 Microsoft 365 的 CLI

  6. 连接到应用程序目录

  7. 将解决方案包添加到应用程序目录

  8. 部署应用程序

  9. 设置环境变量

如果您只想使用 Azure DevOps CD 而不想使用 CI,则可以跳过第二步,直接将构建工件上传到存储库,然后在发布管道中使用它们。


0
投票

使用管道有一些基本场景:

  1. 您根据云管道(azure、github 等)的能力和目的来使用它们。
  2. 您使用自托管管道创建自己的环境
  3. 您将自己的运行程序(管道代理)添加到您的云(天蓝色)环境

因此,azure 允许您将自己的管道代理添加到环境中。例如,自托管 Windows 代理

所以,我认为您的情况的解决方案是:

  • 安装自托管代理
  • 配置代理环境-安装SharePointPnPPowerShell2019
  • 将代理添加到您的蔚蓝环境
  • 添加使用自托管代理将解决方案部署到 pipline 的步骤

此方案允许您部署 sppkg 解决方案,而无需将应用程序目录发布到互联网,因为您的自托管代理将作为您的共享点场位于保存网络中。

Azure 管道部署步骤允许在目标计算机上运行 powershell

先决条件 此任务使用 Windows 远程管理 (WinRM) 访问本地物理计算机或虚拟计算机 已加入域或已加入工作组。


0
投票
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;
    
© www.soinside.com 2019 - 2024. All rights reserved.