diff --git a/build_projects/dotnet-cli-build/CompileTargets.cs b/build_projects/dotnet-cli-build/CompileTargets.cs index 9d08a07ff..dbadac7b2 100644 --- a/build_projects/dotnet-cli-build/CompileTargets.cs +++ b/build_projects/dotnet-cli-build/CompileTargets.cs @@ -164,12 +164,7 @@ namespace Microsoft.DotNet.Cli.Build string rootOutputDirectory, DotNetCli currentDotnet) { - var buildVersion = c.BuildContext.Get("BuildVersion"); - var sdkOutputDirectory = Path.Combine(rootOutputDirectory, "sdk", buildVersion.NuGetVersion); - - CompileCliSdk(c, dotnet, rootOutputDirectory); - - GenerateNuGetPackagesArchive(c, currentDotnet, sdkOutputDirectory); + CompileCliSdk(c, dotnet, rootOutputDirectory, currentDotnet); return c.Success(); } @@ -177,7 +172,8 @@ namespace Microsoft.DotNet.Cli.Build private static BuildTargetResult CompileCliSdk( BuildTargetContext c, DotNetCli dotnet, - string rootOutputDirectory) + string rootOutputDirectory, + DotNetCli dotnetToGenerateNuGetPackagesArchive = null) { var configuration = c.BuildContext.Get("Configuration"); var buildVersion = c.BuildContext.Get("BuildVersion"); @@ -280,8 +276,13 @@ namespace Microsoft.DotNet.Cli.Build var content = $@"{c.BuildContext["CommitHash"]}{Environment.NewLine}{version}{Environment.NewLine}"; File.WriteAllText(Path.Combine(sdkOutputDirectory, ".version"), content); + if(dotnetToGenerateNuGetPackagesArchive != null) + { + GenerateNuGetPackagesArchive(c, dotnetToGenerateNuGetPackagesArchive, sdkOutputDirectory); + } + return c.Success(); - } + } private static void GenerateNuGetPackagesArchive( BuildTargetContext c, @@ -325,7 +326,7 @@ namespace Microsoft.DotNet.Cli.Build string sdkOutputDirectory) { var configuration = c.BuildContext.Get("Configuration"); - var archiver = Path.Combine(Dirs.Output, "tools", $"Archiver{Constants.ExeSuffix}"); + var archiverExe = Path.Combine(Dirs.Output, "tools", $"Archiver{Constants.ExeSuffix}"); var intermediateArchive = Path.Combine(Dirs.Intermediate, "nuGetPackagesArchive.lzma"); var finalArchive = Path.Combine(sdkOutputDirectory, "nuGetPackagesArchive.lzma"); @@ -334,14 +335,14 @@ namespace Microsoft.DotNet.Cli.Build c.Info("Publishing Archiver"); dotnet.Publish("--output", Path.Combine(Dirs.Output, "tools"), "--configuration", configuration) - .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "tools", "Archiver")) + .WorkingDirectory(Path.Combine(Dirs.RepoRoot, "tools", "Archiver")) .Execute() .EnsureSuccessful(); - Cmd(archiver, + Cmd(archiverExe, "-a", intermediateArchive, nuGetPackagesArchiveFolder) - .Execute(); + .Execute(); File.Copy(intermediateArchive, finalArchive); } diff --git a/src/Microsoft.DotNet.Configurer/DotnetFirstTimeUseConfigurer.cs b/src/Microsoft.DotNet.Configurer/DotnetFirstTimeUseConfigurer.cs index e67b10cd5..3b508a243 100644 --- a/src/Microsoft.DotNet.Configurer/DotnetFirstTimeUseConfigurer.cs +++ b/src/Microsoft.DotNet.Configurer/DotnetFirstTimeUseConfigurer.cs @@ -9,13 +9,18 @@ namespace Microsoft.DotNet.Configurer { public class DotnetFirstTimeUseConfigurer { + private IEnvironmentProvider _environmentProvider; private INuGetCachePrimer _nugetCachePrimer; private INuGetCacheSentinel _nugetCacheSentinel; - public DotnetFirstTimeUseConfigurer(INuGetCachePrimer nugetCachePrimer, INuGetCacheSentinel nugetCacheSentinel) + public DotnetFirstTimeUseConfigurer( + INuGetCachePrimer nugetCachePrimer, + INuGetCacheSentinel nugetCacheSentinel, + IEnvironmentProvider environmentProvider) { _nugetCachePrimer = nugetCachePrimer; _nugetCacheSentinel = nugetCacheSentinel; + _environmentProvider = environmentProvider; } public void Configure() @@ -30,29 +35,28 @@ namespace Microsoft.DotNet.Configurer private void PrintFirstTimeUseNotice() { + const string firstTimeUseWelcomeMessage = @"Welcome to .NET Core! +--------------------- +Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs. +Telemetry +-------------- +The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include commandline arguments. The data is collected by Microsoft and shared with the community. +You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell. +You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry. +Configuring... +------------------- +A command is running to initially populate your local package cache, to improve restorespeed and enable offline access. This command will take up to a minute to complete and will only happen once."; + Reporter.Output.WriteLine(); - Reporter.Output.WriteLine("Welcome to .NET Core!"); - Reporter.Output.WriteLine("---------------------"); - Reporter.Output.WriteLine("Learn more about .NET Core @ https://aka.ms/dotnet-docs. " + - "Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs."); - Reporter.Output.WriteLine("Telemetry"); - Reporter.Output.WriteLine("--------------"); - Reporter.Output.WriteLine("The .NET Core tools collect usage data in order to improve your experience. " + - "The data is anonymous and does not include commandline arguments. " + - "The data is collected by Microsoft and shared with the community."); - Reporter.Output.WriteLine(); - Reporter.Output.WriteLine("You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT " + - "environment variable to 1 using your favorite shell."); - Reporter.Output.WriteLine("You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry."); - Reporter.Output.WriteLine("Configuring..."); - Reporter.Output.WriteLine("-------------------"); - Reporter.Output.WriteLine("A command is running to initially populate your local package cache, to improve restore" + - "speed and enable offline access. This command will take up to a minute to complete and will only happen once."); + Reporter.Output.WriteLine(firstTimeUseWelcomeMessage); } private bool ShouldPrimeNugetCache() { - return !_nugetCacheSentinel.Exists(); + var skipFirstTimeExperience = + _environmentProvider.GetEnvironmentVariableAsBool("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", false)); + + return !skipFirstTimeExperience && !_nugetCacheSentinel.Exists(); } } } diff --git a/src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs b/src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs index 12f93b968..ae8ed84d5 100644 --- a/src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs +++ b/src/Microsoft.DotNet.Configurer/NuGetCachePrimer.cs @@ -50,9 +50,9 @@ namespace Microsoft.DotNet.Configurer return; } - var pathToPackagesArchive = _nugetPackagesArchiver.ExtractArchive(); + var extractedPackagesArchiveDirectory = _nugetPackagesArchiver.ExtractArchive(); - PrimeCacheUsingArchive(pathToPackagesArchive); + PrimeCacheUsingArchive(extractedPackagesArchiveDirectory); } private bool SkipPrimingTheCache() @@ -60,7 +60,7 @@ namespace Microsoft.DotNet.Configurer return !_file.Exists(_nugetPackagesArchiver.NuGetPackagesArchive); } - private void PrimeCacheUsingArchive(string pathToPackagesArchive) + private void PrimeCacheUsingArchive(string extractedPackagesArchiveDirectory) { using (var temporaryDotnetNewDirectory = _directory.CreateTemporaryDirectory()) { @@ -69,7 +69,8 @@ namespace Microsoft.DotNet.Configurer if (createProjectSucceeded) { - var restoreProjectSucceeded = RestoreTemporaryProject(pathToPackagesArchive, workingDirectory); + var restoreProjectSucceeded = + RestoreTemporaryProject(extractedPackagesArchiveDirectory, workingDirectory); if (restoreProjectSucceeded) { _nuGetCacheSentinel.CreateIfNotExists(); @@ -83,11 +84,11 @@ namespace Microsoft.DotNet.Configurer return RunCommand("new", Enumerable.Empty(), workingDirectory); } - private bool RestoreTemporaryProject(string pathToPackagesArchive, string workingDirectory) + private bool RestoreTemporaryProject(string extractedPackagesArchiveDirectory, string workingDirectory) { return RunCommand( "restore", - new[] {NUGET_SOURCE_PARAMETER, $"{pathToPackagesArchive}"}, + new[] {NUGET_SOURCE_PARAMETER, $"{extractedPackagesArchiveDirectory}"}, workingDirectory); } diff --git a/src/dotnet-archive/project.json b/src/dotnet-archive/project.json index 4a4dbfd4c..b4f4bcceb 100644 --- a/src/dotnet-archive/project.json +++ b/src/dotnet-archive/project.json @@ -14,7 +14,7 @@ }, "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc3-004391" + "version": "1.0.0-rc3-004449-00" } }, "frameworks": { diff --git a/src/dotnet/Program.cs b/src/dotnet/Program.cs index 54863d2ad..47dd721ff 100644 --- a/src/dotnet/Program.cs +++ b/src/dotnet/Program.cs @@ -55,10 +55,10 @@ namespace Microsoft.DotNet.Cli try { + ConfigureDotNetForFirstTimeUse(); + using (PerfTrace.Current.CaptureTiming()) { - ConfigureDotNetForFirstTimeUse(); - return ProcessArgs(args, new Telemetry()); } } @@ -162,15 +162,23 @@ namespace Microsoft.DotNet.Cli private static void ConfigureDotNetForFirstTimeUse() { - using (var nugetPackagesArchiver = new NuGetPackagesArchiver()) + using (PerfTrace.Current.CaptureTiming()) { - var nugetCacheSentinel = new NuGetCacheSentinel(); - var commandFactory = new DotNetCommandFactory(); - var nugetCachePrimer = new NuGetCachePrimer(commandFactory, nugetPackagesArchiver, nugetCacheSentinel); - var dotnetConfigurer = new DotnetFirstTimeUseConfigurer(nugetCachePrimer, nugetCacheSentinel); + using (var nugetPackagesArchiver = new NuGetPackagesArchiver()) + { + var environmentProvider = new EnvironmentProvider(); + var nugetCacheSentinel = new NuGetCacheSentinel(); + var commandFactory = new DotNetCommandFactory(); + var nugetCachePrimer = + new NuGetCachePrimer(commandFactory, nugetPackagesArchiver, nugetCacheSentinel); + var dotnetConfigurer = new DotnetFirstTimeUseConfigurer( + nugetCachePrimer, + nugetCacheSentinel, + environmentProvider); - dotnetConfigurer.Configure(); - } + dotnetConfigurer.Configure(); + } + } } private static void InitializeProcess() diff --git a/test/Microsoft.DotNet.Configurer.UnitTests/GivenADotnetFirstTimeUseConfigurer.cs b/test/Microsoft.DotNet.Configurer.UnitTests/GivenADotnetFirstTimeUseConfigurer.cs index 2c5c85703..37e21e2e5 100644 --- a/test/Microsoft.DotNet.Configurer.UnitTests/GivenADotnetFirstTimeUseConfigurer.cs +++ b/test/Microsoft.DotNet.Configurer.UnitTests/GivenADotnetFirstTimeUseConfigurer.cs @@ -15,11 +15,17 @@ namespace Microsoft.DotNet.Configurer.UnitTests { private Mock _nugetCachePrimerMock; private Mock _nugetCacheSentinelMock; + private Mock _environmentProviderMock; public GivenADotnetFirstTimeUseConfigurer() { _nugetCachePrimerMock = new Mock(); _nugetCacheSentinelMock = new Mock(); + _environmentProviderMock = new Mock(); + + _environmentProviderMock + .Setup(e => e.GetEnvironmentVariableAsBool("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", false)) + .Returns(false); } [Fact] @@ -29,7 +35,26 @@ namespace Microsoft.DotNet.Configurer.UnitTests var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, - _nugetCacheSentinelMock.Object); + _nugetCacheSentinelMock.Object, + _environmentProviderMock.Object); + + dotnetFirstTimeUseConfigurer.Configure(); + + _nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never); + } + + [Fact] + public void It_does_not_prime_the_cache_if_the_sentinel_exists_but_the_user_has_set_the_DOTNET_SKIP_FIRST_TIME_EXPERIENCE_environemnt_variable() + { + _nugetCacheSentinelMock.Setup(n => n.Exists()).Returns(false); + _environmentProviderMock + .Setup(e => e.GetEnvironmentVariableAsBool("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", false)) + .Returns(true); + + var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( + _nugetCachePrimerMock.Object, + _nugetCacheSentinelMock.Object, + _environmentProviderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); @@ -43,7 +68,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, - _nugetCacheSentinelMock.Object); + _nugetCacheSentinelMock.Object, + _environmentProviderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); diff --git a/test/Microsoft.DotNet.Configurer.UnitTests/project.json b/test/Microsoft.DotNet.Configurer.UnitTests/project.json index d876769f2..2eaaf6fa0 100644 --- a/test/Microsoft.DotNet.Configurer.UnitTests/project.json +++ b/test/Microsoft.DotNet.Configurer.UnitTests/project.json @@ -6,7 +6,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-rc3-004363" + "version": "1.0.0-rc3-004442-00" }, "System.Diagnostics.TraceSource": "4.0.0-rc3-24131-00", "Microsoft.DotNet.Configurer": { diff --git a/tools/Archiver/project.json b/tools/Archiver/project.json index fa12a278d..07db9fa6e 100644 --- a/tools/Archiver/project.json +++ b/tools/Archiver/project.json @@ -12,7 +12,7 @@ "Microsoft.DotNet.Archive": { "target": "project" }, - "Microsoft.NETCore.App": "1.0.0-rc3-004391" + "Microsoft.NETCore.App": "1.0.0-rc3-004442-00" }, "frameworks": { "netcoreapp1.0": {}