Gitlab CI / CD yml文件以nuget的形式构建,打包和部署.net标准类库到nexus存储库

时间:2019-05-06 10:25:57

标签: nuget gitlab nexus gitlab-ci .net-standard

我有一个.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图片的示例,但我们没有使用它。

谢谢!

2 个答案:

答案 0 :(得分:0)

如果我正确理解了您的问题,则希望从项目中创建一个nuget包,然后将其上传到Nexus Repo。您可以一步完成。

Private Sub Worksheet_Change(ByVal Target As Range)    
    Application.EnableEvents = False

    If Target.Addres = "$L$9" And Target.Value <> "" Then

    ...
    ...
    ...

    End If

    Application.EnableEvents = True 
End Sub

答案 1 :(得分:0)

我找到了一个对我来说很好的解决方案。这是脚本,以防有人遇到相同的问题/要求:

ci.yml阶段的deploy中:

stages:
  - deploy

before_script:
    - nuget restore mysolution.sln

deploy_mysolution:
  stage: deploy
  image:
    name: crunchtime/dotnetcore-nuget-msbuild-docker
  script:
    - dotnet msbuild mysolution.sln /t:Clean,ReBuild /p:Configuration=Release;Platform="Any CPU"
    - dotnet pack "mysolution/myproject.csproj" /p:Configuration=Release;Platform="Any CPU"
    - PKGPATH=$(find myproject/bin/Release/*.nupkg)
    - dotnet nuget push $PKGPATH -k $NUGET_PUSH_KEY -s https://nexus.xyz.com/repository/nuget/
  only:
    - master

其中$NUGET_PUSH_KEY是api密钥,它保存为env变量,可通过运行程序应用于环境。