'How can I use a Visual Studio solution (.sln) to determine the path filters for an Azure Pipelines trigger?

For my application I have a solution file (.sln) containing the "main" application assembly (c:\src\app) and the three internal libraries that are used: c:\src\lib\Lib1, c:\src\lib\Lib2, and c:\src\lib\Lib3.

I also have a c:\src\azure-pipelines.yml file that builds (and tests and publishes) my solution file. The pipeline's triggers are branch triggers (e.g. main and patch), with a set of path filters, one for each assembly:

trigger:
  branches:
    include:
    - main
    - patch/*
  paths:
    include:
    - app/*
    - lib/Lib1/*
    - lib/Lib2/*
    - lib/Lib3/*

I know that more lib/ projects will be created and added to my .sln over time, and I want changes to those libraries to trigger my pipeline, so I know that I'll need to add to both the .sln and the .yml, and ideally at the same time.

But the solution already lists the project folders, which is exactly the set of paths that I want to trigger on!

How can I take advantage of this? I'd like to do something, maybe during a local (workstation) build, to automate updating the paths/include list based on the solution contents. At the very least getting the .yml to show up in my source control as having changed would be useful.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source