nuget - Gitlab CI/CD yml 文件,用于构建、打包和部署 .net 标准类库作为 nuget 到 nexus 存储库
问题描述
我有一个.net Standard (.Net Standard 2.0)
类库,我想将其部署nexus
为nuget package
. 私有关系存储库已准备就绪,我正在使用它Gitlab
进行代码管理。
在 Gitlab 中,我添加了 gitlab-ci.yml 文件,该文件将触发构建和部署,但仍然没有足够的步骤:
stages:
- build
- package
- deploy
build_image:
stage: build
only:
- master
script:
- echo "Restoring NuGet Packages…"
- RUN dotnet restore
- echo "Building solution…"
- RUN dotnet build --no-restore -c Release -o
package_dev:
stage: package
script:
-
deploy_dev:
stage: deploy
environment:
name: development
only:
- master
script:
-
我的问题是如何配置此文件以触发构建然后执行packaging and deploy/push to nexus repo
?
我不知道我是否描述得很好,因为我对这个话题完全陌生。我发现了一些使用MAVEN
图像的例子,但我们没有使用它。
提前致谢!
解决方案
如果我正确理解您的问题,您想从您的项目中创建一个 nuget 包并将其上传到 Nexus Repo。你可以一步到位。
build-and-upload:
image: <dot-net image>
stage: build-and-upload
environment:
name: dev/test/prod
only:
- master
before_script:
- aws commands if you need to assume a deploy role.
script:
- ./scripts/nuget_publish.sh
And this is how your nuget_publish.sh will look like
dotnet build
dotnet pack
NEXUS_SOURCE=<Nexus_Source_Repo_Url>
NEXUS_API_KEY=<Nexus_Source_Repo_Api_Key>
dotnet nuget push <ProjectName>/bin/Debug/*.nupkg --source $NEXUS_SOURCE --api-key $NEXUS_API_KEY
推荐阅读
- c# - EF Core 3.1 Fluent API 未检测到实体上的更改
- c# - 在 MongoDB 中为嵌套对象使用自定义序列化程序会干扰使用该对象的过滤器
- javascript - 如何在pdfMake的页眉/页脚中使用类变量/调用函数
- parsing - LR(1) 解析器:为什么添加 epsilon 产生式会导致 r/r 或 s/r 冲突
- android - 获取 Firestore 文档的 URL 链接
- highcharts - 我无法在 tremap 中制作多线性渐变
- python - 从数据列表中只收集 7 个所需的项目并创建一个新的列表列表来删除不需要的数据?
- javascript - 在 DT 中隐藏子表列
- c# - 硬编码还是抽象视图?
- sql - 在传输中编辑 SQL 请求