Skip to content

Commit f95af5d

Browse files
Copilotstephentoub
andcommitted
Merge main into branch and resolve conflicts with updated Aspire.OpenAI versions
Co-authored-by: stephentoub <[email protected]>
1 parent 0768e27 commit f95af5d

File tree

179 files changed

+3079
-1172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+3079
-1172
lines changed

.github/copilot-instructions.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# .NET Extensions Repository
2+
3+
**Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.**
4+
5+
The .NET Extensions repository contains a suite of libraries providing facilities commonly needed when creating production-ready applications. Major areas include AI abstractions, compliance mechanisms, diagnostics, contextual options, resilience (Polly), telemetry, AspNetCore extensions, static analysis, and testing utilities.
6+
7+
## Working Effectively
8+
9+
### Prerequisites and Bootstrap
10+
- **CRITICAL**: Ensure you have access to the appropriate Azure DevOps feeds. If build fails with "Name or service not known" for `pkgs.dev.azure.com`, this indicates network/authentication issues with required internal feeds.
11+
- Install .NET SDK 9.0.109 (as specified in global.json) if you do not already have it:
12+
```bash
13+
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version 9.0.109 --install-dir ~/.dotnet
14+
export PATH="$HOME/.dotnet:$PATH"
15+
```
16+
- Verify installation: `dotnet --version` should show `9.0.109`
17+
18+
### Essential Build Commands
19+
- **Restore dependencies**: `./restore.sh` (Linux/Mac) or `restore.cmd` (Windows)
20+
- **CRITICAL - NEVER CANCEL**: Takes 5-10 minutes on first run. Always set timeout to 30+ minutes.
21+
- Downloads .NET SDK, tools, and packages from Azure DevOps feeds
22+
- Equivalent to `./build.sh --restore`
23+
24+
- **Build the entire solution**: `./build.sh` (Linux/Mac) or `build.cmd` (Windows)
25+
- **CRITICAL - NEVER CANCEL**: Takes 45-60 minutes for full build. Always set timeout to 90+ minutes.
26+
- Repository has 124 total projects - build times are expected to be substantial
27+
- Without parameters: equivalent to `./build.sh --restore --build`
28+
- Individual actions: `--restore`, `--build`, `--test`, `--pack`
29+
30+
- **Run tests**: `./build.sh --test`
31+
- **CRITICAL - NEVER CANCEL**: Takes 20-30 minutes. Always set timeout to 60+ minutes.
32+
- Runs all unit tests across the solution
33+
34+
### Solution Generation (Key Workflow)
35+
This repository does NOT contain a single solution file. Instead, use the slngen tool to generate filtered solutions:
36+
37+
- **Generate filtered solution**: `./build.sh --vs <keywords>`
38+
- Examples:
39+
- `./build.sh --vs Http,Fakes,AspNetCore`
40+
- `./build.sh --vs Polly` (for resilience libraries)
41+
- `./build.sh --vs AI` (for AI-related projects)
42+
- `./build.sh --vs '*'` (all projects - escape asterisk)
43+
- Creates `SDK.sln` in repository root
44+
- Also performs restore operation
45+
- **NEVER CANCEL**: Takes 5-15 minutes depending on filter scope. Set timeout to 30+ minutes.
46+
47+
- **Open in Visual Studio Code**: `./start-code.sh` (Linux/Mac) or `start-code.cmd` (Windows)
48+
- Sets up environment variables for proper .NET SDK resolution
49+
- Opens repository in VS Code with correct configuration
50+
51+
### Build Validation and CI Requirements
52+
- **Always run before committing**:
53+
```bash
54+
./build.sh --restore --build --test
55+
```
56+
- **Check for API changes**: If you modify public APIs, run `./scripts/MakeApiBaselines.ps1` to update API baseline manifest files
57+
- **NEVER CANCEL** long-running builds or tests - this repository has hundreds of projects and build times are expected to be lengthy
58+
59+
### Common Build Issues and Workarounds
60+
61+
1. **"Workload manifest microsoft.net.sdk.aspire not installed"**:
62+
- Run `git clean -xdf` then restore again
63+
- Caused by multiple SDK installations
64+
65+
2. **"Could not resolve SDK Microsoft.DotNet.Arcade.Sdk"** or feed access errors:
66+
- Indicates no access to internal Microsoft Azure DevOps feeds
67+
- **NOT A CODE ISSUE** - environment/network limitation
68+
- Document as "Build requires access to internal Microsoft feeds"
69+
70+
3. **SSL connection errors during restore**:
71+
- Try disabling IPv6 on network adapter
72+
- May indicate network/firewall restrictions
73+
74+
### Project Structure and Navigation
75+
76+
#### Key Directories
77+
- `src/` - Main source code:
78+
- `src/Analyzers/` - Code analyzers
79+
- `src/Generators/` - Source generators
80+
- `src/Libraries/` - Core extension libraries
81+
- `src/Packages/` - NuGet package definitions
82+
- `src/ProjectTemplates/` - Project templates
83+
- `test/` - Test projects (organized to match src/ structure)
84+
- `docs/` - Documentation including `building.md`
85+
- `scripts/` - PowerShell automation scripts
86+
- `eng/` - Build engineering and configuration
87+
88+
#### Build Outputs
89+
- `artifacts/bin/` - Compiled binaries
90+
- `artifacts/log/` - Build logs (including `Build.binlog` for MSBuild Structured Log Viewer)
91+
- `artifacts/packages/` - Generated NuGet packages
92+
93+
#### Key Files
94+
- `global.json` - Specifies required .NET SDK version (9.0.109)
95+
- `Directory.Build.props` - MSBuild properties for entire repository
96+
- `NuGet.config` - Package source configuration (internal Microsoft feeds)
97+
98+
## Validation Scenarios
99+
100+
**After making changes, always execute these validation steps**:
101+
1. **Generate relevant filtered solution**: `./build.sh --vs <relevant-keywords>`
102+
- For AI libraries: `./build.sh --vs AI`
103+
- For AspNetCore: `./build.sh --vs AspNetCore`
104+
- For telemetry: `./build.sh --vs Telemetry,Logging,Metrics`
105+
- For resilience: `./build.sh --vs Polly,Resilience`
106+
2. **Build and test**: `./build.sh --build --test` (remember: NEVER CANCEL, 60+ minute timeout)
107+
3. **For public API changes**: Run `./scripts/MakeApiBaselines.ps1` to update API baseline manifest files
108+
4. **Manual verification**:
109+
- Check that your changes compile across target frameworks (net8.0, net9.0)
110+
- Review generated packages in `artifacts/packages/` if applicable
111+
- Verify no new build warnings in `artifacts/log/Build.binlog`
112+
113+
**Cannot run applications interactively** - this is a library repository. Validation is primarily through unit tests and integration tests.
114+
115+
**Common validation patterns by library type**:
116+
- **Source generators** (Microsoft.Gen.*): Build consumer projects that use the generator
117+
- **AspNetCore extensions**: Build test web applications that reference the extensions
118+
- **Testing utilities**: Use them in test projects to verify functionality
119+
- **Analyzers**: Build projects that trigger the analyzer rules
120+
121+
## Time Expectations and Timeouts
122+
123+
**CRITICAL - NEVER CANCEL BUILD OR TEST COMMANDS**:
124+
- **First-time setup**: 15-20 minutes (SDK download + initial restore) - timeout: 45+ minutes
125+
- **Restore operation**: 5-10 minutes - **ALWAYS set timeout to 30+ minutes, NEVER CANCEL**
126+
- **Full build**: 45-60 minutes - **ALWAYS set timeout to 90+ minutes, NEVER CANCEL**
127+
- **Test execution**: 20-30 minutes - **ALWAYS set timeout to 60+ minutes, NEVER CANCEL**
128+
- **Filtered solution generation**: 5-15 minutes - **ALWAYS set timeout to 30+ minutes**
129+
130+
**Repository has 124 total projects** - build times are substantial by design. If commands appear to hang, wait at least 60 minutes before considering alternatives.
131+
132+
## Advanced Usage
133+
134+
### Custom Solution Generation
135+
```bash
136+
# Using PowerShell script directly with options
137+
./scripts/Slngen.ps1 -Keywords "Http","Fakes" -Folders -OutSln "MyCustom.sln"
138+
```
139+
140+
### Build Configuration Options
141+
- `--configuration Debug|Release` - Build configuration
142+
- `--verbosity minimal|normal|detailed|diagnostic` - MSBuild verbosity
143+
- `--onlyTfms "net8.0;net9.0"` - Build specific target frameworks only
144+
145+
### Code Coverage
146+
```bash
147+
./build.sh --restore --build --configuration Release --testCoverage
148+
```
149+
Results available at: `artifacts/TestResults/Release/CoverageResultsHtml/index.html`
150+
151+
## Common Tasks Reference
152+
153+
**Key library areas and their keywords for filtered solutions**:
154+
- **AI libraries**: `./build.sh --vs AI` (Microsoft.Extensions.AI.*, embedding, chat completion)
155+
- **Telemetry**: `./build.sh --vs Telemetry,Logging,Metrics` (logging, metrics, tracing)
156+
- **AspNetCore**: `./build.sh --vs AspNetCore` (middleware, diagnostics, testing)
157+
- **Resilience**: `./build.sh --vs Polly,Resilience` (Polly integration, resilience patterns)
158+
- **Compliance**: `./build.sh --vs Compliance,Audit` (data classification, audit reports)
159+
- **Hosting**: `./build.sh --vs Hosting,Options` (contextual options, ambient metadata)
160+
- **Testing utilities**: `./build.sh --vs Testing,Fakes` (mocking, fake implementations)
161+
162+
**Find projects by pattern**:
163+
```bash
164+
# AI-related projects
165+
find src/Libraries -name "*AI*" -name "*.csproj"
166+
167+
# All AspNetCore extensions
168+
find src/Libraries -name "*AspNetCore*" -name "*.csproj"
169+
170+
# Source generators
171+
find src/Generators -name "*.csproj"
172+
173+
# Test projects for a specific library
174+
find test/Libraries -name "*[LibraryName]*" -name "*.csproj"
175+
```
176+
177+
**Working with specific libraries workflow**:
178+
1. Identify library area: `ls src/Libraries/` or use find commands above
179+
2. Generate focused solution: `./build.sh --vs <library-keywords>`
180+
3. Navigate to library directory: `cd src/Libraries/Microsoft.Extensions.[Area]`
181+
4. Check corresponding tests: `cd test/Libraries/Microsoft.Extensions.[Area].Tests`
182+
5. Review library README: `cat src/Libraries/Microsoft.Extensions.[Area]/README.md`
183+
6. Build and test: `./build.sh --build --test` (with appropriate timeouts)

