是否可以使用 GitHub Actions 自动构建安装程序?这是一个 VSTO 加载项解决方案,包含多个 .NET 项目和一个“Visual Studio 安装程序项目”(又名 vdproj
)。我需要在提交到特定分支时构建安装程序项目。
最佳答案
是的,这是可能的。
首先确保环境是Windows:
jobs:
....
runs-on: windows-2022
要构建 VSTO 解决方案,您必须先导入 pfx 证书:
- name: Import certificate from the command-line
shell: pwsh
run: |
$Secure_String_Pwd = ConvertTo-SecureString "<password>" -AsPlainText -Force
Import-PfxCertificate -FilePath '${{github.workspace}}\<path>\project1_TemporaryKey.pfx' -CertStoreLocation Cert:\CurrentUser\My -Password $Secure_String_Pwd
然后使用 msbuild 构建 VSTO:
- name: setup-msbuild
uses: microsoft/setup-msbuild@v1.1.3
- name: Set VS.net environment
run: cmd.exe /C CALL "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
- name: Build VSTO
run: msbuild ${{github.workspace}}\yourproject.sln -t:rebuild /p:Platform="Any CPU" /p:Configuration="Release" /nologo /nr:false /p:VisualStudioVersion="17.0"
并构建 Visual Studio 安装程序项目:
- name: Setup VS Dev Environment
uses: seanmiddleditch/gha-setup-vsdevenv@v4
- name: Build installer
run: devenv.com ${{github.workspace}}\yourproject\yourproject.vdproj /build "Release|Any CPU"
关于github - 使用 GitHub Actions 构建安装程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71823928/