简体   繁体   English

对来自不同 Git 存储库的项目使用 VSTS 持续集成管道

[英]Use VSTS Continous Integration Pipeline with Projects From Different Git Repositories

I have this particiular setup that I would like to include into VSTS and continous integration + continous deployment.我有这个特定的设置,我想将其包含到 VSTS 和持续集成 + 持续部署中。 For the sake of simplicity, I'll reduce my situation to the following setup:为简单起见,我将我的情况简化为以下设置:

I have two solutions, A and B, which are in individual Git repositories.我有两个解决方案 A 和 B,它们位于单独的 Git 存储库中。 One project A1 of solution A references a project B1 of solution B. Since this is a simplified case for demonstration purposes, let's assume that the Git repositories can not be merged!解决方案 A 的一个项目 A1 引用了解决方案 B 的项目 B1。由于这是一个用于演示目的的简化案例,我们假设 Git 存储库无法合并!

Right now, I'm setting up CI for project A1.现在,我正在为项目 A1 设置 CI。 The project's build obviously fails since the dependencies to B1 can't be resolved.项目的构建显然失败了,因为无法解决对 B1 的依赖。

So far I've googled two solutions for my case which both make me unhappy:到目前为止,我已经为我的案例搜索了两个解决方案,这两个解决方案都让我不高兴:

  • Option 1) All references that can't be resolved by NuGet should be added to a library folder, see How to properly check in DLLs/assemblies to TFS/Visual Studio Team Services (was VSO) I might agree with this option in cases where these are third party dependencies that rarely change, like twice a year.选项 1) NuGet 无法解析的所有引用都应添加到库文件夹中,请参阅如何正确检入 DLL/程序集到 TFS/Visual Studio Team Services(是 VSO)在以下情况下我可能同意此选项这些是很少更改的第三方依赖项,例如一年两次。 However, since I compile B1 myself (and I might do that often), I dislike this solution.但是,由于我自己编译 B1(我可能经常这样做),我不喜欢这个解决方案。 Granted, I could automatically copy the binaries from B1 into A1/lib after B1's build, but I'd like to avoid checking in the binaries of B1.当然,我可以在 B1 构建后自动将二进制文件从 B1 复制到 A1/lib,但我想避免签入 B1 的二进制文件。
  • Option 2) Use NuGet for every reference that I want to integrate.选项 2)将 NuGet 用于我想要集成的每个参考。 I know that I can set up my own local NuGet server.我知道我可以设置自己的本地 NuGet 服务器。 I'm not sure about hosted solutions solutions with 'private packages'.我不确定带有“私人包”的托管解决方案。 Using Nuget for this seems like an overkill since I develop A1 and B1 locally and for every local build of B1 I'd have to push a new version and update the packages from A1 before updates are passed through to A1.为此使用 Nuget 似乎有点矫枉过正,因为我在本地开发了 A1 和 B1,对于 B1 的每个本地构建,我都必须在更新传递到 A1 之前推送新版本并从 A1 更新包。 Right now, I can build B1 locally and A1 immediately sees the updates.现在,我可以在本地构建 B1,而 A1 会立即看到更新。 Let's assume I have a lot of development builds locally, I essentially don't want to push 50+/100+ builds for B1 each day.假设我在本地有很多开发构建,我基本上不想每天为 B1 推送 50+/100+ 构建。

I will also set up a CI pipeline for B1 in VSTS.我还将在 VSTS 中为 B1 设置 CI 管道。

I guess I'm looking for a way to using a "reference path" for VSTS to look for dependencies that I build from another CI pipeline.我想我正在寻找一种方法来使用 VSTS 的“参考路径”来查找我从另一个 CI 管道构建的依赖项。 Is there a sort of shared "bin" space for VSTS projects? VSTS 项目是否有一种共享的“bin”空间? Before A1's build, I would automatically copy the built binary from B1 to A1.在 A1 构建之前,我会自动将构建的二进制文件从 B1 复制到 A1。

