Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit a357fd7

Browse files
committed
Removing NuGetConfig from the first run experience and replacing the sentinel with the FirstUseNoticeSentinel when needed.
1 parent 529d7ca commit a357fd7

File tree

15 files changed

+37
-148
lines changed

15 files changed

+37
-148
lines changed

packaging/rpm/scripts/after_install_host.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ The data collected is anonymous and will be published in an aggregated form for
1919
2020
The .NET Core Tools telemetry feature is enabled by default. You can opt-out of the telemetry feature by setting an environment variable DOTNET_CLI_TELEMETRY_OPTOUT (for example, 'export' on macOS/Linux, 'set' on Windows) to true (for example, 'true', 1). You can read more about .NET Core tools telemetry at https://aka.ms/dotnet-cli-telemetry."
2121

22-
su - $SUDO_USER -c "dotnet new > /dev/null 2>&1 || true"
22+
dotnet new > /dev/null 2>&1 || true

src/Microsoft.DotNet.Configurer/CliFallbackFolderPathCalculator.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ public class CliFallbackFolderPathCalculator
1616
Environment.GetEnvironmentVariable("DOTNET_CLI_TEST_FALLBACKFOLDER") ??
1717
Path.Combine(new DirectoryInfo(AppContext.BaseDirectory).Parent.FullName, "NuGetFallbackFolder");
1818

19+
public string DotnetUserProfileFolderPath
20+
{
21+
get
22+
{
23+
string profileDir = Environment.GetEnvironmentVariable(
24+
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "USERPROFILE" : "HOME");
25+
26+
return Path.Combine(profileDir, ".dotnet");
27+
}
28+
}
29+
1930
public string NuGetUserSettingsDirectory =>
2031
NuGetEnvironment.GetFolderPath(NuGetFolderPath.UserSettingsDirectory);
2132
}

src/Microsoft.DotNet.Configurer/DotnetFirstTimeUseConfigurer.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ public void Configure()
4141

4242
if (ShouldPrimeNugetCache())
4343
{
44+
if (_nugetCacheSentinel.UnauthorizedAccess)
45+
{
46+
PrintUnauthorizedAccessMessage();
47+
}
48+
4449
PrintNugetCachePrimeMessage();
50+
4551
_nugetCachePrimer.PrimeCache();
4652
}
47-
else if (_nugetCacheSentinel.UnauthorizedAccess)
48-
{
49-
PrintUnauthorizedAccessMessage();
50-
}
5153
}
5254

5355
private bool ShouldPrintFirstTimeUseNotice()

src/Microsoft.DotNet.Configurer/FirstTimeUseNoticeSentinel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ public class FirstTimeUseNoticeSentinel : IFirstTimeUseNoticeSentinel
1414

1515
private readonly IFile _file;
1616

17-
private string _nugetCachePath;
17+
private string _dotnetUserProfileFolderPath;
1818

19-
private string SentinelPath => Path.Combine(_nugetCachePath, SENTINEL);
19+
private string SentinelPath => Path.Combine(_dotnetUserProfileFolderPath, SENTINEL);
2020

2121
public FirstTimeUseNoticeSentinel(CliFallbackFolderPathCalculator cliFallbackFolderPathCalculator) :
22-
this(cliFallbackFolderPathCalculator.CliFallbackFolderPath, FileSystemWrapper.Default.File)
22+
this(cliFallbackFolderPathCalculator.DotnetUserProfileFolderPath, FileSystemWrapper.Default.File)
2323
{
2424
}
2525

26-
internal FirstTimeUseNoticeSentinel(string nugetCachePath, IFile file)
26+
internal FirstTimeUseNoticeSentinel(string dotnetUserProfileFolderPath, IFile file)
2727
{
2828
_file = file;
29-
_nugetCachePath = nugetCachePath;
29+
_dotnetUserProfileFolderPath = dotnetUserProfileFolderPath;
3030
}
3131

3232
public bool Exists()

src/Microsoft.DotNet.Configurer/INuGetConfig.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Microsoft.DotNet.Configurer/LocalizableStrings.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Here are some options to fix this error:
143143
---------------------
144144
1. Re-run this command with elevated access.
145145
2. Disabled the first run experience by setting the environment variable DOTNET_SKIP_FIRST_TIME_EXPERIENCE to true.
146-
3. Copy the .NET Core SDK to a non-protected location and use it from there.";
146+
3. Copy the .NET Core SDK to a non-protected location and use it from there.
147147
</value>
148148
</data>
149149
</root>

src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,14 @@ public class NuGetCachePrimer : INuGetCachePrimer
1717

