Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup submodules Azure DevOps

Can somebody clarify how SubModule works in azure devops

MyDevOps Root Folder

I have a Solution called MyCore.sln containing 4-5 projects

I have my Main Solution called MyMain.sln containing another 4-5 projects project referencing MyCore.sln projects

  • It all compiles and works locally but fails when building in azure devops

  • Gone into MyMain.sln folder in powershell and executed as follows

  • executed as follows git submodule add https://[email protected]/MyGroup/MyProjec/_git/MyCore

  • I can now see a folder inside my Main Repo called MyCore with projects inside and I start reference them
  • I can see .gitmodules file

    However when I go and build the pipeline it cannot find the projects that are referenced (belonging to myCore repo)

Am I missing the obvious?

Are there any comprehensive instructions on how to setup submodules in azure devops?

Can I visualize this anywhere?

like image 571
developer9969 Avatar asked Dec 04 '18 16:12

developer9969


People also ask

When should you use submodules?

In most cases, Git submodules are used when your project becomes more complex, and while your project depends on the main Git repository, you might want to keep their change history separate. Using the above as an example, the Room repository depends on the House repository, but they operate separately.

Do submodules update automatically?

Submodules are very static and only track specific commits. Submodules do not track git refs or branches and are not automatically updated when the host repository is updated. When adding a submodule to a repository a new . gitmodules file will be created.

How do I checkout with multiple repositories in Azure pipelines?

Specify multiple repositoriesRepositories can be specified as a repository resource, or inline with the checkout step. The following repository types are supported. Only Azure Repos Git ( git ) repositories in the same organization as the pipeline are supported for multi-repo checkout in Azure DevOps Server 2020.

What is git clone -- recurse submodules?

Cloning a Project with Submodules If you pass --recurse-submodules to the git clone command, it will automatically initialize and update each submodule in the repository, including nested submodules if any of the submodules in the repository have submodules themselves.


1 Answers

In the advanced section of the Get Sources step you need to enable the Checkout Submodules option.

enter image description here

If you're using YAML builds, you need to add:

steps:
- checkout: self
  submodules: true

As to your follow-up questions:

Where should I put my solution files

Ideally, you'd have a single solution, since you expect these projects to build together. Having multiple solutions will be awkward. If you want to share the components from one solution, you are probably better off publishing the projects from your 2nd repo as NuGet packages.

like image 72
jessehouwing Avatar answered Sep 17 '22 17:09

jessehouwing