-2

I'm struggling to get Azure Devops Server 2019 (on prem) to build a complicated project setup of mine.

I have multiple solutions that build various BizTalk apps. Some of these solutions references some of the projects in other solutions/repos. This works fine in Visual Studio (providing everybody names their repos as the default, which they do).

To automate this build, I've created a multi-stage build pipeline that builds each solution in order.

Whilst solution 1 will build successfully, when it comes to solution 2, the msbuild tasks will not reference the outputs for the projects that have been included as a project reference in the solution.

This seems to be because these referenced projects aren't marked for build - because they wouldn't be able to build themselves without them in turn referencing their other projects in the main solutions etc.

Bundling everything into one big super solution file is not feasible.

I'm wanting msbuild to /reference the projects that have already been built in the previous step, as per being included as project references. But msbuild is a complicated beast and I cannot figure out a way of achieving this.

Is what I'm trying to achieve even possible? Can anybody point me in the right direction?

SirKumbskull
  • 137
  • 2
  • 11
  • The solution probably depends on how your source control is setup. Are you using GIT or TFVC? If using GIT, is each app in its own repository, or is there a single repository that contains everything? Based on your comments about 'providing everybody names their repos as the default', i'm assuming that you are using GIT with individual repo's for each app, but could you confirm? – DenverDev Mar 11 '19 at 20:41
  • Just checking in to see if the information provided was helpful. Please let us know if you would like further assistance. – Leo Liu Mar 13 '19 at 04:54
  • I don't have an issue with getting the source code onto the build agent. As it happens, I'm using git with a super project that brings together all the projects. This works fine, and the entire source structure is available to the build agent. The problem is, as per the above, building solutions that have project references to neighbouring solutions. The files are all there and resolve, but msbuild doesn't /reference them. – SirKumbskull Mar 13 '19 at 10:13
  • You mention project references, but you also talk about multiple solutions. Project references are only valid within a single solution. Are you using file path references to reference the DLL's from Solution 1 in Solution 2? – DenverDev Mar 13 '19 at 15:51
  • Indeed. I have multiple solutions, all need building in sequence. Some of the solutions reference projects in previous solutions. The project references are relative, and valid. If the projects are loaded up in VS on the build server in the agent _work directory, you can build the projects just fine. The place I'm stuck at is how to get the Azure Pipeline to use the same arguments as VS does. – SirKumbskull Mar 13 '19 at 16:34
  • Are you referencing a project file or a dll? If its a DLL, you can't use the default configuration as it'll change the output path of the DLL based on the project configuration. You are most likely building in debug locally, and release on the build agent. In this scenario you need to update the projects to output to the same directory regardless of configuration. This is not a problem when using a project reference within a single solution as visual studio takes care of it for you. – DenverDev Mar 13 '19 at 19:47
  • They're project references, not DLL references. Everything is on the same build configuration. – SirKumbskull Mar 14 '19 at 10:35
  • Could you include your project file? What version of visual studio are you using? I personally wasn't aware of the ability to do project-project references between solutions and when I try to do it with the most basic example, it doesn't work and it becomes a file reference instead (visual studio 2017) – DenverDev Mar 14 '19 at 14:27
  • Of course you can. A solution is just a container for projects. So Solution 1 has Projects A & B. Solution 2 has Projects B & C. B cannot be built without A, so it's built as Solution 1's build. We then need to build Solution 2. Whilst Project B is built, and listed in Solution 2, it's not marked to build (as we know it's already been). MSBuild though, through TFS will not reference the output of Project B with the generated /reference arguments. So when Project C tries to build, it cannot find symbols from Project B. So how do we get MSBuild to reference Project B during Solution 2? – SirKumbskull Mar 14 '19 at 16:30
  • I fully understand how references work and there is no magic here. MSBuild is simply doing what has been configured in the project file. I've tried to help, but if you can't provide additional details about your specific project setup, then there is nothing else I can do to help. – DenverDev Mar 14 '19 at 17:00

3 Answers3

1

TFS / msbuild, building project references

This is a known issue about project reference in different Repos, but unfortunately it doesn't have a best answer. Because the best solution is always to have a single repository.

Git thinks of files as the content of the whole repository, not as a collection of files. Therefore this is quite hard to do. As workaround, you can consider to use Git Submodules or Git Subtree:

Check the details info from here:

Git and Visual Studio project references

Besides, the solution we are using now is to put the shared code in the NuGet package. Then, you can use the package from any repository, and you don't have to perform any unstable git settings and keep access control as they should be.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
1

It seems that msbuild was changed to only reference project references, and that you can revert that to reference all references by setting the property OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration to true when running msbuild.

Source: https://stackoverflow.com/a/25144169

Have confirmed this works.

SirKumbskull
  • 137
  • 2
  • 11
0

I've finally revisited this and done some more experimentation.

The only way, that I can see, to get TFS/msbuild to /reference other projects outputs is to mark them in the solution build configuration to build.

Now if you do this in Visual Studio and try and build a solution that has projects from another solution then the build will fail if the previous solution hasn't been fully built yet (as the other chained dependencies won't have been built). This makes sense.

But with TFS/msbuild, the build will succeed. From what I can tell there is some magic going on that ensures the dependencies across all solutions are somehow resolved. This might be luck, it might be specific behaviour (it's working for me so far).

The problem of course is that it's incompatible with Visual Studio. So I have an extra "Build" definition setup in each Solution file that has all the projects set to build.

This seems the easiest way to manage lots of interrelated solutions without having one big one.

SirKumbskull
  • 137
  • 2
  • 11