如何在Travis CI中部署nuget软件包?

编程入门 行业动态 更新时间:2024-10-24 09:17:37
本文介绍了如何在Travis CI中部署nuget软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个运行Travis CI的nuget软件包.这是我的yml:

I have a nuget package that runs Travis CI for its builds. Here is my yml:

language: csharp solution: TreasureGen.sln install: - nuget restore TreasureGen.sln - nuget install NUnit.Runners -OutputDirectory testrunner script: - xbuild TreasureGen.sln /p:TargetFrameworkVersion="v4.5" /p:Configuration=Stress - mono ./testrunner/NUnit.ConsoleRunner.*/tools/nunit3-console.exe ./TreasureGen.Tests.Unit/bin/Stress/TreasureGen.Tests.Unit.dll - mono ./testrunner/NUnit.ConsoleRunner.*/tools/nunit3-console.exe ./TreasureGen.Tests.Integration.IoC/bin/Stress/TreasureGen.Tests.Integration.IoC.dll - mono ./testrunner/NUnit.ConsoleRunner.*/tools/nunit3-console.exe ./TreasureGen.Tests.Integration.Tables/bin/Stress/TreasureGen.Tests.Integration.Tables.dll - mono ./testrunner/NUnit.ConsoleRunner.*/tools/nunit3-console.exe ./TreasureGen.Tests.Integration.Stress/bin/Stress/TreasureGen.Tests.Integration.Stress.dll

理想情况下,当它在master分支上运行时,如果成功,则将根据需要部署nuget软件包.解决方案中已经有Nuget项目,每个项目包含 Package.nuspec 和 NuGet.config 文件.我曾尝试让它自己部署,但并没有取得太大的成功-通常我会遇到身份验证方面的问题,但不是排他性的.我想知道这里是否有人在Travis中部署了像这样的nuget包,以及他们是如何做到的.

Ideally, when this runs on the master branch, if it is successful, it would then deploy the nuget packages as needed. There are already Nuget projects in the solution, which contain Package.nuspec and NuGet.config files for each package. I have tried getting it to deploy myself and have not had much success - typically I run into problems with the authentication, but not exclusively. I was wondering if anyone here has deployed nuget packages like this in Travis and how they did it.

推荐答案

经过反复的摸索和试验,我终于找到了解决方法.

After much fiddling and experimentation, I finally found a solution.

.travis.yml

language: csharp solution: TreasureGen.sln install: - nuget restore TreasureGen.sln - nuget install NUnit.Runners -OutputDirectory testrunner script: - xbuild TreasureGen.sln /p:TargetFrameworkVersion="v4.5" /p:Configuration=Stress - mono ./testrunner/NUnit.ConsoleRunner.*/tools/nunit3-console.exe ./TreasureGen.Tests.Unit/bin/Stress/TreasureGen.Tests.Unit.dll - mono ./testrunner/NUnit.ConsoleRunner.*/tools/nunit3-console.exe ./TreasureGen.Tests.Integration.IoC/bin/Stress/TreasureGen.Tests.Integration.IoC.dll - mono ./testrunner/NUnit.ConsoleRunner.*/tools/nunit3-console.exe ./TreasureGen.Tests.Integration.Tables/bin/Stress/TreasureGen.Tests.Integration.Tables.dll - mono ./testrunner/NUnit.ConsoleRunner.*/tools/nunit3-console.exe ./TreasureGen.Tests.Integration.Stress/bin/Stress/TreasureGen.Tests.Integration.Stress.dll deploy: skip_cleanup: true provider: script script: chmod +x ./deploy/deploy.sh && ./deploy/deploy.sh $NUGET_API_KEY $NUGET_SOURCE on: branch: master

deploy.sh

ApiKey=$1 Source=$2 nuget pack ./TreasureGen/TreasureGen.nuspec -Verbosity detailed nuget pack ./TreasureGen.Domain/TreasureGen.Domain.nuspec -Verbosity detailed nuget push ./DnDGen.TreasureGen.*.nupkg -Verbosity detailed -ApiKey $ApiKey -Source $Source nuget push ./DnDGen.TreasureGen.Domain.*.nupkg -Verbosity detailed -ApiKey $ApiKey -Source $Source

以下是要记住的一些关键事项:

Here are some of the key things to remember:

  • 不要忘记 skip_cleanup:true -这使您可以重复使用您以前的nuget软件包的构建命令结果
  • chmod + x ./deploy/deploy.sh 允许脚本可执行
  • 将您的API密钥和源放置为Travis环境变量.特别是对于API密钥,请确保将其标记为不显示在输出中
  • 您的构建可能会有所不同(不使用nunit进行测试,仅发布1个软件包,等等),但是部署过程应该相似.
  • Do not forget the skip_cleanup: true - this allows you to reuse your previous build command results for your nuget package
  • The chmod +x ./deploy/deploy.sh allows for the script to be executable
  • Place your API Key and Source as Travis environment variables. Especially for the API Key, make sure they are marked to not show in the output
  • Your build may differ (not using nunit for tests, only 1 package to publish, etc.), but the deployment process should be similar.
  • 更多推荐

    如何在Travis CI中部署nuget软件包?

    本文发布于:2023-11-14 19:17:21,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1588308.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:软件包   如何在   CI   Travis   nuget

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!