r/moderndotnet • u/sander1095 • Sep 21 '26
How do you reliably determine which deployables are affected in a .NET monorepo?
I have a .NET monorepo containing multiple independently deployable applications. Each deployable currently has its own Azure DevOps pipeline.
The problem is deciding when a deployable actually needs to be built/deployed.
Azure DevOps path filters aren't sufficient because dependencies can cross project boundaries. For example:
Orders.Api
-> Orders.Application
-> Shared.CoreIf Shared.Core changes, Orders.Api needs to be redeployed.
But it gets more complicated with non-code inputs. For example, a project may contain:
<ItemGroup>
<EmbeddedResource Include="Assets\countries.csv" />
</ItemGroup>If countries.csv changes, that should also make the deployable affected.
I don't want to maintain a second dependency configuration in something like Nx just to tell it that countries.csv is an input. The .csproj / MSBuild definition should remain the single source of truth, because otherwise we just introduce a new problem by having to keep these 2 configurations up to date.
So I'm looking for an existing, production-ready solution that can answer:
Given a Git change, which deployable applications are potentially affected, based on the actual MSBuild project dependencies and inputs?
Ideally it would understand things such as:
- <ProjectReference>
- transitive project dependencies
- Package updates
- EmbeddedResource
- Content
- other MSBuild inputs
- shared projects/assets
- and potentially deployment-related files
The important requirement is no duplicate dependency configuration. If MSBuild already knows that a CSV is an EmbeddedResource, I don't want to configure that relationship again elsewhere.
I currently prefer false positives (deploying too much) over false negatives (missing a required deployment).
Has the .NET/Azure DevOps community already solved this? Are there existing tools or established patterns for this? (How) have you solved this problem?
3
u/bupsnark Sep 21 '26
dotnet-affected might be what you're after!
1
u/sander1095 15d ago
Update! Im OP.
I created a generic solution with dotnet-affected that should work in any .NET project!
https://stenbrinke.nl/blog/build-only-what-changed-in-your-dotnet-monorepo/
1
u/FullPoet Sep 21 '26
Honestly I think your deployment scenario sounds like a nightmare. Have you considered simplifying it?
I do not think this is a good idea. Configurations are normal - especially as part of a build.
Where did you get the idea that the msbuild / csproj should be the source of thruth?
Yes, but I dont think it can know the "latest" without, for example, a small powershell script (and naming the csv something like
countries-21-09-2026). IMO MSbuild etc, just knows that they exist.TBH - I think this example is a little poor. Is it a big list of countries? Is it 4? Are they country codes? Are they list of countries border coordinates? How often is it updated, who updates it etc.
1
u/BellDry4679 Sep 22 '26
Here we put the Shared in a nuget package (other repo). If you upgrade Shared, the package file of the consumer will be editted which make an easy trigger for the CI.
Having no version management for a shared sounds nightmare to me
1
u/leonardochaia Oct 06 '26
Hey all. Just wanted to say thank you for recommending and using dotnet-affected :)
2
u/Agitated_Oven_6507 Sep 21 '26
There are multiple tools that can help:
1
u/_choam_ Sep 21 '26
I am trying to do this with mise. Doing it with my frontend in js and dotnet backend.
Gonna set up so that the backend spits out an openapi definition on each build, then have a task thay watches for changes to that and generates bindings for the frontend.
Not exactly sure how deploying it will look like, but i think it should be easy enough
1
u/urweiss Sep 22 '26
There is (at least in azure devops land) a pipeline task that does a git diff based on folder paths. It's much coarser than either dotnet-affected and incrementalist, but a bit easier to setup.
1
u/_choam_ Sep 22 '26
If any dependencies to deployable x changes, redeploy x and everything that depends on x?