Docker内使用Mono编译发布ASP.Net应用
Docker内使用Mono编译发布ASP.Net应用
MSBuild 指令
dotnet
不支持
MSBuild
尝试了许多,只有以下方式能够正常生成publish文件
msbuild -p:Configuration=Release -p:OutputPath=/publish
该指令只适合vs tools中使用,且MSBuild版本为.Net framework
msbuild /p:DeployOnBuild=true /p:PublishProfile=DockerPublishProfile /p:OutDir=/builds/publish
配合gitlab-ci.yml 自动化发布
#image: mcr.microsoft.com/dotnet/sdk:latest
image : mono
cache:
key: deploy-job
paths:
- packages # 缓存nuget包
stages:
- deploy
deploy-job:
stage: deploy
artifacts:
paths:
- bin/publish/_PublishedWebsites
script:
- echo "发布程序中..."
- echo "恢复nuget包..."
- nuget restore
- echo "恢复nuget包完成"
- echo "开始发布..."
# - msbuild /p:DeployOnBuild=true /p:PublishProfile=DockerPublishProfile /p:OutDir=/builds/publish
- msbuild -p:Configuration=Release -p:OutputPath=bin/publish # /builds/publish 会同步映射到d盘docker\gitlab-runner\publish内
- echo "程序发布成功."
tags:
- PublishRunner
发布之后会生成_PublishedWebsites
文件夹
再配合config.toml volumes映射
这里有个小彩蛋~✨✨