//public PackageInfo Install(string packageId, string version, string location, string applicationFolder)
		//{
		//	// instantiates the appropriate package repository
		//	IPackageRepository packageRepository = PackageRepositoryFactory.Default.CreateRepository(location);

		//	// gets an IPackage instance from the repository
		//	var packageVersion = String.IsNullOrEmpty(version) ? null : new SemanticVersion(version);
		//	var package = packageRepository.FindPackage(packageId, packageVersion);
		//	if (package == null)
		//	{
		//		throw new ArgumentException("The specified package could not be found, id:{0} version:{1}".FormatCurrent(packageId, version.IsEmpty() ? "No version" : version));
		//	}

		//	return InstallPackage(package, packageRepository, location, applicationFolder);
		//}

		public PackageInfo Install(Stream packageStream, string location, string applicationPath)
		{
			Guard.ArgumentNotNull(() => packageStream);
			
			IPackage package = null;
			try
			{
				package = new ZipPackage(packageStream);

			}
			catch (Exception ex)
			{
				throw new SmartException(T("Admin.Packaging.StreamError"), ex);
			}
			
			// instantiates the appropriate package repository
			var packageRepository = new NullSourceRepository();
			return InstallPackage(package, packageRepository, location, applicationPath);
		}
Exemplo n.º 2
0
        //public PackageInfo Install(string packageId, string version, string location, string applicationFolder)
        //{
        //	// instantiates the appropriate package repository
        //	IPackageRepository packageRepository = PackageRepositoryFactory.Default.CreateRepository(location);

        //	// gets an IPackage instance from the repository
        //	var packageVersion = String.IsNullOrEmpty(version) ? null : new SemanticVersion(version);
        //	var package = packageRepository.FindPackage(packageId, packageVersion);
        //	if (package == null)
        //	{
        //		throw new ArgumentException("The specified package could not be found, id:{0} version:{1}".FormatCurrent(packageId, version.IsEmpty() ? "No version" : version));
        //	}

        //	return InstallPackage(package, packageRepository, location, applicationFolder);
        //}

        public PackageInfo Install(Stream packageStream, string location, string applicationPath)
        {
            Guard.NotNull(packageStream, nameof(packageStream));

            IPackage package;

            try
            {
                package = new ZipPackage(packageStream);
            }
            catch (Exception ex)
            {
                throw new SmartException(T("Admin.Packaging.StreamError"), ex);
            }

            // instantiates the appropriate package repository
            var packageRepository = new NullSourceRepository();

            return(InstallPackage(package, packageRepository, location, applicationPath));
        }
Exemplo n.º 3
0
        private PackageInfo ExecuteUpdate(IPackage package)
        {
            var appPath = CommonHelper.MapPath("~/");

            var logger = new NugetLogger(_logger);

            var project = new FileBasedProjectSystem(appPath)
            {
                Logger = logger
            };

            var nullRepository = new NullSourceRepository();

            var projectManager = new ProjectManager(
                nullRepository,
                new DefaultPackagePathResolver(appPath),
                project,
                nullRepository
                )
            {
                Logger = logger
            };

            // Perform the update
            projectManager.AddPackageReference(package, true, false);

            var info = new PackageInfo
            {
                Id      = package.Id,
                Name    = package.Title ?? package.Id,
                Version = package.Version.ToString(),
                Type    = "App",
                Path    = appPath
            };

            _logger.Information("Update '{0}' successfully executed.".FormatInvariant(info.Name));

            return(info);
        }
Exemplo n.º 4
0
        private PackageInfo ExecuteUpdate(IPackage package)
        {
            var appPath = CommonHelper.MapPath("~/");

            var logger = new NugetLogger(_logger);

            var project = new FileBasedProjectSystem(appPath) { Logger = logger };

            var nullRepository = new NullSourceRepository();

            var projectManager = new ProjectManager(
                nullRepository,
                new DefaultPackagePathResolver(appPath),
                project,
                nullRepository
                ) { Logger = logger };

            // Perform the update
            projectManager.AddPackageReference(package, true, false);

            var info = new PackageInfo
            {
                Id = package.Id,
                Name = package.Title ?? package.Id,
                Version = package.Version.ToString(),
                Type = "App",
                Path = appPath
            };

            _logger.Information("Update '{0}' successfully executed.".FormatInvariant(info.Name));

            return info;
        }