dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.7k stars 1.06k forks source link

Disabling first time experience in CI #12195

Open jaredpar opened 4 years ago

jaredpar commented 4 years ago

What are the recommended steps to disable the first time experience and telemetry in CI? Specifically for GitHub Actions. I've tried using the environment variables suggested in other issues but this has no impact.

    - name: Restore
      run: dotnet restore
      env:
        DOTNET_CLI_TELEMETRY_OPTOUT: 1
        DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1

This still produces the first time output when running restore (on all OS):

image

timheuer commented 4 years ago

Same as #3828?

jaredpar commented 4 years ago

@timheuer #3828 is a long issue with many comments. It's very difficult to pullout a concrete actionable message in that issue. The change I listed here was done by pulling out what information I could find in that issue and it didn't work.

timheuer commented 4 years ago

@jaredpar if you add DOTNET_NOLOGO: true this disables. Now this is in .300 i added it as well and it suppresses. I think this was your goal right? Ex: https://github.com/timheuer/buildtest/runs/808185371?check_suite_focus=true#step:4:1

jaredpar commented 4 years ago

Yep that works. Thanks!

Do we have this documented anywhere though in a MD file? Or is the expectation that customers should be going through GitHub issues to discover this?

timheuer commented 4 years ago

@jaredpar yep it is in the docs under environment vars section: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet#environment-variables

PathogenDavid commented 4 years ago

Is it intentional that DOTNET_NOLOGO doesn't work in preview releases? I've been debugging why it wasn't working for me and eventually I figured out using 3.1.300 instead of 5 preview 6 fixed it.

.NET 5 Preview 6:

Run dotnet build

Welcome to .NET 5.0!
---------------------
SDK Version: 5.0.100-preview.6.20318.15

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

.NET Core 3.1.300

Run dotnet build
Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
timheuer commented 4 years ago

@PathogenDavid I think in previews we keep it for telemetry warning, is that right @marcpopMSFT -- or could just be a bug :-)

PathogenDavid commented 4 years ago

I'm starting to lean more towards bug.

I was messing around with it some more and found out that if I opt-out of telemetry that part of the notice (and only that part) goes away. That reminded me that I still had the ASP.NET certificate enabled, so I disabled it and it's still being generated. Tried with .NET Core 3.1.300 and it doesn't happen there.

Edit: Happens with preview 7 too: Welcome message and certificate

I dug a little bit, turns out that was a red herring. Turns out the real issue there is that the ASP.NET certificate notice is part of the welcome message, so it's printed regardless of whether a certificate was actually generated.

PathogenDavid commented 4 years ago

Got it figured it out. The DOTNET_NOLOGO changes aren't in .NET 5 yet. I assume the feature was added sometime between when dotnet/cli was merged into this repo for .NET 5 development and now (or something like that.)

It looks like #12424 will fix this for future previews.

marcpopMSFT commented 4 years ago

@PathogenDavid You are correct. We didn't have automatic code flow from 3.1 into our .net 5 branches but we have caught up with that PR and are monitoring for additional changes we'll need in the future so we should be good for a future PR.

KirillOsenkov commented 4 years ago

A customer on Twitter is mentioning that dotnet msbuild does not respect the DOTNET_NOLOGO environment variable: https://twitter.com/jasonkarns/status/1320030746619334656

Is this a bug?

PathogenDavid commented 3 years ago

DOTNET_NOLOGO does what it's supposed to with dotnet msbuild:

image

I think that Jason is expecting it to do the same thing as /nologo, which isn't how it's documented in either of the two places I could find. (Here and here)

It's probably unnecessarily confusing to have two different concepts use nologo, but I imagine it's way too late to switch to DOTNET_NOWELCOME.

ericsampson commented 3 years ago

This is a separate topic, but would it make sense to have DOTNET_SKIP_FIRST_TIME_EXPERIENCE set to true by default in GitHub Actions hosted runners? Just thinking that the % of users that will know to set this is probably small, and that in aggregate worldwide having it default true could probably save some carbon emissions (and customer build minute $) :D

ericsampson commented 3 years ago

would it not be somewhat logical to change things so that setting DOTNET_NOLOGO=1 would also disable the MSBuild welcome output when its run via 'dotnet msbuild' ?

PathogenDavid commented 3 years ago

@ericsampson That's probably a better request for actions/setup-dotnet. Also IIRC DOTNET_SKIP_FIRST_TIME_EXPERIENCE was superseded by DOTNET_NOLOGO.

Also since we're talking about carbon emissions you should probably set DOTNET_GENERATE_ASPNET_CERTIFICATE to false unless you actually need it.

(Also also if you're really concerned about minutes and carbon emissions, you should probably use custom build agents that have everything you need pre-installed.)

would also disable the MSBuild welcome output when its run via 'dotnet msbuild' ?

In my opinion, it absolutely should not. What MSBuild prints is not really a welcome message. It's telling you the version of MSBuild being run, which personally is something I'd want in my CI logs.

ericsampson commented 3 years ago

@PathogenDavid fair point - I guess there's no MSBUILD_NOLOGO equivalent. It's just unfortunate that there is a naming collision between DOTNET_NOLOGO and dotnet msbuild /nologo, which leads people to assume the former will set the latter - but we can't go back in time : )

I don't believe that DOTNET_NOLOGO results in the nuget cache skipping. it doesn't supercede the _SKIP_FTE flag, unless I'm mistaken.

FWIW, there's a bunch of .NET Core SDKs pre-installed on the Actions hosted runners - but it's really not clear to me from the setup-dotnet runner documentation if it's smart enough to use those if there's a match, or just always installs the specified SDK.