eng/Publishing.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
3+
<ItemGroup>
4+
<PackageDownload Include="Microsoft.DotNet.Build.Tasks.Feed" Version="[$(MicrosoftDotNetBuildTasksFeedVersion)]" />
5+
</ItemGroup>
6+
37
<PropertyGroup>
48
<PublishingVersion>3</PublishingVersion>
59
<ProducesDotNetReleaseShippingAssets>true</ProducesDotNetReleaseShippingAssets>

eng/Signing.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!-- This file gets automatically imported by Arcade infrastructure when calling the build scripts -->
22
<Project>
33
<ItemGroup>
4+
<FileExtensionSignInfo Update=".js" CertificateName="MicrosoftDotNet500" />
45
<ItemsToSign Include="$(ArtifactsDir)VSIX\*.vsix" />
56
</ItemGroup>
67
</Project>

eng/Version.Details.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,17 @@
194194
</Dependency>
195195
</ProductDependencies>
196196
<ToolsetDependencies>
197-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.25428.3">
197+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="10.0.0-beta.25476.2">
198198
<Uri>https://github.com/dotnet/arcade</Uri>
199-
<Sha>5fe939db0a156be6f10e17c105b1842c0c8c8bdc</Sha>
199+
<Sha>a4c9a07d978c070ef5c19d2ec9f811d6a5b20914</Sha>
200200
</Dependency>
201-
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="9.0.0-beta.25428.3">
201+
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="10.0.0-beta.25476.2">
202202
<Uri>https://github.com/dotnet/arcade</Uri>
203-
<Sha>5fe939db0a156be6f10e17c105b1842c0c8c8bdc</Sha>
203+
<Sha>a4c9a07d978c070ef5c19d2ec9f811d6a5b20914</Sha>
204204
</Dependency>
205-
<Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="9.0.0-beta.25428.3">
205+
<Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="10.0.0-beta.25476.2">
206206
<Uri>https://github.com/dotnet/arcade</Uri>
207-
<Sha>5fe939db0a156be6f10e17c105b1842c0c8c8bdc</Sha>
207+
<Sha>a4c9a07d978c070ef5c19d2ec9f811d6a5b20914</Sha>
208208
</Dependency>
209209
</ToolsetDependencies>
210210
</Dependencies>

