diff --git a/.vsts-ci.yml b/.vsts-ci.yml index 5eee7dcb875e..495149976450 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -26,13 +26,17 @@ variables: - ${{ if eq(variables['System.TeamProject'], 'public') }}: - name: _InternalRuntimeDownloadArgs value: '' + - name: _OfficialBuildArgs + value: '' - ${{ if ne(variables['System.TeamProject'], 'public') }}: - name: _DotNetPublishToBlobFeed value: true + - name: _OfficialBuildArgs + value: /p:OfficialBuilder=Microsoft - group: DotNetBuilds storage account read tokens - name: _InternalRuntimeDownloadArgs value: /p:DotNetRuntimeSourceFeed=https://dotnetbuilds.blob.core.windows.net/internal - /p:DotNetRuntimeSourceFeedKey=$(dotnetbuilds-internal-container-read-token-base64) + /p:DotNetRuntimeSourceFeedKey=$(dotnetbuilds-internal-container-read-token-base64) - ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - group: DotNet-CLI-SDLValidation-Params diff --git a/Directory.Build.props b/Directory.Build.props index 8ee962ab1da8..1353696a295f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -21,6 +21,7 @@ $(DefineConstants);CI_BUILD + $(DefineConstants);MICROSOFT_ENABLE_TELEMETRY $(DefineConstants);DOT_NET_BUILD_FROM_SOURCE diff --git a/eng/build.yml b/eng/build.yml index fc97c8fe6608..6fb25a126e73 100644 --- a/eng/build.yml +++ b/eng/build.yml @@ -74,6 +74,7 @@ jobs: $(_OfficialBuildIdArgs) /p:Test=false $(_InternalRuntimeDownloadArgs) + $(_OfficialBuildArgs) displayName: Build env: BuildConfig: $(_BuildConfig) @@ -480,4 +481,4 @@ jobs: ArtifactName: '$(_AgentOSName)_$(Agent.JobName)_$(Build.BuildNumber)' publishLocation: Container continueOnError: true - condition: always() \ No newline at end of file + condition: always() diff --git a/src/Cli/dotnet/Program.cs b/src/Cli/dotnet/Program.cs index eee34231f9ce..b7cc49dd4274 100644 --- a/src/Cli/dotnet/Program.cs +++ b/src/Cli/dotnet/Program.cs @@ -168,7 +168,7 @@ internal static int ProcessArgs(string[] args, TimeSpan startupTime, ITelemetry bool generateAspNetCertificate = environmentProvider.GetEnvironmentVariableAsBool("DOTNET_GENERATE_ASPNET_CERTIFICATE", defaultValue: true); bool telemetryOptout = - environmentProvider.GetEnvironmentVariableAsBool("DOTNET_CLI_TELEMETRY_OPTOUT", defaultValue: false); + environmentProvider.GetEnvironmentVariableAsBool(EnvironmentVariableNames.TELEMETRY_OPTOUT, defaultValue: CompileOptions.TelemetryOptOutDefault); bool addGlobalToolsToPath = environmentProvider.GetEnvironmentVariableAsBool("DOTNET_ADD_GLOBAL_TOOLS_TO_PATH", defaultValue: true); bool nologo = diff --git a/src/Cli/dotnet/Telemetry/Telemetry.cs b/src/Cli/dotnet/Telemetry/Telemetry.cs index 20b2af393c34..954fe655c64a 100644 --- a/src/Cli/dotnet/Telemetry/Telemetry.cs +++ b/src/Cli/dotnet/Telemetry/Telemetry.cs @@ -23,7 +23,6 @@ public class Telemetry : ITelemetry private Task _trackEventTask = null; private const string InstrumentationKey = "74cc1c9e-3e6e-4d05-b3fc-dde9101d0254"; - private const string TelemetryOptout = "DOTNET_CLI_TELEMETRY_OPTOUT"; public bool Enabled { get; } @@ -49,7 +48,8 @@ public Telemetry( environmentProvider = new EnvironmentProvider(); } - Enabled = !environmentProvider.GetEnvironmentVariableAsBool(TelemetryOptout, false) && PermissionExists(sentinel); + Enabled = !environmentProvider.GetEnvironmentVariableAsBool(EnvironmentVariableNames.TELEMETRY_OPTOUT, defaultValue: CompileOptions.TelemetryOptOutDefault) + && PermissionExists(sentinel); if (!Enabled) { diff --git a/src/Cli/dotnet/dotnet.csproj b/src/Cli/dotnet/dotnet.csproj index ad31316cefd3..bb202db43721 100644 --- a/src/Cli/dotnet/dotnet.csproj +++ b/src/Cli/dotnet/dotnet.csproj @@ -17,6 +17,7 @@ + diff --git a/src/Common/CompileOptions.cs b/src/Common/CompileOptions.cs new file mode 100644 index 000000000000..2ba77d957d5e --- /dev/null +++ b/src/Common/CompileOptions.cs @@ -0,0 +1,15 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.DotNet.Cli +{ + static class CompileOptions + { + public const bool TelemetryOptOutDefault = +#if MICROSOFT_ENABLE_TELEMETRY + false; +#else + true; +#endif + } +} diff --git a/src/Common/EnvironmentVariableNames.cs b/src/Common/EnvironmentVariableNames.cs index 236e27329eb1..573bf63dcd98 100644 --- a/src/Common/EnvironmentVariableNames.cs +++ b/src/Common/EnvironmentVariableNames.cs @@ -11,5 +11,6 @@ static class EnvironmentVariableNames public static readonly string WORKLOAD_UPDATE_NOTIFY_DISABLE = "DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_DISABLE"; public static readonly string WORKLOAD_UPDATE_NOTIFY_INTERVAL_HOURS = "DOTNET_CLI_WORKLOAD_UPDATE_NOTIFY_INTERVAL_HOURS"; public static readonly string WORKLOAD_DISABLE_PACK_GROUPS = "DOTNET_CLI_WORKLOAD_DISABLE_PACK_GROUPS"; + public static readonly string TELEMETRY_OPTOUT = "DOTNET_CLI_TELEMETRY_OPTOUT"; } } diff --git a/src/WebSdk/Publish/Tasks/Microsoft.NET.Sdk.Publish.Tasks.csproj b/src/WebSdk/Publish/Tasks/Microsoft.NET.Sdk.Publish.Tasks.csproj index 7946ba4deaf8..bfd3e00a8afd 100644 --- a/src/WebSdk/Publish/Tasks/Microsoft.NET.Sdk.Publish.Tasks.csproj +++ b/src/WebSdk/Publish/Tasks/Microsoft.NET.Sdk.Publish.Tasks.csproj @@ -48,7 +48,10 @@ True Resources.resx - + + + + true targets diff --git a/src/WebSdk/Publish/Tasks/WebConfigTelemetry.cs b/src/WebSdk/Publish/Tasks/WebConfigTelemetry.cs index e485e0547c8b..45cd901e3150 100644 --- a/src/WebSdk/Publish/Tasks/WebConfigTelemetry.cs +++ b/src/WebSdk/Publish/Tasks/WebConfigTelemetry.cs @@ -3,12 +3,12 @@ using System.IO; using System.Text.RegularExpressions; using System.Xml.Linq; +using Microsoft.DotNet.Cli; namespace Microsoft.NET.Sdk.Publish.Tasks { public class WebConfigTelemetry { - private const string TelemetryOptout = "DOTNET_CLI_TELEMETRY_OPTOUT"; // An example of a project line looks like this: // Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{05A5AD00-71B5-4612-AF2F-9EA9121C4111}" private static readonly Lazy s_crackProjectLine = new Lazy( @@ -31,7 +31,7 @@ public static XDocument AddTelemetry(XDocument webConfig, string projectGuid, bo { try { - bool isCLIOptOutEnabled = EnvironmentHelper.GetEnvironmentVariableAsBool(TelemetryOptout); + bool isCLIOptOutEnabled = EnvironmentHelper.GetEnvironmentVariableAsBool(EnvironmentVariableNames.TELEMETRY_OPTOUT, defaultValue: CompileOptions.TelemetryOptOutDefault); if (string.IsNullOrEmpty(projectGuid) && !ignoreProjectGuid && !isCLIOptOutEnabled) { projectGuid = GetProjectGuidFromSolutionFile(solutionFileFullPath, projectFileFullPath);