Skip to content

Commit 22b0288

Browse files
Merge main into darc-main-9120e3d3-21ba-42fb-86ad-3bdff34b1bfc
Auto-resolved conflicts: - src/Cli/dotnet/Parser.cs
2 parents 0190c26 + e52eadb commit 22b0288

26 files changed

+681
-498
lines changed

eng/Version.Details.props

Lines changed: 132 additions & 132 deletions
Large diffs are not rendered by default.

eng/Version.Details.xml

Lines changed: 265 additions & 265 deletions
Large diffs are not rendered by default.

eng/common/core-templates/steps/generate-sbom.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# IgnoreDirectories - Directories to ignore for SBOM generation. This will be passed through to the CG component detector.
66

77
parameters:
8-
PackageVersion: 10.0.0
8+
PackageVersion: 11.0.0
99
BuildDropPath: '$(System.DefaultWorkingDirectory)/artifacts'
1010
PackageName: '.NET'
1111
ManifestDirPath: $(Build.ArtifactStagingDirectory)/sbom

eng/common/core-templates/steps/source-index-stage1-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
parameters:
2-
sourceIndexUploadPackageVersion: 2.0.0-20250818.1
3-
sourceIndexProcessBinlogPackageVersion: 1.0.1-20250818.1
2+
sourceIndexUploadPackageVersion: 2.0.0-20250906.1
3+
sourceIndexProcessBinlogPackageVersion: 1.0.1-20250906.1
44
sourceIndexPackageSource: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
55
binlogPath: artifacts/log/Debug/Build.binlog
66