eng/Versions.props

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<!-- Dependencies from https://github.com/dotnet/efcore -->
8484
<MicrosoftEntityFrameworkCoreSqliteVersion>9.0.9</MicrosoftEntityFrameworkCoreSqliteVersion>
8585
<!-- Dependencies from https://github.com/dotnet/arcade -->
86-
<MicrosoftDotNetBuildTasksTemplatingVersion>9.0.0-beta.25428.3</MicrosoftDotNetBuildTasksTemplatingVersion>
86+
<MicrosoftDotNetBuildTasksTemplatingVersion>10.0.0-beta.25476.2</MicrosoftDotNetBuildTasksTemplatingVersion>
8787
</PropertyGroup>
8888
<PropertyGroup Label="No longer automated Maestro dependency updates">
8989
<!-- Packages from dotnet/runtime -->
@@ -159,5 +159,9 @@
159159
https://github.com/dotnet/arcade/blob/f5a7c5d5c56197b09715dece7541ca06beb94eb0/src/Microsoft.DotNet.Arcade.Sdk/tools/XUnit/XUnit.targets#L9
160160
-->
161161
<XUnitVersion>2.9.3</XUnitVersion>
162+
<!--
163+
Starting with 3.0.0, xunit.runner.visualstudio only supports net472, but we target net462
164+
-->
165+
<XUnitRunnerVisualStudioVersion>2.8.2</XUnitRunnerVisualStudioVersion>
162166
</PropertyGroup>
163167
</Project>

