Exemplo n.º 1
0
        /// <summary>
        /// Gets the dot net version that the application runs on.
        /// </summary>
        /// <param name="appInfo">The application info structure.</param>
        /// <returns>The .net version supported by the application</returns>
        private DotNetVersion GetAppVersion(ApplicationInfo appInfo)
        {
            this.startupLogger.Info(Strings.DeterminingApplication);

            string[] allAssemblies = Directory.GetFiles(appInfo.Path, "*.dll", SearchOption.AllDirectories);

            DotNetVersion version = DotNetVersion.Two;

            if (allAssemblies.Length == 0)
            {
                version = NetFrameworkVersion.GetFrameworkFromConfig(Path.Combine(appInfo.Path, "web.config"));
            }

            foreach (string assembly in allAssemblies)
            {
                if (NetFrameworkVersion.GetVersion(assembly) == DotNetVersion.Four)
                {
                    version = DotNetVersion.Four;
                    break;
                }
            }

            this.startupLogger.Info(Strings.DetectedNet + GetAspDotNetVersion(version));

            return(version);
        }