Beispiel #1
0
        public static IEnvironmentPath CreateEnvironmentPath(
            bool isDotnetBeingInvokedFromNativeInstaller = false,
            IEnvironmentProvider environmentProvider     = null)
        {
            if (environmentProvider == null)
            {
                environmentProvider = new EnvironmentProvider();
            }

            IEnvironmentPath environmentPath = new DoNothingEnvironmentPath();

            if (OperatingSystem.IsWindows())
            {
                if (isDotnetBeingInvokedFromNativeInstaller)
                {
                    // On Windows MSI will in charge of appending ToolShimPath
                    environmentPath = new DoNothingEnvironmentPath();
                }
                else
                {
                    environmentPath = new WindowsEnvironmentPath(
                        CliFolderPathCalculator.ToolsShimPath,
                        CliFolderPathCalculator.WindowsNonExpandedToolsShimPath,
                        environmentProvider,
                        new WindowsRegistryEnvironmentPathEditor(),
                        Reporter.Output);
                }
            }
            else if (OperatingSystem.IsLinux() && isDotnetBeingInvokedFromNativeInstaller)
            {
                environmentPath = new LinuxEnvironmentPath(
                    CliFolderPathCalculator.ToolsShimPathInUnix,
                    Reporter.Output,
                    environmentProvider,
                    new FileWrapper());
            }
            else if (OperatingSystem.IsMacOS() && isDotnetBeingInvokedFromNativeInstaller)
            {
                environmentPath = new OsxBashEnvironmentPath(
                    executablePath: CliFolderPathCalculator.ToolsShimPathInUnix,
                    reporter: Reporter.Output,
                    environmentProvider: environmentProvider,
                    fileSystem: new FileWrapper());
            }

            return(environmentPath);
        }
Beispiel #2
0
        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();
            }

            IEnvironmentPath environmentPath = new DoNothingEnvironmentPath();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                environmentPath = new WindowsEnvironmentPath(
                    cliFolderPathCalculator.ToolsShimPath,
                    Reporter.Output,
                    environmentProvider);
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && hasSuperUserAccess)
            {
                environmentPath = new LinuxEnvironmentPath(
                    cliFolderPathCalculator.ToolsShimPathInUnix,
                    Reporter.Output,
                    environmentProvider,
                    new FileWrapper());
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && hasSuperUserAccess)
            {
                environmentPath = new OSXEnvironmentPath(
                    executablePath: cliFolderPathCalculator.ToolsShimPathInUnix,
                    reporter: Reporter.Output,
                    environmentProvider: environmentProvider,
                    fileSystem: new FileWrapper());
            }

            return(environmentPath);
        }