eng/common/CIBuild.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@echo off
2-
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0Build.ps1""" -restore -build -test -sign -pack -publish -ci %*"
2+
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0Build.ps1""" -restore -build -test -sign -pack -publish -ci %*"

eng/common/SetupNugetSources.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ if ($dotnet31Source -ne $null) {
157157
AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v2" -Creds $creds -Username $userName -pwd $Password
158158
}
159159

160-
$dotnetVersions = @('5','6','7','8','9')
160+
$dotnetVersions = @('5','6','7','8','9','10')
161161

162162
foreach ($dotnetVersion in $dotnetVersions) {
163163
$feedPrefix = "dotnet" + $dotnetVersion;

eng/common/SetupNugetSources.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ if [ "$?" == "0" ]; then
9999
PackageSources+=('dotnet3.1-internal-transport')
100100
fi
101101

102-
DotNetVersions=('5' '6' '7' '8' '9')
102+
DotNetVersions=('5' '6' '7' '8' '9' '10')
103103

104104
for DotNetVersion in ${DotNetVersions[@]} ; do
105105
FeedPrefix="dotnet${DotNetVersion}";

eng/common/build.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Param(
77
[string] $msbuildEngine = $null,
88
[bool] $warnAsError = $true,
99
[bool] $nodeReuse = $true,
10+
[switch] $buildCheck = $false,
1011
[switch][Alias('r')]$restore,
1112
[switch] $deployDeps,
1213
[switch][Alias('b')]$build,
@@ -20,6 +21,7 @@ Param(
2021
[switch] $publish,
2122
[switch] $clean,
2223
[switch][Alias('pb')]$productBuild,
24+
[switch]$fromVMR,
2325
[switch][Alias('bl')]$binaryLog,
2426
[switch][Alias('nobl')]$excludeCIBinarylog,
2527
[switch] $ci,
@@ -71,6 +73,9 @@ function Print-Usage() {
7173
Write-Host " -msbuildEngine <value> Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)."
7274
Write-Host " -excludePrereleaseVS Set to exclude build engines in prerelease versions of Visual Studio"
7375
Write-Host " -nativeToolsOnMachine Sets the native tools on machine environment variable (indicating that the script should use native tools on machine)"
76+
Write-Host " -nodeReuse <value> Sets nodereuse msbuild parameter ('true' or 'false')"
77+
Write-Host " -buildCheck Sets /check msbuild parameter"
78+
Write-Host " -fromVMR Set when building from within the VMR"
7479
Write-Host ""
7580

7681
Write-Host "Command line arguments not listed above are passed thru to msbuild."
@@ -97,6 +102,7 @@ function Build {
97102

98103
$bl = if ($binaryLog) { '/bl:' + (Join-Path $LogDir 'Build.binlog') } else { '' }
99104
$platformArg = if ($platform) { "/p:Platform=$platform" } else { '' }
105+
$check = if ($buildCheck) { '/check' } else { '' }
100106

101107
if ($projects) {
102108
# Re-assign properties to a new variable because PowerShell doesn't let us append properties directly for unclear reasons.
@@ -113,6 +119,7 @@ function Build {
113119
MSBuild $toolsetBuildProj `
114120
$bl `
115121
$platformArg `
122+
$check `
116123
/p:Configuration=$configuration `
117124
/p:RepoRoot=$RepoRoot `
118125
/p:Restore=$restore `
@@ -122,11 +129,13 @@ function Build {
122129
/p:Deploy=$deploy `
123130
/p:Test=$test `
124131
/p:Pack=$pack `
125-
/p:DotNetBuildRepo=$productBuild `
132+
/p:DotNetBuild=$productBuild `
133+
/p:DotNetBuildFromVMR=$fromVMR `
126134
/p:IntegrationTest=$integrationTest `
127135
/p:PerformanceTest=$performanceTest `
128136
/p:Sign=$sign `
129137
/p:Publish=$publish `
138+
/p:RestoreStaticGraphEnableBinaryLogger=$binaryLog `
130139
@properties
131140
}
132141

0 commit comments

Comments
 (0)