Merge pull request #9381 from dotnet/merges/release/2.1.4xx-to-master

Merge release/2.1.4xx to master
This commit is contained in:
Livar 2018-06-05 22:45:53 -07:00 committed by GitHub
commit 670dcedba2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 216 additions and 108 deletions

View file

@ -5,7 +5,7 @@
<MicrosoftAspNetCoreAppPackageVersion>$(MicrosoftAspNetCoreAllPackageVersion)</MicrosoftAspNetCoreAppPackageVersion>
<MicrosoftNETCoreAppPackageVersion>2.2.0-preview1-26529-01</MicrosoftNETCoreAppPackageVersion>
<MicrosoftNETCoreDotNetHostResolverPackageVersion>$(MicrosoftNETCoreAppPackageVersion)</MicrosoftNETCoreDotNetHostResolverPackageVersion>
<MicrosoftBuildPackageVersion>15.8.0-preview-000061</MicrosoftBuildPackageVersion>
<MicrosoftBuildPackageVersion>15.8.0-preview-000060</MicrosoftBuildPackageVersion>
<MicrosoftBuildFrameworkPackageVersion>$(MicrosoftBuildPackageVersion)</MicrosoftBuildFrameworkPackageVersion>
<MicrosoftBuildRuntimePackageVersion>$(MicrosoftBuildPackageVersion)</MicrosoftBuildRuntimePackageVersion>
<MicrosoftBuildLocalizationPackageVersion>$(MicrosoftBuildPackageVersion)</MicrosoftBuildLocalizationPackageVersion>

View file

@ -8,7 +8,8 @@
<MajorMinorVersion>$(VersionMajor).$(VersionMinor)</MajorMinorVersion>
<CliVersionNoSuffix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</CliVersionNoSuffix>
<CliVersionPrefix>$(CliVersionNoSuffix)-$(ReleaseSuffix)</CliVersionPrefix>
<CliBrandingVersion>$(CliVersionNoSuffix) - $(ReleaseSuffix)</CliBrandingVersion>
<CliBrandingVersion Condition=" '$(DropSuffix)' != 'true' ">$(CliVersionNoSuffix) - $(ReleaseSuffix)</CliBrandingVersion>
<CliBrandingVersion Condition=" '$(DropSuffix)' == 'true' ">$(CliVersionNoSuffix)</CliBrandingVersion>
<SimpleVersion Condition=" '$(DropSuffix)' != 'true' ">$(CliVersionNoSuffix).$(CommitCount)</SimpleVersion>
<SimpleVersion Condition=" '$(SimpleVersion)' == '' ">$(CliVersionNoSuffix)</SimpleVersion>

View file

@ -119,6 +119,11 @@ namespace Microsoft.DotNet.Tools.Common
/// </summary>
public static string GetRelativePath(string path1, string path2)
{
if (!Path.IsPathRooted(path1) || !Path.IsPathRooted(path2))
{
throw new ArgumentException("both paths need to be rooted/full path");
}
return GetRelativePath(path1, path2, Path.DirectorySeparatorChar, true);
}

View file

