环境:
Window10
Net Core 3.1
jdk 11.0.10
目录
一、配置好 MSBuild 、 Git 、Nuget和JDK
一、配置好 MSBuild 、 Git 、Nuget和JDK
Git : https://mp.csdn.net/editor/html/113312729
MSBuild: https://mp.csdn.net/editor/html/113310755
下载好Nuget.exe https://www.nuget.org/downloads
安装JDK(注意:jdk只可11版本及以下版本) 参考:https://blog.csdn.net/weixin_42216984/article/details/107722155
二、新建任务
2.1 指定工作空间
2.2 设置Git
测试GitHub项目:https://github.com/czjnoe/Jenkins.AspNetCoreSample
SSH: git@github.com:czjnoe/Jenkins.AspNetCoreSample.git
SSH凭据添加参考: https://mp.csdn.net/editor/html/113340188
注意: 指定分支改成 ** (默认是*/master) ,不然不能成功从Github上面Pull代码,如下图:
2.3 添加构建命令
选择cmd命令:
dotnet CLI 参考: https://docs.microsoft.com/zh-cn/dotnet/core/tools/dotnet
这里我将编译后的结果保存到目录: C:\WebSite\Jenkins.AspNetCoreSample
参数命令说明:
dotnet restore //恢复项目的依赖项和工具
dotnet build //生成项目及其所有依赖项
dotnet publish -o C:\WebSite\Jenkins.AspNetCoreSample //发布到目录
然后保存任务即可。
三、运行任务
点 Build new ,执行任务
发布完成:
查看输出到目录: C:\WebSite\Jenkins.AspNetCoreSample ,已经成功发布到该文件夹
四、IIS部署
创建网站:
打开 localhost:8095
部署成功
注意:netcore 不能IIS部署运行,查看是否安装 dotnet-core-hosting 和 dotnet-core-runtime