eng/common/sdk-task.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ show_usage() {
1010

1111
echo "Advanced settings:"
1212
echo " --excludeCIBinarylog Don't output binary log (short: -nobl)"
13-
echo " --noWarnAsError Do not warn as error
13+
echo " --noWarnAsError Do not warn as error"
1414
echo ""
1515
echo "Command line arguments not listed above are passed thru to msbuild."
1616
}

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
}
2222
},
2323
"msbuild-sdks": {
24-
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25427.104",
25-
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25427.104",
24+
"Microsoft.DotNet.Arcade.Sdk": "11.0.0-beta.25461.111",
25+
"Microsoft.DotNet.Helix.Sdk": "11.0.0-beta.25461.111",
2626
"Microsoft.Build.NoTargets": "3.7.0",
2727
"Microsoft.Build.Traversal": "3.4.0",
2828
"Microsoft.WixToolset.Sdk": "5.0.2-dotnet.2737382"

src/Cli/dotnet/Parser.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,10 @@ public override void Write(HelpContext context)
427427

428428
private class PrintCliSchemaAction : SynchronousCommandLineAction
429429
{
430-
public override bool Terminating => true;
430+
public PrintCliSchemaAction()
431+
{
432+
Terminating = true;
433+
}
431434

432435
public override int Invoke(ParseResult parseResult)
433436
{
Lines changed: 33 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,50 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
4+
using System;
5+
using System.Linq;
56

67
namespace Microsoft.DotNet.Cli.Telemetry;
78

89
internal class CIEnvironmentDetectorForTelemetry : ICIEnvironmentDetector
910
{
10-
// Systems that provide boolean values only, so we can simply parse and check for true
11-
private static readonly string[] _booleanVariables = [
12-
// Azure Pipelines - https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables#system-variables-devops-services
13-
"TF_BUILD",
14-
// GitHub Actions - https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
15-
"GITHUB_ACTIONS",
16-
// AppVeyor - https://www.appveyor.com/docs/environment-variables/
17-
"APPVEYOR",
18-
// A general-use flag - Many of the major players support this: AzDo, GitHub, GitLab, AppVeyor, Travis CI, CircleCI.
19-
// Given this, we could potentially remove all of these other options?
20-
"CI",
21-
// Travis CI - https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
22-
"TRAVIS",
23-
// CircleCI - https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
24-
"CIRCLECI",
25-
];
26-
27-
// Systems where every variable must be present and not-null before returning true
28-
private static readonly string[][] _allNotNullVariables = [
11+
private static readonly EnvironmentDetectionRule[] _detectionRules = [
12+
// Systems that provide boolean values only, so we can simply parse and check for true
13+
new BooleanEnvironmentRule(
14+
// Azure Pipelines - https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables#system-variables-devops-services
15+
"TF_BUILD",
16+
// GitHub Actions - https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
17+
"GITHUB_ACTIONS",
18+
// AppVeyor - https://www.appveyor.com/docs/environment-variables/
19+
"APPVEYOR",
20+
// A general-use flag - Many of the major players support this: AzDo, GitHub, GitLab, AppVeyor, Travis CI, CircleCI.
21+
// Given this, we could potentially remove all of these other options?
22+
"CI",
23+
// Travis CI - https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
24+
"TRAVIS",
25+
// CircleCI - https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
26+
"CIRCLECI"
27+
),
28+
29+
// Systems where every variable must be present and not-null before returning true
2930
// AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
30-
["CODEBUILD_BUILD_ID", "AWS_REGION"],
31+
new AllPresentEnvironmentRule("CODEBUILD_BUILD_ID", "AWS_REGION"),
3132
// Jenkins - https://github.com/jenkinsci/jenkins/blob/master/core/src/main/resources/jenkins/model/CoreEnvironmentContributor/buildEnv.groovy
32-
["BUILD_ID", "BUILD_URL"],
33+
new AllPresentEnvironmentRule("BUILD_ID", "BUILD_URL"),
3334
// Google Cloud Build - https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values#using_default_substitutions
34-
["BUILD_ID", "PROJECT_ID"]
35-
];
36-
37-
// Systems where the variable must be present and not-null
38-
private static readonly string[] _ifNonNullVariables = [
39-
// TeamCity - https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html#Predefined+Server+Build+Parameters
40-
"TEAMCITY_VERSION",
41-
// JetBrains Space - https://www.jetbrains.com/help/space/automation-environment-variables.html#general
42-
"JB_SPACE_API_URL"
35+
new AllPresentEnvironmentRule("BUILD_ID", "PROJECT_ID"),
36+
37+
// Systems where the variable must be present and not-null
38+
new AnyPresentEnvironmentRule(
39+
// TeamCity - https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html#Predefined+Server+Build+Parameters
40+
"TEAMCITY_VERSION",
41+
// JetBrains Space - https://www.jetbrains.com/help/space/automation-environment-variables.html#general
42+
"JB_SPACE_API_URL"
43+
)
4344
];
4445

4546
public bool IsCIEnvironment()
4647
{
47-
foreach (var booleanVariable in _booleanVariables)
48-
{
49-
if (bool.TryParse(Environment.GetEnvironmentVariable(booleanVariable), out bool envVar) && envVar)
50-
{
51-
return true;
52-
}
53-
}
54-
55-
foreach (var variables in _allNotNullVariables)
56-
{
57-
if (variables.All((variable) => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(variable))))
58-
{
59-
return true;
60-
}
61-
}
62-
63-
foreach (var variable in _ifNonNullVariables)
64-
{
65-
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable(variable)))
66-
{
67-
return true;
68-
}
69-
}
70-
71-
return false;
48+
return _detectionRules.Any(rule => rule.IsMatch());
7249
}
7350
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
8+
namespace Microsoft.DotNet.Cli.Telemetry;
9+
10+
/// <summary>
11+
/// Base class for environment detection rules that can be evaluated against environment variables.
12+
/// </summary>
13+
internal abstract class EnvironmentDetectionRule
14+
{
15+
/// <summary>
16+
/// Evaluates the rule against the current environment.
17+
/// </summary>
18+
/// <returns>True if the rule matches the current environment; otherwise, false.</returns>
19+
public abstract bool IsMatch();
20+
}
21+
22+
/// <summary>
23+
/// Rule that matches when any of the specified environment variables is set to "true".
24+
/// </summary>
25+
internal class BooleanEnvironmentRule : EnvironmentDetectionRule
26+
{
27+
private readonly string[] _variables;
28+
29+
public BooleanEnvironmentRule(params string[] variables)
30+
{
31+
_variables = variables ?? throw new ArgumentNullException(nameof(variables));
32+
}
33+
34+
public override bool IsMatch()
35+
{
36+
return _variables.Any(variable =>
37+
bool.TryParse(Environment.GetEnvironmentVariable(variable), out bool value) && value);
38+
}
39+
}
40+
41+
/// <summary>
42+
/// Rule that matches when all specified environment variables are present and not null/empty.
43+
/// </summary>
44+
internal class AllPresentEnvironmentRule : EnvironmentDetectionRule
45+
{
46+
private readonly string[] _variables;
47+
48+
public AllPresentEnvironmentRule(params string[] variables)
49+
{
50+
_variables = variables ?? throw new ArgumentNullException(nameof(variables));
51+
}
52+
53+
public override bool IsMatch()
54+
{
55+
return _variables.All(variable => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(variable)));
56+
}
57+
}
58+
59+
/// <summary>
60+
/// Rule that matches when any of the specified environment variables is present and not null/empty.
61+
/// </summary>
62+
internal class AnyPresentEnvironmentRule : EnvironmentDetectionRule
63+
{
64+
private readonly string[] _variables;
65+
66+
public AnyPresentEnvironmentRule(params string[] variables)
67+
{
68+
_variables = variables ?? throw new ArgumentNullException(nameof(variables));
69+
}
70+
71+
public override bool IsMatch()
72+
{
73+
return _variables.Any(variable => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(variable)));
74+
}
75+
}
76+
77+
/// <summary>
78+
/// Rule that matches when any of the specified environment variables is present and not null/empty,
79+
/// and returns the associated result value.
80+
/// </summary>
81+
/// <typeparam name="T">The type of the result value.</typeparam>
82+
internal class EnvironmentDetectionRuleWithResult<T> where T : class
83+
{
84+
private readonly string[] _variables;
85+
private readonly T _result;
86+
87+
public EnvironmentDetectionRuleWithResult(T result, params string[] variables)
88+
{
89+
_variables = variables ?? throw new ArgumentNullException(nameof(variables));
90+
_result = result ?? throw new ArgumentNullException(nameof(result));
91+
}
92+
93+
/// <summary>
94+
/// Evaluates the rule and returns the result if matched.
95+
/// </summary>
96+
/// <returns>The result value if the rule matches; otherwise, null.</returns>
97+
public T? GetResult()
98+
{
99+
return _variables.Any(variable => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(variable)))
100+
? _result
101+
: null;
102+
}
103+
}

src/Cli/dotnet/Telemetry/ICIEnvironmentDetector.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
5-
64
namespace Microsoft.DotNet.Cli.Telemetry;
75

86
internal interface ICIEnvironmentDetector

0 commit comments

Comments
 (0)