1818
private readonly INuGetCacheSentinel _nuGetCacheSentinel;
1919

20-
private readonly INuGetConfig _nuGetConfig;
21-
2220
private readonly CliFallbackFolderPathCalculator _cliFallbackFolderPathCalculator;
2321

2422
public NuGetCachePrimer(
2523
INuGetPackagesArchiver nugetPackagesArchiver,
2624
INuGetCacheSentinel nuGetCacheSentinel,
27-
INuGetConfig nuGetConfig,
2825
CliFallbackFolderPathCalculator cliFallbackFolderPathCalculator)
2926
: this(nugetPackagesArchiver,
3027
nuGetCacheSentinel,
31-
nuGetConfig,
3228
cliFallbackFolderPathCalculator,
3329
FileSystemWrapper.Default.File)
3430
{
@@ -37,16 +33,13 @@ public NuGetCachePrimer(
3733
internal NuGetCachePrimer(
3834
INuGetPackagesArchiver nugetPackagesArchiver,
3935
INuGetCacheSentinel nuGetCacheSentinel,
40-
INuGetConfig nuGetConfig,
4136
CliFallbackFolderPathCalculator cliFallbackFolderPathCalculator,
4237
IFile file)
4338
{
4439
_nugetPackagesArchiver = nugetPackagesArchiver;
4540

4641
_nuGetCacheSentinel = nuGetCacheSentinel;
4742

48-
_nuGetConfig = nuGetConfig;
49-
5043
_cliFallbackFolderPathCalculator = cliFallbackFolderPathCalculator;
5144

5245
_file = file;
@@ -63,8 +56,6 @@ public void PrimeCache()
6356

6457
_nugetPackagesArchiver.ExtractArchive(nuGetFallbackFolder);
6558

66-
_nuGetConfig.AddCliFallbackFolder(nuGetFallbackFolder);
67-
6859
_nuGetCacheSentinel.CreateIfNotExists();
6960
}
7061

src/Microsoft.DotNet.Configurer/NuGetConfig.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/dotnet/Program.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ internal static int ProcessArgs(string[] args, ITelemetry telemetryClient = null
128128

129129
if (telemetryClient == null)
130130
{
131-
telemetryClient = new Telemetry(nugetCacheSentinel);
131+
telemetryClient = new Telemetry(firstTimeUseNoticeSentinel);
132132
}
133133
}
134134

@@ -177,18 +177,16 @@ private static void ConfigureDotNetForFirstTimeUse(
177177
var nugetPackagesArchiver = new NuGetPackagesArchiver();
178178
var environmentProvider = new EnvironmentProvider();
179179
var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true);
180-
var nugetConfig = new NuGetConfig(cliFallbackFolderPathCalculator);
181180
var nugetCachePrimer = new NuGetCachePrimer(
182181
nugetPackagesArchiver,
183182
nugetCacheSentinel,
184-
nugetConfig,
185183
cliFallbackFolderPathCalculator);
186184
var dotnetConfigurer = new DotnetFirstTimeUseConfigurer(
187185
nugetCachePrimer,
188186
nugetCacheSentinel,
189187
firstTimeUseNoticeSentinel,
190188
environmentProvider,
191-
Reporter.Output
189+
Reporter.Output,
192190
cliFallbackFolderPathCalculator.CliFallbackFolderPath);
193191

194192
dotnetConfigurer.Configure();

src/dotnet/Telemetry.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public class Telemetry : ITelemetry
3535

3636
public Telemetry () : this(null) { }
3737

38-
public Telemetry(INuGetCacheSentinel sentinel) : this(sentinel, null) { }
38+
public Telemetry(IFirstTimeUseNoticeSentinel sentinel) : this(sentinel, null) { }
3939

40-
public Telemetry(INuGetCacheSentinel sentinel, string sessionId)
40+
public Telemetry(IFirstTimeUseNoticeSentinel sentinel, string sessionId)
4141
{
4242
Enabled = !Env.GetEnvironmentVariableAsBool(TelemetryOptout) && PermissionExists(sentinel);
4343

@@ -53,7 +53,7 @@ public Telemetry(INuGetCacheSentinel sentinel, string sessionId)
5353
_trackEventTask = Task.Factory.StartNew(() => InitializeTelemetry());
5454
}
5555

56-
private bool PermissionExists(INuGetCacheSentinel sentinel)
56+
private bool PermissionExists(IFirstTimeUseNoticeSentinel sentinel)
5757
{
5858
if (sentinel == null)
5959
{

0 commit comments

Comments
 (0)