Skip to content
This repository was archived by the owner on Feb 28, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"permissions": {
"allow": [
"Edit",
"Bash(git checkout:*)",
"Bash(git add:*)",
"Bash(git commit:*)",
"Bash(dotnet list:*)",
"Bash(dotnet build:*)",
"Bash(dotnet test:*)",
"Bash(dotnet run:*)",
"Bash(dotnet test)",
"Bash(dotnet outdated)",
"Bash(dotnet sdk check:*)",
"Bash(curl:*)"
]
}
}
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"nbgv": {
"version": "3.7.115",
"version": "3.9.50",
"commands": [
"nbgv"
]
Expand Down
56 changes: 56 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# CLAUDE.md

This file provides guidance to AI agents when working with code in this repository.

## Project Overview

This repository contains `Treasure.Build.CentralBuildOutput`, an MSBuild project SDK that centralizes build output for .NET projects. Instead of placing `bin` and `obj` folders in each project directory, this SDK writes all build output to a common location with a tree structure mirroring the project structure.

## Build Commands

```shell
# Build the SDK
dotnet build

# Run all tests
dotnet test

# Run tests for a specific framework
dotnet test --framework net9.0
```

## Project Structure

- `src/CentralBuildOutput/` - The MSBuild SDK package (uses `Microsoft.Build.NoTargets`)
- `Sdk/Sdk.props` - Entry point props imported by consuming projects
- `Sdk/Sdk.targets` - Entry point targets that conditionally imports the appropriate configuration
- `Sdk/ConfigureBuildOutput.targets` - Core logic for redirecting build output paths
- `Sdk/ConfigureBuildOutputForArtifacts.targets` - Configuration when using .NET 8+ artifacts output
- `src/CentralBuildOutput.Tests/` - xUnit tests using `MSBuild.ProjectCreation` for in-memory MSBuild testing
- `samples/CentralBuildOutput/` - Sample projects demonstrating SDK usage
- `eng/` - Build infrastructure (analyzers, defaults, packaging configuration)

## Key Architecture Details

**SDK Entry Points**: The SDK uses standard MSBuild SDK conventions with `Sdk.props` and `Sdk.targets` files that get automatically imported when a project references the SDK.

**Two Modes of Operation**:

1. **Standard mode** (`ConfigureBuildOutput.targets`): Redirects `BaseIntermediateOutputPath`, `BaseOutputPath`, `OutputPath`, `PublishDir`, etc. to centralized folders prefixed with `__` (configurable via `CentralBuildOutputFolderPrefix`)
2. **Artifacts mode** (`ConfigureBuildOutputForArtifacts.targets`): When `UseArtifactsOutput=true`, defers to .NET 8+ artifacts output but still centralizes test results

**Path Calculation**: The SDK calculates `RelativeProjectPath` by determining the relative path from `CentralBuildOutputPath` (or `CentralBuildOutputRelativeToPath` if set) to the project directory, preserving the folder hierarchy in output.

**This Repo's Own Build**: Uses .NET 8+ artifacts output (`UseArtifactsOutput=true`) with `ArtifactsPath` set to `__artifacts`.

## Testing Approach

Tests use `MSBuild.ProjectCreation` to create in-memory MSBuild projects and verify that the SDK correctly sets output path properties. The test project copies SDK files to its output directory to enable testing.

## Versioning

Uses Nerdbank.GitVersioning for version management.

## Coding style

The project adheres to styles defined in `.editorconfig`.
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
8 changes: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
https://learn.microsoft.com/nuget/consume-packages/central-package-management#global-package-references
-->
<ItemGroup>
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.7.115" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.9.50" />
<GlobalPackageReference Include="Microsoft.VisualStudioEng.MicroBuild.Core" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
<PackageVersion Include="IsExternalInit" Version="1.0.3" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="MSBuild.ProjectCreation" Version="14.0.5" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="MSBuild.ProjectCreation" Version="17.0.1" />
<PackageVersion Include="Neovolve.Logging.Xunit" Version="6.3.0" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"rollForward": "latestPatch"
},
"msbuild-sdks": {
"Microsoft.Build.NoTargets": "3.7.56"
"Microsoft.Build.NoTargets": "3.7.134"
}
}