背景:winform客户端基于.NET Framwork4.8,并且基于Msbuild命令进行ClickOnce打包。在Linux下,Msbuild无法使用,且无法安装.NET Framwork4.8,于是Jenkins部署在Window Server上
1.在Windows服务器安装Jenkins,并启动。安装教程百度,建议安装新版本
2.在windows服务器采用vs_BuildTools.exe (https://download.visualstudio.microsoft.com/download/pr/655265af-cd2f-4919-97b2-3198ac560526/72224eda2843205f7b6abbbd93da8426d05f25571f8a02b4915a6d61cbbf1b13/vs_BuildTools.exe) 安装特定组件 .NET Framwork4.8和ClickOnce工具
3. 根据官方文档 https://learn.microsoft.com/zh-cn/visualstudio/deployment/how-to-include-prerequisites-with-a-clickonce-application?view=vs-2022 需要先将必备组件安装到Jenkins服务器指定路径
1.将自己电脑上面 C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX48 下的NDP48-x86-x64-AllOS-ENU.exe 拷贝到服务器相同路径下。
2.将D:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\BootstrapperPackages\WebViewRuntime 下的MicrosoftEdgeWebView2RuntimeInstallerX86.exe和Product.xml 拷贝到服务器E:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VisualStudio\BootstrapperPackages\WebViewRuntime 下。
4.登录Jenkins,安装插件 Build With Parameters Git client plugin Git Parameter Plug-In Git plugin GitLab GitLab API Plugin MSBuild Plugin SSH server 等插件,可能会安装失败,失败时可以自己手动下载安装包进行安装。下面有手动安装的截图
5.配置Jenkins工具 MSbuild
6.在Jenkins创建一个FreeStyle风格的项目,
设置git分支参数
设置版本参数
配置源码管理,
git凭证需要先去Jenkins凭证管理进行配置,
7.构建步骤
1.Execute Windows batch command
@echo off echo "%appversion%" rmdir /s /q "E:\Jenkins_Publish\SPC-Analysis-DEV\AnalysisLaunch\%appversion%"
2.Build a Visual Studio project or solution using MSBuild
/t:restore /t:Publish /p:Configuration=Release /p:ApplicationVersion=${appversion} /p:OutputPath=E:\Jenkins_Publish\SPC-Analysis-DEV\AnalysisLaunch\${appversion}\
3. Execute Windows batch command
@echo off setlocal set "target_path=E:\Jenkins_Publish\SPC-Analysis-DEV\AnalysisLaunch\%appversion%\app.publish\Application Files\" for /d %%i in ("%target_path%\*") do ( echo %%~nxi set updateDir=%%~nxi ) set zipOutPutFile=%target_path%%updateDir%.zip set sourcePath=%target_path%%updateDir% "C:\Program Files\7-Zip\7z.exe" a -t7z "%zipOutPutFile%" "%sourcePath%" -r endlocal echo zip Done.
8 构建成功,后续把更新包通过ssh发送到Linux应用服务器
标签:Files,exe,FramWork4.8,echo,Jenkins,ClickOnce,安装,Microsoft From: https://www.cnblogs.com/shuyuansong/p/18577038