コード例 #1
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            worker.ReportProgress(2);
            string unzipPath = InstallPath.Replace('\\', '/');

            try
            {
                if (!LocalInstallTesting.GetDotNetRelease())
                {
                    //LocalInstallTesting.CopyFile(unzipPath, @"Environmental/NDP452-KB2901907-x86-x64-AllOS-ENU.exe");
                    //Process.Start(unzipPath + @"/Environmental/NDP452-KB2901907-x86-x64-AllOS-ENU.exe").WaitForExit();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("检测并安装.Net版本错误:" + ex.Message);
            }

            worker.ReportProgress(10);
            try
            {
                if (!LocalInstallTesting.IsInstallVC1() && !LocalInstallTesting.IsInstallVC2())
                {
                    if (LocalInstallTesting.Is64Bit())
                    {
                        //LocalInstallTesting.CopyFile(unzipPath, @"Environmental/vc_redist.x64.exe");
                        //Process.Start(unzipPath + @"/Environmental/vc_redist.x64.exe").WaitForExit();
                    }
                    else
                    {
                        //LocalInstallTesting.CopyFile(unzipPath, @"Environmental/vc_redist.x86.exe");
                        //Process.Start(unzipPath + @"/Environmental/vc_redist.x86.exe").WaitForExit();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("检测并安装VC运行环境错误:" + ex.Message);
            }

            worker.ReportProgress(15);
            Process[] ExeList = Process.GetProcessesByName("MusicTeachingWindow");
            for (int i = 0; i < ExeList.Length; i++)
            {
                ExeList[i].Kill();
            }
            worker.ReportProgress(20);

            LocalInstallTesting.CopyAllFile(unzipPath, new Action <int>((p) =>
            {
                worker.ReportProgress(p);
            }));
            try
            {
                LocalInstallTesting.CreateShortcut(InstallPath);
                LocalInstallTesting.CreateProgramsShortcut(InstallPath, "音乐教学云平台");
                LocalInstallTesting.CreateProgramsUninstallShortcut(InstallPath, "音乐教学云平台");
            }
            catch (Exception ex)
            {
                MessageBox.Show("生成快捷方式错误:" + ex.Message);
            }
            worker.ReportProgress(95);
            try
            {
                LocalInstallTesting.AddRegedit(InstallPath);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            worker.ReportProgress(100);
            CurrentSetupState = SetupState.SetupComplete;
        }
コード例 #2
0
ファイル: NugetStore.cs プロジェクト: vol16bit/xenko
        /// <summary>
        /// Initialize NugetStore using <paramref name="rootDirectory"/> as location of the local copies,
        /// and a configuration file <paramref name="configFile"/> as well as an override configuration
        /// file <paramref name="overrideFile"/> where all settings of <paramref name="overrideFile"/> also
        /// presents in <paramref name="configFile"/> take precedence.
        /// </summary>
        /// <param name="rootDirectory">The location of the Nuget store.</param>
        /// <param name="configFile">The configuration file name for the Nuget store, or <see cref="DefaultConfig"/> if not specified.</param>
        /// <param name="overrideFile">The override configuration file name for the Nuget store, or <see cref="OverrideConfig"/> if not specified.</param>
        public NugetStore(string rootDirectory, string configFile = DefaultConfig, string overrideFile = OverrideConfig)
        {
            if (rootDirectory == null)
            {
                throw new ArgumentNullException(nameof(rootDirectory));
            }
            if (configFile == null)
            {
                throw new ArgumentNullException(nameof(configFile));
            }
            if (overrideFile == null)
            {
                throw new ArgumentNullException(nameof(overrideFile));
            }

            // First try the override file with custom settings
            var configFileName = overrideFile;
            var configFilePath = Path.Combine(rootDirectory, configFileName);

            if (!File.Exists(configFilePath))
            {
                // Override file does not exist, fallback to default config file
                configFileName = configFile;
                configFilePath = Path.Combine(rootDirectory, configFileName);

                if (!File.Exists(configFilePath))
                {
                    throw new ArgumentException($"Invalid installation. Configuration file [{configFile}] not found", nameof(configFile));
                }
            }

            var rootFileSystem = new PhysicalFileSystem(rootDirectory);

            RootDirectory = rootFileSystem.Root;
            settings      = new Settings(rootFileSystem, configFileName, false);

            InstallPath = settings.GetValue(ConfigurationConstants.Config, RepositoryPathKey, true);
            if (!string.IsNullOrEmpty(InstallPath))
            {
                InstallPath = InstallPath.Replace('/', Path.DirectorySeparatorChar);
            }

            var mainPackageList = settings.GetValue(ConfigurationConstants.Config, MainPackagesKey, false);

            if (string.IsNullOrWhiteSpace(mainPackageList))
            {
                throw new InvalidOperationException($"Invalid configuration. Expecting [{MainPackagesKey}] in config");
            }
            MainPackageIds = mainPackageList.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            VsixPluginId = settings.GetValue(ConfigurationConstants.Config, VsixPluginKey, false);
            if (string.IsNullOrWhiteSpace(VsixPluginId))
            {
                throw new InvalidOperationException($"Invalid configuration. Expecting [{VsixPluginKey}] in config");
            }

            RepositoryPath = settings.GetValue(ConfigurationConstants.Config, RepositoryPathKey, false);
            if (string.IsNullOrWhiteSpace(RepositoryPath))
            {
                RepositoryPath = DefaultGamePackagesDirectory;
            }

            // Setup NugetCachePath in the cache folder
            CacheDirectory = Path.Combine(rootDirectory, "Cache");
            Environment.SetEnvironmentVariable("NuGetCachePath", CacheDirectory);

            var packagesFileSystem = new PhysicalFileSystem(InstallPath);

            PathResolver = new PackagePathResolver(packagesFileSystem);

            var packageSourceProvider = new PackageSourceProvider(settings);

            SourceRepository = packageSourceProvider.CreateAggregateRepository(new PackageRepositoryFactory(), true);

            var localRepo = new SharedPackageRepository(PathResolver, packagesFileSystem, rootFileSystem);

            manager = new NuGet.PackageManager(SourceRepository, PathResolver, packagesFileSystem, localRepo);
            manager.PackageInstalling   += OnPackageInstalling;
            manager.PackageInstalled    += OnPackageInstalled;
            manager.PackageUninstalling += OnPackageUninstalling;
            manager.PackageUninstalled  += OnPackageUninstalled;
        }