构建过程中的条件标准选择Nuget软件包

发布于 2025-01-24 14:54:01 字数 359 浏览 0 评论 0原文

我们的构建环境是VSTS管道,我们的开发环境是视觉工作室。

我们正在使用开发分支(或特征分支),并且有一个主分支(主分支)。 随着代码越来越稳定,不需要太多调试,我们现在愿意将项目分为Nuget软件包。

只要我们在开发或功能分支中,我们就希望生成并使用-alpha Nuget软件包来测试和使用最新代码。 但是,一旦我们向主分支提取请求,我们就希望使用稳定的Nuget软件包。 当然,无需手动转到Nuget Package Manager并在委托之前更新每个Nuget软件包;

换句话说,开发分支机构中的每个项目都应使用每个Nuget软件包的-alpha版本自动构建,并且Master分支的构建应与稳定版本的软件包一起构建。 我们如何创建VST管道来实现这一目标

Our build environment is VSTS pipeline and our development environment is visual studio.

We are using dev branches (or feature branches) and we have a main branch (master branch).
As piece of code are getting stable and don't need much debug, We are now willing to split our projects into nuget packages.

As long as we are in dev or feature branch, we want to generate and use the -alpha nuget package to test and use the latest code.
But as soon as we are doing a pull request to the master branch, we want to use the stable nuget package.
Of course, without having to manually go to the nuget package manager and update every nuget package before committing;

Said differently, every project in a dev branch should automatically build with the -alpha version of each nuget package and the build of the master branch should be with the stable version of the package.
How can we create a vsts pipeline to achieve this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

在风中等你 2025-01-31 14:54:01

构建期间的条件选择nuget软件包

您可以添加一个任务(PowerShell或Batch)来修改Nuget.config或项目文件以使用条件更新软件包版本。

steps:
- powershell: |
     # Write your PowerShell commands here.
   
     update the package version in the nuget.config or project file.
  displayName: 'Update package version'
  condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))

conditionnally select nuget package during build

You could add a task (powershell or batch) to modify the nuget.config or the project file to update the package version with condition.

steps:
- powershell: |
     # Write your PowerShell commands here.
   
     update the package version in the nuget.config or project file.
  displayName: 'Update package version'
  condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
爱人如己 2025-01-31 14:54:01

您创建两个(构建)管道:

  • dev / feature unun n n n n n n n n'>由您的功能 /*分支触发,并发布您的-aplpha nuget软件包
  • 稳定 / prod->被拉的请求触发到主要分支,并发布了

我个人对YAML的稳定Nuget软件包的触发,但是在经典的管道编辑器中,您可以轻松添加任务。每个管道都应该大致看起来像这样:

更多详细信息:

  • 屏幕截图上缺少是重要的触发部分。您还可以在“触发”选项卡中的经典管道编辑器中编辑。您可以选择您的功能分支设置(例如功能/*),并在功能管道上排除主人。
  • 将全部转换为YAML应该通过经典网络编辑器中的“ View YAML”功能直接进行。
  • 根据您的私有设置,如果您使用私人Nuget服务器等,您可能需要诸如Nuget Auth之类的额外步骤。

You create two (build) pipelines:

  • Dev / Feature you name it -> gets triggered by your feature/* branches and publishes your -aplpha nuget package
  • Stable / Prod -> gets triggered by pull requests into the main branch and publishes the stable nuget package

I personally don't have much experience with YAML, yet, but in the classic pipeline editor you can easily add tasks. Each pipeline should roughly be looking like this:
enter image description here

Some more details:

  • Missing on the screen shot is the important trigger part. You can also edit that in the classic pipeline editor in the "trigger" tab. There you choose your feature branch setting (e.g. feature/*) and exclude the master on the feature pipeline.
  • Converting all to YAML should be straight forward via the "View YAML" feature in the classic web editor.
  • Depending on your private setup you might need extra steps like NuGet auth if you use a private NuGet server etc..
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文