Пример #1
0
        internal static string GetLocalFileVersion(string target, FileSystemProxy fileSystemProxy)
        {
            if (!File.Exists(target))
            {
                ConsoleImpl.WriteTrace("File doesn't exists, no version information: {0}", target);
                return("");
            }

            try
            {
                var bytes = new MemoryStream();
                using (var stream = fileSystemProxy.OpenRead(target))
                {
                    stream.CopyTo(bytes);
                }
                var attr = Assembly.Load(bytes.ToArray()).GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false).Cast <AssemblyInformationalVersionAttribute>().FirstOrDefault();
                if (attr == null)
                {
                    ConsoleImpl.WriteWarning("No assembly version found in {0}", target);
                    return("");
                }

                return(attr.InformationalVersion);
            }
            catch (Exception exception)
            {
                ConsoleImpl.WriteWarning("Unable to get file version from {0}: {1}", target, exception);
                return("");
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            executionWatch.Start();
            Console.CancelKeyPress += CancelKeyPressed;

            var fileProxy = new FileSystemProxy();
            var optionsBeforeDependenciesFile = ArgumentParser.ParseArgumentsAndConfigurations(args, ConfigurationManager.AppSettings,
                                                                                               Environment.GetEnvironmentVariables(), fileProxy, Enumerable.Empty <string>());

            ConsoleImpl.Verbosity = optionsBeforeDependenciesFile.Verbosity;

            var argumentsFromDependenciesFile =
                WindowsProcessArguments.Parse(
                    PaketDependencies.GetBootstrapperArgsForFolder(fileProxy));
            var options = ArgumentParser.ParseArgumentsAndConfigurations(args, ConfigurationManager.AppSettings,
                                                                         Environment.GetEnvironmentVariables(), fileProxy, argumentsFromDependenciesFile);

            if (options.ShowHelp)
            {
                ConsoleImpl.WriteAlways(BootstrapperHelper.HelpText);
                return;
            }

            ConsoleImpl.Verbosity = options.Verbosity;
            if (options.UnprocessedCommandArgs.Any())
            {
                ConsoleImpl.WriteWarning("Ignoring the following unknown argument(s): {0}", String.Join(", ", options.UnprocessedCommandArgs));
            }

            var effectiveStrategy = GetEffectiveDownloadStrategy(options.DownloadArguments, options.PreferNuget, options.ForceNuget);

            ConsoleImpl.WriteTrace("Using strategy: " + effectiveStrategy.Name);

            StartPaketBootstrapping(effectiveStrategy, options.DownloadArguments, fileProxy, () => OnSuccessfulDownload(options));
        }
Пример #3
0
        static IEnumerable <string> SetBootstrapperArgument(string program, IEnumerable <string> arguments)
        {
            var setBootstrapperArg = true;

            try
            {
                var versionInfo = FileVersionInfo.GetVersionInfo(program);
                var version     = new Version(versionInfo.FileVersion);
                setBootstrapperArg = version >= VersionWithFromBootstrapper;
            }
            catch (Exception ex)
            {
                ConsoleImpl.WriteWarning("Could not detect bootstrapper version. Message: {0}", ex.Message);
            }

            return
                (setBootstrapperArg
                    ? new[] { "--from-bootstrapper" }.Concat(arguments)
                    : arguments);
        }
Пример #4
0
        static void Main(string[] args)
        {
            AppContext.SetSwitch("Switch.System.Net.DontEnableSystemDefaultTlsVersions", false);
            executionWatch.Start();
            Console.CancelKeyPress += CancelKeyPressed;

            IProxyProvider proxyProvider = new DefaultProxyProvider();

            var appSettings = ConfigurationManager.AppSettings;

            var appConfigInWorkingDir = Path.Combine(Environment.CurrentDirectory, "paket.bootstrapper.exe.config");

            if (File.Exists(appConfigInWorkingDir))
            {
                var exeInWorkingDir = Path.Combine(Environment.CurrentDirectory, "paket.bootstrapper.exe");
                var exeConf         = ConfigurationManager.OpenExeConfiguration(null);
                if (exeConf != null)
                {
                    var nv = new System.Collections.Specialized.NameValueCollection();
                    foreach (KeyValueConfigurationElement kv in exeConf.AppSettings.Settings)
                    {
                        nv.Add(kv.Key, kv.Value);
                    }
                    appSettings = nv;
                }
            }

            var optionsBeforeDependenciesFile = ArgumentParser.ParseArgumentsAndConfigurations(args, appSettings,
                                                                                               Environment.GetEnvironmentVariables(), proxyProvider.FileSystemProxy, Enumerable.Empty <string>());

            ConsoleImpl.Verbosity = optionsBeforeDependenciesFile.Verbosity;

            var argumentsFromDependenciesFile =
                WindowsProcessArguments.Parse(
                    PaketDependencies.GetBootstrapperArgsForFolder(proxyProvider.FileSystemProxy));
            var options = ArgumentParser.ParseArgumentsAndConfigurations(args, appSettings,
                                                                         Environment.GetEnvironmentVariables(), proxyProvider.FileSystemProxy, argumentsFromDependenciesFile);

            if (options.ShowHelp)
            {
                ConsoleImpl.WriteAlways(BootstrapperHelper.HelpText);
                return;
            }

            ConsoleImpl.Verbosity = options.Verbosity;
            if (options.UnprocessedCommandArgs.Any())
            {
                ConsoleImpl.WriteWarning("Ignoring the following unknown argument(s): {0}", String.Join(", ", options.UnprocessedCommandArgs));
            }

#if PAKET_BOOTSTRAP_NO_CACHE
            ConsoleImpl.WriteTrace("Force ignore cache, because not implemented.");
            options.DownloadArguments.IgnoreCache = true;
#endif

            var effectiveStrategy = GetEffectiveDownloadStrategy(options.DownloadArguments, options.PreferNuget, options.ForceNuget, proxyProvider);
            ConsoleImpl.WriteTrace("Using strategy: " + effectiveStrategy.Name);
            ConsoleImpl.WriteTrace("Using install kind: " + (options.DownloadArguments.AsTool? "tool": "exe"));

            StartPaketBootstrapping(effectiveStrategy, options.DownloadArguments, proxyProvider.FileSystemProxy, () => OnSuccessfulDownload(options));
        }