mida build builds a .NET repo through MSBuild's static graph with an output cache on local disk and Google Cloud Storage. Each project gets a key from its inputs. On a hit its outputs are restored instead of built, at any checkout path, so a clean CI clone of an unchanged repo restores and builds nothing. mida test then runs only the test projects that have not passed with their current inputs. It is a CI tool: the target is CI build and test time.
Status: an MVP, not released yet. On Linux x64 a clean clone with a filled cache builds an open-source web CMS of 227 projects in 0.10 of a plain build's time, and an application framework of 270 projects in 0.82, since its multi-targeted projects are not cached. Windows has never been run. See docs/plan.md for what is proven, what is next and the known risks.
There is no package on nuget.org yet. Until the first release, pack it from a clone:
dotnet pack src/Mida -c Release -p:Version=0.0.0-dev -o out
dotnet tool install -g mida --version 0.0.0-dev --add-source outIt needs .NET SDK 10 or 11, and it loads MSBuild from the SDK your global.json selects. mida must run on that SDK's runtime, because a runtime cannot load a newer SDK's MSBuild. If it cannot, it stops with an error.
mida build [<solution>] [-c <configuration>] [-p:<name>=<value>] [--cache <dir>] [--cache gs://<bucket>[/<prefix>]] [--read-only] [--evaluate]<solution>defaults to the only.slnor.slnxin the current directory.-ptakes one property each. Unlikedotnet build, it does not split on;.--cache <dir>is the local store,~/.mida/cacheby default. Nothing evicts it.--cache gs://...adds a GCS store behind the local one. Hits restore from local disk, and what came from the bucket is kept locally.--read-onlystores nothing in either store.--evaluaterestores and evaluates every project, even when the store holds a graph that fits.
It first looks in the store for an evaluated graph of the solution. When one fits the checkout and the packages are on disk, it skips restore and evaluation, and when every project then hits, it never loads MSBuild. Otherwise it restores, then builds. It ends with a summary such as 47 hits, 2 misses, 312.4 s of project build time saved. The time saved is the stored build time of each hit, summed over projects, so it is not wall-clock time. A key that cannot be computed and any store failure are misses with a warning: the cache never fails a build.
mida build always sets ContinuousIntegrationBuild=true and IncludeSourceRevisionInInformationalVersion=false, which make outputs the same at every checkout path and keep the commit SHA out of reference assemblies. A -p for either wins, at the cost of hits.
It restores with NuGet's static graph evaluation, which is faster and which NuGet calls experimental. -p:RestoreUseStaticGraphEvaluation=false restores the default way.
mida test [<solution>] [the options of mida build] [--all] [--include <glob>] [--exclude <glob>] [--category <name>] [-- <runner arguments>]It builds as mida build does, then runs each test project that has not passed before with the same sources, packages, properties, SDK and runner arguments, in the project itself and in everything it references. A pass is stored, a failure is not. It ends with a summary such as 3 test projects run, 1 failed, 5 passed before, 12.4 s of test time saved, and exits with the code of the first test project that failed.
- What follows
--goes to every test project's runner, such as-- --report-trx. --allruns every test project, also one that passed before.--read-onlystores no pass either.--includeand--excludechoose test projects by their path from the repo root, such as--include 'tests/Unit/*' --exclude '*.Integration.Tests.csproj'.*matches/too.--categorychooses those whoseMidaTestCategoryproperty names it, a;list such as<MidaTestCategory>slow;db</MidaTestCategory>. Each can be given more than once, and all three must agree. With any of them only the chosen test projects and what they reference are built, and a choice of none fails.<MidaStoreTestPasses>false</MidaStoreTestPasses>in a project runs it every time and stores none of its passes. To store passes only for some projects, set it tofalseinDirectory.Build.propsand totruein those.- Test projects must use Microsoft.Testing.Platform, as TUnit does and as xUnit v3, NUnit and MSTest can. A VSTest project counts as failed. Each runs as its own application, as many at once as the machine has processors. Only a failed test project's output is shown.
RunArguments, a.runsettingsfile named in the project and launch profiles are not applied.
A test that depends on something outside its inputs, such as the clock, the network, a database or an environment variable, is not run again when only that changed. Give such a project MidaStoreTestPasses false, or run with --all. See docs/notes/mida-test.md.
-
Run every later step with
--no-buildand the same configuration, such asdotnet test -c Release --no-build. A step without it rebuilds everything.mida testbuilds and tests in one step. -
Packages are not cached. Cache
~/.nuget/packageswith your CI's own cache: restore is skipped only when they are all on disk. -
Give PR runners
--read-only, so only trusted builds write to the bucket. -
Credentials come from Application Default Credentials:
GOOGLE_APPLICATION_CREDENTIALS, gcloud's, or the metadata server. From GitHub Actions, use Workload Identity Federation throughgoogle-github-actions/auth. Writers needroles/storage.objectCreatorandroles/storage.objectVieweron the bucket, read-only runners only the viewer. -
Give the bucket one age-based lifecycle rule. mida never deletes, and a rule that removes manifests along with their blobs keeps every entry whole. Add
"matchesPrefix": ["<prefix>/"]to the condition to cover only mida's prefix.echo '{"rule":[{"action":{"type":"Delete"},"condition":{"age":30}}]}' > lifecycle.json gcloud storage buckets update gs://<bucket> --lifecycle-file=lifecycle.json
A GitHub Actions job:
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props') }}
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: projects/<number>/locations/global/workloadIdentityPools/<pool>/providers/<provider>
service_account: <name>@<project>.iam.gserviceaccount.com
- run: dotnet tool install -g mida
- run: mida build -c Release --cache gs://<bucket>/mida ${{ github.event_name == 'pull_request' && '--read-only' || '' }}
- run: dotnet test -c Release --no-buildTo run only the tests that have not passed, replace the last two steps with mida test and the same options.
- Projects that target several frameworks are not cached. They are built on every run and are in neither the hits nor the misses: a line such as
3 nodes without a key: 3 multi-targetedcounts them, one node per framework and one for the project. Their dependents are cached, and so is a project with one framework inTargetFrameworks. - A project that sets
GeneratePackageOnBuildis not cached either, since a hit would not write its package. The same line counts it. - Nor, for now, is a project that copies to its output a file it writes into its own
bin/orobj/outside the directories a hit restores, such asobj/Debug/Scripts/:copies a file it writes outside its outputs. See docs/notes/relocation.md. - A build that writes into its project's directory outside
bin/andobj/is not stored, and the build names the file it wrote. If the project names what it writes in<MidaSourceOutputs>Localization;wwwroot</MidaSourceOutputs>, paths or patterns under its directory split on;, mida stores them and a hit writes them. Name only what the build makes: a named path is no longer an input of the key, and a hit that finds a file there that differs from the stored one builds instead. A build in a checkout that has built before cannot see such a write when the file was there already, so this check is for clean clones, as on CI. What a build writes outside its project's directory is not restored and not checked. - A Web or Razor SDK project with a static web asset outside the repo, the package folder, the .NET install and the user profile is not cached, and the build says why. Static web assets on Windows have not been tested.
- Environment variables are not in the key.
- If the repo's build SDK moves the package folder into the checkout under
ContinuousIntegrationBuild, which mida sets, setNUGET_PACKAGES. - Tools that stamp a version from git cost the hits of every dependent whenever they change
AssemblyVersion, which by default happens on a major, a minor or a patch version, depending on the tool. A hit can serve outputs stamped with an older version, which matters at pack and publish.
dotnet test --project tests/Mida.Tests -f net10.0
dotnet test --project tests/Mida.Tests -f net11.0Each run takes about 13 minutes and starts many MSBuild nodes, so name what you changed with --treenode-filter "/*/*/<class>/*". The GCS tests use the bucket MIDA_TEST_BUCKET names, else fake-gcs-server through Testcontainers, and skip without either. The benchmarks and the real-repo builds are [Explicit] tests, see docs/notes/benchmarks.md. A release is a v<version> tag, which packs the tool and pushes it to nuget.org.