10

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://myGroup@dev.azure.com/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?

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
developer9969
  • 4,628
  • 6
  • 40
  • 88
  • 1
    It depends on what kind of submodules they are, as on your own machine, any user credentials can come as easy as breeze, while on Azure DevOps everything needs to be configured explicitly (one example https://blog.lextudio.com/how-to-use-private-repos-as-submodules-in-vsts-fd69801e233f). – Lex Li Dec 05 '18 at 19:34
  • @LexLi thanks for that! It was a little helpful to understand that finding. – sud007 Dec 28 '22 at 05:49

2 Answers2

16

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.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • Hi thanks for quick reply. Forgot to mention but I did that and still my pipeline fails. – developer9969 Dec 04 '18 at 16:12
  • thanks for your reply. I will try to put some logs (work stuff not sure) . The logs say that cannot find the referenced projects which leads me to a question. Should the repo that has a reference to the submodules contain the actual physical projects in both repos? Or should just contain a link to the submodules repo? – developer9969 Dec 04 '18 at 18:40
  • Depends on the solution file. That's what tells the project system which project is stored where. – jessehouwing Dec 04 '18 at 19:54
  • Each `.*proj` file and `*.sln` file should be stored in one repository and one repository only. – jessehouwing Dec 05 '18 at 14:34
  • just to clarify I have 2 repos "MyCore Repo" and "MyMain Repo" (fictious names) simplified for clarity. I want to add "MyCore Repo" as a submodule to My Main repo so each repo will have their own solution. kind of confused about your last comment. Sorry . Appreciate time on your side to explain. – developer9969 Dec 05 '18 at 17:32
  • This UI seems to have changed, where does this live now? – Andrew Bullock May 01 '20 at 08:36
  • @AndrewBullock for UI based builds, the option still lives there. yaml based builds, see update. – jessehouwing May 01 '20 at 14:30
0

Go Project Settings=>Settings(The project where your pipeline exists), disable these two limitations: enter image description here

mahdi
  • 189
  • 2
  • 2
  • 11