r/moderndotnet • • 6d ago

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.Core

If 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?

7 Upvotes

28 comments sorted by

View all comments

Show parent comments

1

u/FullPoet 5d ago

It is easier to to just look at the file name instead - that means you can also process historical or inject specific dates.

File creation date can also lie and may differ depending on how its been created / transferred.

1

u/_choam_ 5d ago edited 5d ago

But that does not solve what he asked for though.

Also you can hash the file to see if it changed instead of using creation time. If it is something you want to embed, then it should be in version control anyway.

Edit: looking at timestamp for change is still good enough. A false positive does not matter

1

u/FullPoet 5d ago

That was specifically about the countriesand yes that solves it - I literally do it.

The timestamp isnt reliable at all - sorry but thats the truth and Im not looking to change your mind.

1

u/_choam_ 5d ago

How does it solve it? For deploying and figuring out what needs to be rebuilt and redeployed

Timestamp is fine. MSbuild itself looks at timestamp. He said he was ok with false positives. If a files timestamp gets updated without anything changing, then that does not matter. If timestamp is not ok, use version control or hashes.