@ -7,6 +7,7 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyMetadataAttribute("Serviceable", "True")]
[assembly: InternalsVisibleTo("dotnet, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("dotnet.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.DotNet.Configurer, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.DotNet.Tools.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.DotNet.Cli.Utils.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.DotNet.TestFramework, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

View file

@ -21,7 +21,7 @@ namespace Microsoft.DotNet.Configurer
private string SentinelPath => Path.Combine(_dotnetUserProfileFolderPath, SENTINEL);
public AspNetCertificateSentinel(CliFolderPathCalculator cliFallbackFolderPathCalculator) :
public AspNetCertificateSentinel() :
this(
CliFolderPathCalculator.DotnetUserProfileFolderPath,
FileSystemWrapper.Default.File,

View file

@ -4,40 +4,59 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli.Utils;
using NuGet.Common;
namespace Microsoft.DotNet.Configurer
{
public class CliFolderPathCalculator
public static class CliFolderPathCalculator
{
public const string DotnetHomeVariableName = "DOTNET_CLI_HOME";
private const string DotnetProfileDirectoryName = ".dotnet";
private const string ToolsShimFolderName = "tools";
public string CliFallbackFolderPath => Environment.GetEnvironmentVariable("DOTNET_CLI_TEST_FALLBACKFOLDER") ??
Path.Combine(new DirectoryInfo(AppContext.BaseDirectory).Parent.FullName, "NuGetFallbackFolder");
public string ToolsShimPath => Path.Combine(DotnetUserProfileFolderPath, ToolsShimFolderName);
public string ToolsPackagePath => ToolPackageFolderPathCalculator.GetToolPackageFolderPath(ToolsShimPath);
public BashPathUnderHomeDirectory ToolsShimPathInUnix
public static string CliFallbackFolderPath =>
Environment.GetEnvironmentVariable("DOTNET_CLI_TEST_FALLBACKFOLDER") ??
Path.Combine(new DirectoryInfo(AppContext.BaseDirectory).Parent.FullName, "NuGetFallbackFolder");
public static string ToolsShimPath => Path.Combine(DotnetUserProfileFolderPath, ToolsShimFolderName);
public static string ToolsPackagePath => ToolPackageFolderPathCalculator.GetToolPackageFolderPath(ToolsShimPath);
public static BashPathUnderHomeDirectory ToolsShimPathInUnix =>
new BashPathUnderHomeDirectory(
DotnetHomePath,
Path.Combine(DotnetProfileDirectoryName, ToolsShimFolderName));
public static string DotnetUserProfileFolderPath =>
Path.Combine(DotnetHomePath, DotnetProfileDirectoryName);
public static string PlatformHomeVariableName =>
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "USERPROFILE" : "HOME";
public static string DotnetHomePath
{
get
{
return new BashPathUnderHomeDirectory(Environment.GetEnvironmentVariable("HOME"),
Path.Combine(DotnetProfileDirectoryName, ToolsShimFolderName));
var home = Environment.GetEnvironmentVariable(DotnetHomeVariableName);
if (string.IsNullOrEmpty(home))
{
home = Environment.GetEnvironmentVariable(PlatformHomeVariableName);
if (string.IsNullOrEmpty(home))
{
throw new ConfigurationException(
string.Format(
LocalizableStrings.FailedToDetermineUserHomeDirectory,
DotnetHomeVariableName))
.DisplayAsError();
}
}
return home;
}
}
public static string DotnetUserProfileFolderPath
{
get
{
string profileDir = Environment.GetEnvironmentVariable(
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "USERPROFILE" : "HOME");
return Path.Combine(profileDir, DotnetProfileDirectoryName);
}
}
public string NuGetUserSettingsDirectory =>
public static string NuGetUserSettingsDirectory =>
NuGetEnvironment.GetFolderPath(NuGetFolderPath.UserSettingsDirectory);
}
}

View file

@ -0,0 +1,22 @@
// 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.
using System;
namespace Microsoft.DotNet.Configurer
{
internal class ConfigurationException : Exception
{
public ConfigurationException()
{
}
public ConfigurationException(string message) : base(message)
{
}
public ConfigurationException(string message, Exception innerException) : base(message, innerException)
{
}
}
}

View file

@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Configurer
private string SentinelPath => Path.Combine(_dotnetUserProfileFolderPath, SENTINEL);
public FirstTimeUseNoticeSentinel(CliFolderPathCalculator cliFolderPathCalculator) :
public FirstTimeUseNoticeSentinel() :
this(
CliFolderPathCalculator.DotnetUserProfileFolderPath,
FileSystemWrapper.Default.File,

View file

@ -154,4 +154,7 @@ Successfully installed the ASP.NET Core HTTPS Development Certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only). For establishing trust on other platforms refer to the platform specific documentation.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.</value>
</data>
<data name="FailedToDetermineUserHomeDirectory" xml:space="preserve">
<value>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</value>
</data>
</root>

View file

@ -17,6 +17,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
<PackageReference Include="NuGet.Common" Version="$(NuGetCommonPackageVersion)" />
<PackageReference Include="NuGet.Configuration" Version="$(NuGetConfigurationPackageVersion)" />
<PackageReference Include="Microsoft.DotNet.Archive" Version="$(MicrosoftDotNetArchivePackageVersion)" />

View file

@ -17,31 +17,20 @@ namespace Microsoft.DotNet.Configurer
private readonly INuGetCacheSentinel _nuGetCacheSentinel;
private readonly CliFolderPathCalculator _cliFolderPathCalculator;
public NuGetCachePrimer(
INuGetPackagesArchiver nugetPackagesArchiver,
INuGetCacheSentinel nuGetCacheSentinel,
CliFolderPathCalculator cliFolderPathCalculator)
: this(nugetPackagesArchiver,
nuGetCacheSentinel,
cliFolderPathCalculator,
FileSystemWrapper.Default.File)
public NuGetCachePrimer(INuGetPackagesArchiver nugetPackagesArchiver, INuGetCacheSentinel nuGetCacheSentinel)
: this(nugetPackagesArchiver, nuGetCacheSentinel, FileSystemWrapper.Default.File)
{
}
internal NuGetCachePrimer(
INuGetPackagesArchiver nugetPackagesArchiver,
INuGetCacheSentinel nuGetCacheSentinel,
CliFolderPathCalculator cliFolderPathCalculator,
IFile file)
{
_nugetPackagesArchiver = nugetPackagesArchiver;
_nuGetCacheSentinel = nuGetCacheSentinel;
_cliFolderPathCalculator = cliFolderPathCalculator;
_file = file;
}
@ -52,7 +41,7 @@ namespace Microsoft.DotNet.Configurer
return;
}
var nuGetFallbackFolder = _cliFolderPathCalculator.CliFallbackFolderPath;
var nuGetFallbackFolder = CliFolderPathCalculator.CliFallbackFolderPath;
_nugetPackagesArchiver.ExtractArchive(nuGetFallbackFolder);

View file

@ -27,8 +27,8 @@ namespace Microsoft.DotNet.Configurer
private Stream InProgressSentinel { get; set; }
public NuGetCacheSentinel(CliFolderPathCalculator cliFolderPathCalculator) :
this(cliFolderPathCalculator.CliFallbackFolderPath,
public NuGetCacheSentinel() :
this(CliFolderPathCalculator.CliFallbackFolderPath,
FileSystemWrapper.Default.File,
FileSystemWrapper.Default.Directory)
{

View file

@ -14,7 +14,7 @@ namespace Microsoft.DotNet.Configurer
private readonly IDirectory _directory;
private string _dotnetUserProfileFolderPath;
public UserLevelCacheWriter(CliFolderPathCalculator cliFolderPathCalculator) :
public UserLevelCacheWriter() :
this(
CliFolderPathCalculator.DotnetUserProfileFolderPath,
FileSystemWrapper.Default.File,

View file

@ -71,6 +71,11 @@ Pokud chcete certifikátu důvěřovat (platí jenom pro Windows a macOS), nains
Další informace o konfiguraci protokolu HTTPS najdete na webu https://go.microsoft.com/fwlink/?linkid=848054.</target>
<note />
</trans-unit>
<trans-unit id="FailedToDetermineUserHomeDirectory">
<source>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</source>
<target state="new">The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -71,6 +71,11 @@ Um dem Zertifikat zu vertrauen (nur Windows und macOS), installieren Sie zuerst
Weitere Informationen zur Konfiguration von HTTPS finden Sie unter https://go.microsoft.com/fwlink/?linkid=848054.</target>
<note />
</trans-unit>
<trans-unit id="FailedToDetermineUserHomeDirectory">
<source>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</source>
<target state="new">The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -70,6 +70,11 @@ Para confiar en el certificado (solo Windows y macOS), instale primero la herram
Para obtener más información sobre la configuración HTTPS, vea https://go.microsoft.com/fwlink/?linkid=848054.</target>
<note />
</trans-unit>
<trans-unit id="FailedToDetermineUserHomeDirectory">
<source>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</source>
<target state="new">The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -71,6 +71,11 @@ Pour approuver le certificat (Windows et macOS uniquement), installez d'abord l'
Pour plus d'informations sur la configuration du protocole HTTPS, consultez https://go.microsoft.com/fwlink/?linkid=848054.</target>
<note />
</trans-unit>
<trans-unit id="FailedToDetermineUserHomeDirectory">
<source>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</source>
<target state="new">The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -71,6 +71,11 @@ Per considerare attendibile il certificato (solo Windows e macOS), installare pr
Per altre informazioni sulla configurazione di HTTPS, vedere https://go.microsoft.com/fwlink/?linkid=848054.</target>
<note />
</trans-unit>
<trans-unit id="FailedToDetermineUserHomeDirectory">
<source>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</source>
<target state="new">The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -71,6 +71,11 @@ ASP.NET Core HTTPS 開発証明書が正常にインストールされました
HTTPS を構成する方法の詳細については、https://go.microsoft.com/fwlink/?linkid=848054 をご覧ください。</target>
<note />
</trans-unit>
<trans-unit id="FailedToDetermineUserHomeDirectory">
<source>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</source>
<target state="new">The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -71,6 +71,11 @@ ASP.NET Core HTTPS 개발 인증서를 설치했습니다.
HTTPS 구성에 대한 자세한 내용은 https://go.microsoft.com/fwlink/?linkid=848054를 참조하세요.</target>
<note />
</trans-unit>
<trans-unit id="FailedToDetermineUserHomeDirectory">
<source>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</source>
<target state="new">The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -71,6 +71,11 @@ Aby ufać temu certyfikatowi (dotyczy tylko systemów Windows i macOS), najpierw
Aby uzyskać więcej informacji dotyczących konfigurowania protokołu HTTPS, zobacz https://go.microsoft.com/fwlink/?linkid=848054.</target>
<note />
</trans-unit>
<trans-unit id="FailedToDetermineUserHomeDirectory">
<source>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</source>
<target state="new">The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -71,6 +71,11 @@ Para confiar no certificado (apenas Windows e macOS), primeiramente instale a fe
Para saber mais sobre a configuração de HTTPS, acesse https://go.microsoft.com/fwlink/?linkid=848054.</target>
<note />
</trans-unit>
<trans-unit id="FailedToDetermineUserHomeDirectory">
<source>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</source>
<target state="new">The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -71,6 +71,11 @@ For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?l
Дополнительные сведения о настройке HTTPS: https://go.microsoft.com/fwlink/?linkid=848054.</target>
<note />
</trans-unit>
<trans-unit id="FailedToDetermineUserHomeDirectory">
<source>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</source>
<target state="new">The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -71,6 +71,11 @@ Sertifikaya güvenmek için (yalnızca Windows ve macOS) önce 'dotnet tool inst
HTTPS yapılandırması hakkında daha fazla bilgi için bkz. https://go.microsoft.com/fwlink/?linkid=848054.</target>
<note />
</trans-unit>
<trans-unit id="FailedToDetermineUserHomeDirectory">
<source>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</source>
<target state="new">The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -71,6 +71,11 @@ For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?l
有关配置 HTTPS 的详细信息,请参阅 https://go.microsoft.com/fwlink/?linkid=848054。</target>
<note />
</trans-unit>
<trans-unit id="FailedToDetermineUserHomeDirectory">
<source>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</source>
<target state="new">The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -71,6 +71,11 @@ For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?l
如需如何設定 HTTPS 的詳細資訊,請參閱 https://go.microsoft.com/fwlink/?linkid=848054。</target>
<note />
</trans-unit>
<trans-unit id="FailedToDetermineUserHomeDirectory">
<source>The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</source>
<target state="new">The user's home directory could not be determined. Set the '{0}' environment variable to specify the directory to use.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>

View file

@ -88,15 +88,14 @@ namespace Microsoft.DotNet.Cli
var success = true;
var command = string.Empty;
var lastArg = 0;
var cliFallbackFolderPathCalculator = new CliFolderPathCalculator();
TopLevelCommandParserResult topLevelCommandParserResult = TopLevelCommandParserResult.Empty;
using (INuGetCacheSentinel nugetCacheSentinel = new NuGetCacheSentinel(cliFallbackFolderPathCalculator))
using (INuGetCacheSentinel nugetCacheSentinel = new NuGetCacheSentinel())
using (IFirstTimeUseNoticeSentinel disposableFirstTimeUseNoticeSentinel =
new FirstTimeUseNoticeSentinel(cliFallbackFolderPathCalculator))
new FirstTimeUseNoticeSentinel())
{
IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel = disposableFirstTimeUseNoticeSentinel;
IAspNetCertificateSentinel aspNetCertificateSentinel = new AspNetCertificateSentinel(cliFallbackFolderPathCalculator);
IAspNetCertificateSentinel aspNetCertificateSentinel = new AspNetCertificateSentinel();
IFileSentinel toolPathSentinel = new FileSentinel(
new FilePath(
Path.Combine(
@ -174,7 +173,6 @@ namespace Microsoft.DotNet.Cli
firstTimeUseNoticeSentinel,
aspNetCertificateSentinel,
toolPathSentinel,
cliFallbackFolderPathCalculator,
hasSuperUserAccess,
dotnetFirstRunConfiguration,
environmentProvider);
@ -241,7 +239,6 @@ namespace Microsoft.DotNet.Cli
IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel,
IAspNetCertificateSentinel aspNetCertificateSentinel,
IFileSentinel toolPathSentinel,
CliFolderPathCalculator cliFolderPathCalculator,
bool hasSuperUserAccess,
DotnetFirstRunConfiguration dotnetFirstRunConfiguration,
IEnvironmentProvider environmentProvider)
@ -249,15 +246,11 @@ namespace Microsoft.DotNet.Cli
using (PerfTrace.Current.CaptureTiming())
{
var nugetPackagesArchiver = new NuGetPackagesArchiver();
var environmentPath = EnvironmentPathFactory.CreateEnvironmentPath(
cliFolderPathCalculator,
hasSuperUserAccess,
environmentProvider);
var environmentPath = EnvironmentPathFactory.CreateEnvironmentPath(hasSuperUserAccess, environmentProvider);
var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true);
var nugetCachePrimer = new NuGetCachePrimer(
nugetPackagesArchiver,
nugetCacheSentinel,
cliFolderPathCalculator);
nugetCacheSentinel);
var aspnetCertificateGenerator = new AspNetCoreCertificateGenerator();
var dotnetConfigurer = new DotnetFirstTimeUseConfigurer(
nugetCachePrimer,
@ -268,7 +261,7 @@ namespace Microsoft.DotNet.Cli
toolPathSentinel,
dotnetFirstRunConfiguration,
Reporter.Output,
cliFolderPathCalculator.CliFallbackFolderPath,
CliFolderPathCalculator.CliFallbackFolderPath,
environmentPath);
dotnetConfigurer.Configure();

View file

@ -39,8 +39,8 @@ namespace Microsoft.DotNet.ShellShim
appHostSourcePath = Path.Combine(_appHostSourceDirectory, ApphostNameWithoutExtension);
}
var appHostDestinationFilePath = shimPath.Value;
var appBinaryFilePath = PathUtility.GetRelativePath(appHostDestinationFilePath, entryPoint.Value);
var appHostDestinationFilePath = Path.GetFullPath(shimPath.Value);
var appBinaryFilePath = Path.GetRelativePath(Path.GetDirectoryName(appHostDestinationFilePath), Path.GetFullPath(entryPoint.Value));
EmbedAppNameInHost.EmbedAndReturnModifiedAppHostPath(
appHostSourceFilePath: appHostSourcePath,

View file

@ -14,15 +14,9 @@ namespace Microsoft.DotNet.ShellShim
internal static class EnvironmentPathFactory
{
public static IEnvironmentPath CreateEnvironmentPath(
CliFolderPathCalculator cliFolderPathCalculator = null,
bool hasSuperUserAccess = false,
IEnvironmentProvider environmentProvider = null)
{
if (cliFolderPathCalculator == null)
{
cliFolderPathCalculator = new CliFolderPathCalculator();
}
if (environmentProvider == null)
{
environmentProvider = new EnvironmentProvider();
@ -32,14 +26,14 @@ namespace Microsoft.DotNet.ShellShim
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
environmentPath = new WindowsEnvironmentPath(
cliFolderPathCalculator.ToolsShimPath,
CliFolderPathCalculator.ToolsShimPath,
Reporter.Output,
environmentProvider);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && hasSuperUserAccess)
{
environmentPath = new LinuxEnvironmentPath(
cliFolderPathCalculator.ToolsShimPathInUnix,
CliFolderPathCalculator.ToolsShimPathInUnix,
Reporter.Output,
environmentProvider,
new FileWrapper());
@ -47,7 +41,7 @@ namespace Microsoft.DotNet.ShellShim
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && hasSuperUserAccess)
{
environmentPath = new OSXEnvironmentPath(
executablePath: cliFolderPathCalculator.ToolsShimPathInUnix,
executablePath: CliFolderPathCalculator.ToolsShimPathInUnix,
reporter: Reporter.Output,
environmentProvider: environmentProvider,
fileSystem: new FileWrapper());
@ -57,10 +51,9 @@ namespace Microsoft.DotNet.ShellShim
}
public static IEnvironmentPathInstruction CreateEnvironmentPathInstruction(
CliFolderPathCalculator cliFolderPathCalculator = null,
IEnvironmentProvider environmentProvider = null)
{
return CreateEnvironmentPath(cliFolderPathCalculator, true, environmentProvider);
return CreateEnvironmentPath(true, environmentProvider);
}
}
}

View file

@ -15,8 +15,7 @@ namespace Microsoft.DotNet.ShellShim
private static DirectoryPath GetShimLocation()
{
var cliFolderPathCalculator = new CliFolderPathCalculator();
return new DirectoryPath(cliFolderPathCalculator.ToolsShimPath);
return new DirectoryPath(CliFolderPathCalculator.ToolsShimPath);
}
}
}

View file

@ -30,7 +30,7 @@ namespace Microsoft.DotNet.Cli.Telemetry
_hasher = hasher ?? Sha256Hasher.Hash;
_getMACAddress = getMACAddress ?? MacAddressGetter.GetMacAddress;
_dockerContainerDetector = dockerContainerDetector ?? new DockerContainerDetectorForTelemetry();
_userLevelCacheWriter = userLevelCacheWriter ?? new UserLevelCacheWriter(new CliFolderPathCalculator());
_userLevelCacheWriter = userLevelCacheWriter ?? new UserLevelCacheWriter();
}
private readonly IDockerContainerDetector _dockerContainerDetector;

View file

@ -34,8 +34,7 @@ namespace Microsoft.DotNet.ToolPackage
private static DirectoryPath GetPackageLocation()
{
var cliFolderPathCalculator = new CliFolderPathCalculator();
return new DirectoryPath(cliFolderPathCalculator.ToolsPackagePath);
return new DirectoryPath(CliFolderPathCalculator.ToolsPackagePath);
}
}
}