Is there any good way to achieve this?有什么好的方法可以实现这一目标吗? Right now I'm thinking about a post/pre-build FTP/cloud push/pull solution but given my situation (dependencies over different Git repositories) should be pretty common, what is the solution?现在我正在考虑一个 post/pre-build FTP/cloud push/pull 解决方案,但考虑到我的情况(对不同 Git 存储库的依赖)应该很常见,解决方案是什么?

If you do not want to manage the projectB1 by NuGet package, there has other options you can use.如果您不想通过 NuGet 包管理projectB1 ,您可以使用其他选项。

Assume solutionB is managed in repoB and file structure in repoB look like:假设solutionB在管理repoB和文件结构repoB的样子:

repoB
  |___solutionB
           |___projectB1
                    |___...
           |___...
  |___...

Option 1: clone repoB during build directly选项 1:在构建期间直接克隆 repoB

At the beginning of your build definition, you can add a PowerShell task to clone repo.在构建定义的开头,您可以添加一个PowerShell 任务来克隆存储库。 The PowerShell script as below: PowerShell 脚本如下:

# If you are using private agent to build and clean source is false, you should check if the repoB folder exist or not
git clone https://Personal%20Access%20Token:{PAT}@{account}.visualstudio.com/{project}/_git/repoB

To make sure solutionB build firstly, you can use two VS build task.为了确保solutionB首先构建,您可以使用两个VS构建任务。 The firstly one used for building solutionB ( repoB/*.sln ), and the second one used for building solutionA ( **/solutionA.sln ).第一个用于构建solutionB ( repoB/*.sln ),第二个用于构建solutionA ( **/solutionA.sln )。

Option 2: add repoB as submodule for repoA选项 2:添加 repoB 作为 repoA 的子模块

If you want to add repoB as submodule for repoA , then you can add repoB as submodule for repoA by:如果要将repoB添加为repoA子模块,则可以通过以下方式将repoB添加为repoA的子模块:

git submodule add https://{account}.visualstudio.com/{project}/_git/repoB

Then commit and push the changes to remote repoA .然后提交并将更改推送到远程repoA

Note: you also need to added another VS Build task to build solutionB firstly,.注意:您还需要添加另一个 VS Build 任务来首先构建 solutionB,。

Option 3: add repoB's branch (such as master branch) as subtree for repoA方案三:添加repoB的分支(比如master分支)作为repoA的子树

Similar as submoodule, you can add a branch (such as master ) of repoB into repoA by:与 submoodule 类似,您可以通过以下方式将 repoB 的一个分支(例如masterrepoBrepoA

git subtree add --prefix=repoB https://{account}.visualstudio.com/{project}/_git/repoB master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在本地环境中强制使用MSBuild进行编译,并在持续集成中使用dotnet - Force compile with MSBuild on local environment and use dotnet on continous integration 共享 C# 组件用于来自 2 个不同 GIT 存储库的另一个应用程序 - Shared C# components to be used in another application from 2 different GIT Repositories VSTS - 使用API​​获取所有项目的列表,而不仅仅是前100名 - VSTS - Use API to get a list of all projects, not just top 100 特定层中的通用存储库/服务,可在许多项目中使用 - Generic repositories/services in a specific layer to use in many projects 将VSTS \\ TFVC代码迁移到不同域上的Git DevOps - Migrating VSTS\TFVC code to Git DevOps on different domain VSTS 在线建筑设置项目? - VSTS Online Building Setup Projects? 解决方案中的两个项目使用不同的默认路径 - Two projects in a solution that use different default paths 注册来自不同未引用程序集的合同存储库 - Register contracts-repositories from different unreferenced assemblies 从不同的项目访问appsettings.json - Accessing appsettings.json from different projects 在解决方案中使用来自不同项目的图像 - Using images from different projects inside a solution
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM