feat: [CI-16621]: detect all .csproj/.vbproj/.fsproj in multi-project .NET repos#178
Open
hemanthmantri wants to merge 1 commit into
Open
feat: [CI-16621]: detect all .csproj/.vbproj/.fsproj in multi-project .NET repos#178hemanthmantri wants to merge 1 commit into
hemanthmantri wants to merge 1 commit into
Conversation
… .NET repos Walk the repo recursively and hash every .NET project file so the cache key reflects all projects, not just the root-most .csproj. Cache is prepared once at CWD so a single nuget.config / .nuget/packages covers every detected project. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> AI-Session-Id: 2334fb1b-84e4-49ed-be44-3a482234e63b AI-Tool: claude-code AI-Model: unknown
Author
|
@smjt-h @satyakota04 - Please review. |
Collaborator
|
@hemanthmantri, I have tested the changes, and it is detecting all the projects but caching only one. IMO, it should cache all the directories. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Cache Intelligence auto-detect for .NET only hashes the root-most
.csprojfile and prepares a single NuGet cache at that project's directory. In repos with multiple projects (several.csproj/.vbproj/.fsprojfiles across nested directories), this causes two issues:.nuget/packagespath is mounted, so other projects' restores miss the cache entirely.Jira: https://harness.atlassian.net/browse/CI-16621
Root Cause
auto_detect_util.gorelied onfilepath.Glob("*.csproj")andfilepath.Glob("**/*.csproj"). Go'sfilepath.Globdoes not recurse —**matches exactly one path component, so deeply nested projects were never discovered.calculateMd5FromFiles,shortestPathselected the single root-most match and hashed only that file.tool: "dotnet", so once the first matched, the others were skipped.Solution
Add an
extsToDetectfield onbuildToolInfo. When present, detection uses a recursivefilepath.Walkthat:bin/,obj/,.vs/,.nuget/,.git/,.hg/,.svn/,node_modules/),nuget.config+.nuget/packagescovers every project in the repo.The three separate dotnet entries are consolidated into one that carries
extsToDetect: {".csproj", ".vbproj", ".fsproj"}. Non-.NET tools continue to use the existing single-file glob path — behaviour unchanged for maven/gradle/bazel/node/yarn/go.Changes Made
internal/plugin/autodetect/auto_detect_util.go: addextsToDetect; consolidate dotnet entries; implementhashAllFilesByExtensions+findFilesByExtensions.internal/plugin/autodetect/auto_detect_util_test.go: addTestDetectDirectoriesToCacheDotnetMultiProjectcovering nested.csproj, deeply nested.fsproj, and confirming files underbin/are ignored.Testing
go build ./...— pass.go vet ./...— pass.go test ./internal/plugin/... ./key/... -count=1— pass (including the new multi-project test).Manual verification of detection behaviour in the new test:
.csproj, nestedsrc/Lib/Lib.csproj, deepsrc/F/Sharp/Fs.fsprojare all detected.bin/Artifact.csprojis excluded from the hash..nuget/packagesdirectory under CWD is returned for caching.Related Issues/Logs
🚢 Shipped via Ship