View file

@ -28,7 +28,7 @@ namespace Microsoft.DotNet.ToolPackage
_store = store ?? throw new ArgumentNullException(nameof(store));
_projectRestorer = projectRestorer ?? throw new ArgumentNullException(nameof(projectRestorer));
_tempProject = tempProject;
_offlineFeed = offlineFeed ?? new DirectoryPath(new CliFolderPathCalculator().CliFallbackFolderPath);
_offlineFeed = offlineFeed ?? new DirectoryPath(CliFolderPathCalculator.CliFallbackFolderPath);
}
public IToolPackage InstallPackage(PackageId packageId,

View file

@ -14,7 +14,7 @@ namespace Microsoft.DotNet.Tools.MSBuild
public sealed class MSBuildLogger : INodeLogger
{
private readonly IFirstTimeUseNoticeSentinel _sentinel =
new FirstTimeUseNoticeSentinel(new CliFolderPathCalculator());
new FirstTimeUseNoticeSentinel();
private readonly ITelemetry _telemetry;
private const string NewEventName = "msbuild";
private const string TargetFrameworkTelemetryEventName = "targetframeworkeval";

View file

@ -31,8 +31,7 @@ namespace Microsoft.DotNet.Tools.New
{
var sessionId =
Environment.GetEnvironmentVariable(MSBuildForwardingApp.TelemetrySessionIdEnvironmentVariableName);
var telemetry =
new Telemetry(new FirstTimeUseNoticeSentinel(new CliFolderPathCalculator()), sessionId);
var telemetry = new Telemetry(new FirstTimeUseNoticeSentinel(), sessionId);
var logger = new TelemetryLogger(null);
if (telemetry.Enabled)

View file

@ -60,8 +60,6 @@ namespace Microsoft.DotNet.Tools.Tool.Install
_verbosity = appliedCommand.SingleArgumentOrDefault("verbosity");
_toolPath = appliedCommand.SingleArgumentOrDefault("tool-path");
var cliFolderPathCalculator = new CliFolderPathCalculator();
_createToolPackageStoreAndInstaller = createToolPackageStoreAndInstaller ?? ToolPackageFactory.CreateToolPackageStoreAndInstaller;
_environmentPathInstruction = environmentPathInstruction

View file

@ -34,8 +34,6 @@ namespace Microsoft.DotNet.Tools.Tool.Uninstall
IReporter reporter = null)
: base(result)
{
var pathCalculator = new CliFolderPathCalculator();
_options = options ?? throw new ArgumentNullException(nameof(options));
_reporter = reporter ?? Reporter.Output;
_errorReporter = reporter ?? Reporter.Error;

View file

@ -26,7 +26,6 @@ namespace Microsoft.DotNet.Configurer.UnitTests
private Mock<INuGetPackagesArchiver> _nugetPackagesArchiverMock;
private Mock<INuGetCacheSentinel> _nugetCacheSentinel;
private CliFolderPathCalculator _cliFolderPathCalculator;
public GivenANuGetCachePrimer()
{
@ -40,12 +39,9 @@ namespace Microsoft.DotNet.Configurer.UnitTests
_nugetCacheSentinel = new Mock<INuGetCacheSentinel>();
_cliFolderPathCalculator = new CliFolderPathCalculator();
var nugetCachePrimer = new NuGetCachePrimer(
_nugetPackagesArchiverMock.Object,
_nugetCacheSentinel.Object,
_cliFolderPathCalculator,
_fileSystemMock.File);
nugetCachePrimer.PrimeCache();
@ -63,7 +59,6 @@ namespace Microsoft.DotNet.Configurer.UnitTests
var nugetCachePrimer = new NuGetCachePrimer(
nugetPackagesArchiverMock.Object,
_nugetCacheSentinel.Object,
_cliFolderPathCalculator,
fileSystemMock.File);
nugetCachePrimer.PrimeCache();
@ -75,7 +70,7 @@ namespace Microsoft.DotNet.Configurer.UnitTests
public void It_extracts_the_archive_to_the_fallback_folder()
{
_nugetPackagesArchiverMock.Verify(n =>
n.ExtractArchive(_cliFolderPathCalculator.CliFallbackFolderPath),
n.ExtractArchive(CliFolderPathCalculator.CliFallbackFolderPath),
Times.Exactly(1));
}
@ -95,7 +90,6 @@ namespace Microsoft.DotNet.Configurer.UnitTests
var nugetCachePrimer = new NuGetCachePrimer(
nugetPackagesArchiveMock.Object,
nugetCacheSentinel.Object,
_cliFolderPathCalculator,
_fileSystemMock.File);
Action action = () => nugetCachePrimer.PrimeCache();

View file

@ -15,9 +15,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
public void It_does_not_return_same_path_for_tools_package_and_tool_shim()
{
// shim name will conflict with the folder that is PackageId, if commandName and packageId are the same.
var cliFolderPathCalculator = new CliFolderPathCalculator();
cliFolderPathCalculator.ToolsPackagePath.Should().NotBe(cliFolderPathCalculator.ToolsShimPath);
cliFolderPathCalculator.ToolsPackagePath.Should().NotBe(cliFolderPathCalculator.ToolsShimPathInUnix.Path);
CliFolderPathCalculator.ToolsPackagePath.Should().NotBe(CliFolderPathCalculator.ToolsShimPath);
CliFolderPathCalculator.ToolsPackagePath.Should().NotBe(CliFolderPathCalculator.ToolsShimPathInUnix.Path);
}
}
}

View file

@ -45,6 +45,27 @@ namespace Microsoft.DotNet.ShellShim.Tests
stdOut.Should().Contain("Hello World");
}
// Reproduce https://github.com/dotnet/cli/issues/9319
[Fact]
public void GivenAnExecutableAndRelativePathToShimPathItCanGenerateShimFile()
{
var outputDll = MakeHelloWorldExecutableDll("GivenAnExecutableAndRelativePath");
// To reproduce the bug, dll need to be nested under the shim
var parentPathAsShimPath = outputDll.GetDirectoryPath().GetParentPath().GetParentPath().Value;
var relativePathToShim = Path.GetRelativePath(
Directory.GetCurrentDirectory(),
parentPathAsShimPath);
ShellShimRepository shellShimRepository = ConfigBasicTestDependecyShellShimRepository(relativePathToShim);
var shellCommandName = nameof(ShellShimRepositoryTests) + Path.GetRandomFileName();
shellShimRepository.CreateShim(outputDll, shellCommandName);
var stdOut = ExecuteInShell(shellCommandName, relativePathToShim);
stdOut.Should().Contain("Hello World");
}
private static ShellShimRepository ConfigBasicTestDependecyShellShimRepository(string pathToShim)
{
string stage2AppHostTemplateDirectory = GetAppHostTemplateFromStage2();
@ -473,13 +494,19 @@ namespace Microsoft.DotNet.ShellShim.Tests
return stage2AppHostTemplateDirectory;
}
private static FilePath MakeHelloWorldExecutableDll()
private static FilePath MakeHelloWorldExecutableDll(string instanceName = null)
{
const string testAppName = "TestAppSimple";
const string emptySpaceToTestSpaceInPath = " ";
const string directoryNamePostFix = "Test";
if (instanceName == null)
{
instanceName = testAppName + emptySpaceToTestSpaceInPath + directoryNamePostFix;
}
TestAssetInstance testInstance = TestAssets.Get(testAppName)
.CreateInstance(testAppName + emptySpaceToTestSpaceInPath + directoryNamePostFix)
.CreateInstance(instanceName)
.UseCurrentRuntimeFrameworkVersion()
.WithRestoreFiles()
.WithBuildFiles();

View file

@ -5,9 +5,12 @@ using System;
using System.IO;
using FluentAssertions;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Configurer;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
using LocalizableStrings = Microsoft.DotNet.Cli.Utils.LocalizableStrings;
namespace Microsoft.DotNet.Tests
{
public class GivenThatDotNetRunsCommands : TestBase
@ -32,5 +35,19 @@ namespace Microsoft.DotNet.Tests
.Should().Fail()
.And.HaveStdErrContaining(string.Format(LocalizableStrings.NoExecutableFoundMatchingCommand, "dotnet-crash"));
}
[Theory]
[InlineData("")]
[InlineData(null)]
public void GivenAMissingHomeVariableItPrintsErrorMessage(string value)
{
new TestCommand("dotnet")
.WithEnvironmentVariable(CliFolderPathCalculator.PlatformHomeVariableName, value)
.ExecuteWithCapturedOutput("--help")
.Should()
.Fail()
.And
.HaveStdErrContaining(CliFolderPathCalculator.DotnetHomeVariableName);
}
}
}

