Пример #1
0
        public static void Install()
        {
            try
            {
                var dependanciesFolder = FileSystem.Current.GetDirectory(Resources.DependanciesDir);
                if (!dependanciesFolder.Exists) return;
                var deps = new FrameworkDependancies(Resources.DependanciesFile);

                foreach (KeyValuePair<string, string> dep in deps.Dependencies)
                {
                    if (dep.Key.Contains(".."))
                    {
                        Logger.Current.Write(LogInfoLevel.Error, "Cannot install dependancies outside of the framework dependancy folder ("+dep.Key+")");
                    }
                    else
                    {
                        Logger.Current.Write(LogInfoLevel.Info, "Installing dependancy " + dep.Key + " " + dep.Value + "...");
                        var result = ProcessManager.Current.WaitForProcess(Path.Combine(dependanciesFolder.FullName, dep.Key), dep.Value);
                        Logger.Current.Write(result == 0 ? LogInfoLevel.Info : LogInfoLevel.Error, "Dependancy " + dep.Key + " completed with code " + result);
                    }
                }

                dependanciesFolder.DeleteWithTimeout();
            }
            catch (Exception ex)
            {
                Logger.Current.Write(ex, "Unable to install dependancies");
            }
        }
Пример #2
0
        public void LoadDependanciesFile()
        {
            const string json = @"{
            ""dependancies"":[
            { ""command"": ""vc2013redist_x86.exe"", ""arguments"":""/q"" }
            ]
            }";

            MockDirectory depsDirectory = ((MockDirectory)MockFileSystem.GetDirectory(EnvironmentSettings.Current.AppDirectory));
            depsDirectory = depsDirectory.AddDirectory("dependancies");
            depsDirectory.AddFile("dependancies.json", json);
            var deps = new FrameworkDependancies(Resources.DependanciesFile);
            Assert.AreEqual(true, deps.IsValid);
            Assert.AreEqual(0, deps.ErrorCollection.Count);
            Assert.AreEqual(1, deps.Dependencies.Count);
            Assert.AreEqual("/q", deps.Dependencies["vc2013redist_x86.exe"]);
        }