public Task Install(ApplicationWorkspace workspace)
        {
            var repo           = workspace.GetRemoteRepository();
            var localRepo      = workspace.GetLocalRepository();
            var fileSystem     = workspace.GetFileSystem();
            var packageManager = new PackageManager(repo, new DefaultPackagePathResolver(fileSystem), fileSystem, localRepo);

            packageManager.Logger            = Logger;
            packageManager.PackageInstalled += (s, args) => InstallIntoWorkspace(workspace, args.Package);
            packageManager.InstallPackage(_settings.PackageId, null, false, true);

            return(Task.FromResult <object>(null));
        }
Esempio n. 2
0
		static void Main(string[] args)
		{
			var rootDirectory = Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
			var configuration = ReadConfiguration(rootDirectory);

			var logger = new ConsoleLogger();
			var installers = configuration.Projects.Values.Select(s => new ApplicationInstaller(s) { Logger = logger });
			var workspace = new ApplicationWorkspace(configuration.Workspace)
			{
				Logger = logger
			};
			InstallAll(workspace, installers.ToArray()).Wait();

			Console.WriteLine("Installation completed");
		}
        private void InstallIntoWorkspace(ApplicationWorkspace workspace, IPackage package)
        {
            var projectDirectory = workspace.GetProjectDirectory(_settings);

            if (!Directory.Exists(projectDirectory))
            {
                Directory.CreateDirectory(projectDirectory);
            }

            foreach (var libFile in FilterCompatibles(package.AssemblyReferences))
            {
                using (var file = new FileStream(Path.Combine(projectDirectory, libFile.Name), FileMode.Create, FileAccess.ReadWrite))
                {
                    libFile.GetStream().CopyTo(file);
                }
            }

            if (package.Id == _settings.PackageId) // only install content from base package
            {
                foreach (var contentFile in FilterCompatibles(package.GetContentFiles()))
                {
                    var targetPath = Path.Combine(projectDirectory, contentFile.EffectivePath);
                    if (File.Exists(targetPath))
                    {
                        if (_settings.PreservedFiles.Contains(contentFile.EffectivePath))
                        {
                            continue;
                        }
                    }

                    var targetDirectory = Path.GetDirectoryName(targetPath);
                    if (!Directory.Exists(targetDirectory))
                    {
                        Directory.CreateDirectory(targetDirectory);
                    }

                    using (var file = new FileStream(targetPath, FileMode.Create, FileAccess.ReadWrite))
                    {
                        contentFile.GetStream().CopyTo(file);
                    }
                }
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var rootDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var configuration = ReadConfiguration(rootDirectory);

            var logger     = new ConsoleLogger();
            var installers = configuration.Projects.Values.Select(s => new ApplicationInstaller(s)
            {
                Logger = logger
            });
            var workspace = new ApplicationWorkspace(configuration.Workspace)
            {
                Logger = logger
            };

            InstallAll(workspace, installers.ToArray()).Wait();

            Console.WriteLine("Installation completed");
        }
Esempio n. 5
0
		private static async Task InstallAll(ApplicationWorkspace workspace, params ApplicationInstaller[] installers)
		{
			await Task.WhenAll(installers.Select(i => i.Install(workspace))).ConfigureAwait(false);
		}
Esempio n. 6
0
		private static void ClearRepository(ApplicationWorkspace workspace)
		{
			workspace.ClearLocalRepository();
		}
Esempio n. 7
0
		private static void ClearProjects(ApplicationWorkspace workspace)
		{
			workspace.ClearProjects();
		}
Esempio n. 8
0
 private static async Task InstallAll(ApplicationWorkspace workspace, params ApplicationInstaller[] installers)
 {
     await Task.WhenAll(installers.Select(i => i.Install(workspace))).ConfigureAwait(false);
 }
Esempio n. 9
0
 private static void ClearRepository(ApplicationWorkspace workspace)
 {
     workspace.ClearLocalRepository();
 }
Esempio n. 10
0
 private static void ClearProjects(ApplicationWorkspace workspace)
 {
     workspace.ClearProjects();
 }