View file

@ -59,20 +59,6 @@ namespace Microsoft.DotNet.Tests
.Should().BeFalse("Because multicore JIT is disabled");
}
[Fact]
public void WhenTheProfileRootIsUndefinedThenDotnetDoesNotCrash()
{
var testDirectory = TestAssets.CreateTestDirectory();
var testStartTime = GetTruncatedDateTime();
var optimizationProfileFilePath = GetOptimizationProfileFilePath(testDirectory.FullName);
new TestCommand("dotnet")
.WithUserProfileRoot("")
.ExecuteWithCapturedOutput("--help")
.Should().Pass();
}
[Fact]
public void WhenCliRepoBuildsThenDotnetWritesOptimizationDataToTheDefaultProfileRoot()
{

View file

@ -213,7 +213,7 @@ namespace Microsoft.DotNet.Tests
File.Exists(profiled).Should().BeTrue();
File.ReadAllText(profiled).Should().Be(
$"export PATH=\"$PATH:{new CliFolderPathCalculator().ToolsShimPathInUnix.PathWithDollar}\"");
$"export PATH=\"$PATH:{CliFolderPathCalculator.ToolsShimPathInUnix.PathWithDollar}\"");
}
[MacOsOnlyFact]
@ -234,7 +234,7 @@ namespace Microsoft.DotNet.Tests
command.ExecuteWithCapturedOutput("internal-reportinstallsuccess test").Should().Pass();
File.Exists(pathsd).Should().BeTrue();
File.ReadAllText(pathsd).Should().Be(new CliFolderPathCalculator().ToolsShimPathInUnix.PathWithTilde);
File.ReadAllText(pathsd).Should().Be(CliFolderPathCalculator.ToolsShimPathInUnix.PathWithTilde);
}
[Fact]