internal PackageInstaller(IFileSystem fileSystem, AssemblyLoader assemblyLoader) { _fileSystem = fileSystem; _assemblyLoader = assemblyLoader; _currentFramework = GetCurrentFramework(); _settings = Settings.LoadDefaultSettings(fileSystem.RootPath.FullPath, null, new MachineWideSettings()); _sourceRepositories = new SourceRepositoryProvider(_settings); }
internal PackageInstaller(IFileSystem fileSystem, AssemblyLoader assemblyLoader) { _fileSystem = fileSystem; _assemblyLoader = assemblyLoader; _currentFramework = GetCurrentFramework(); _settings = Settings.LoadDefaultSettings(fileSystem.RootPath.FullPath, null, new XPlatMachineWideSetting()); SettingsUtility.SetConfigValue( _settings, ConfigurationConstants.SignatureValidationMode, nameof(SignatureValidationMode.Accept)); _sourceRepositories = new SourceRepositoryProvider(_settings); }
public void InstallPackages(DirectoryPath absolutePackagesPath, IFileSystem fileSystem, bool updatePackages) { PackageManager packageManager = new PackageManager(_packageRepository, absolutePackagesPath.FullPath); // Install the packages foreach (Package package in _packages) { IPackage installedPackage = package.InstallPackage(packageManager, updatePackages); if (installedPackage != null) { // Add the content path(s) to the input paths if there are content files // We need to use the directory name from an actual file to make sure we get the casing right foreach (string contentSegment in installedPackage.GetContentFiles() .Select(x => new DirectoryPath(x.Path).Segments[0]) .Distinct()) { string installPath = packageManager.PathResolver.GetInstallPath(installedPackage); fileSystem.InputPaths.Insert(0, new DirectoryPath(installPath).Combine(contentSegment)); } } } }
internal PackageInstaller(IFileSystem fileSystem, AssemblyLoader assemblyLoader) { _fileSystem = fileSystem; // Get the current framework string frameworkName = Assembly.GetExecutingAssembly().GetCustomAttributes(true) .OfType <System.Runtime.Versioning.TargetFrameworkAttribute>() .Select(x => x.FrameworkName) .FirstOrDefault(); CurrentFramework = frameworkName == null ? NuGetFramework.AnyFramework : NuGetFramework.ParseFrameworkName(frameworkName, new DefaultFrameworkNameProvider()); Settings = global::NuGet.Configuration.Settings.LoadDefaultSettings(_fileSystem.RootPath.FullPath, null, new MachineWideSettings()); IPackageSourceProvider packageSourceProvider = new PackageSourceProvider(Settings); SourceRepositoryProvider = new WyamSourceRepositoryProvider(packageSourceProvider); _nuGetProject = new WyamFolderNuGetProject(fileSystem, assemblyLoader, CurrentFramework, GetAbsolutePackagesPath().FullPath); PackageManager = new NuGetPackageManager(SourceRepositoryProvider, Settings, GetAbsolutePackagesPath().FullPath) { PackagesFolderNuGetProject = _nuGetProject }; }
public PackagesCollection(IFileSystem fileSystem) { _fileSystem = fileSystem; }
public void InstallPackages(string absolutePackagesPath, DirectoryPath contentPath, IFileSystem fileSystem, bool updatePackages) { // TODO: Use this code when ReadFiles (and other modules) support multiple input paths - make sure to test with clean (I.e., no packages) repo /* * PackageManager packageManager = new PackageManager(_packageRepository, absolutePackagesPath); * * // On package install... * packageManager.PackageInstalled += (sender, args) => * { * IDirectory packageContentDirectory = fileSystem.GetRootDirectory(contentPath.Combine(args.Package.Id)); * * // Copy all content files on install and add to input paths * bool firstFile = true; * foreach (IPackageFile packageFile in args.Package.GetContentFiles()) * { * if (firstFile) * { * // This package does have content files, so create the directory and add an input path * packageContentDirectory.Create(); * fileSystem.InputPaths.Insert(0, packageContentDirectory.Path); * firstFile = false; * } * * IFile file = packageContentDirectory.GetFile(packageFile.EffectivePath); * file.Directory.Create(); * using (Stream fileStream = file.Open(FileMode.Open, FileAccess.Write, FileShare.None)) * { * packageFile.GetStream().CopyTo(fileStream); * } * } * }; * * // On package uninstall... * packageManager.PackageUninstalling += (sender, args) => * { * IDirectory packageContentDirectory = fileSystem.GetRootDirectory(contentPath.Combine(args.Package.Id)); * packageContentDirectory.Delete(true); * }; * * // Install the packages * foreach (Package package in _packages) * { * package.InstallPackage(packageManager, updatePackages); * } */ // *********************************************************** // OLD CODE - remove when code above is ready PackageManager packageManager = new PackageManager(_packageRepository, absolutePackagesPath); packageManager.PackageInstalled += (sender, args) => { // Copy all content files on install foreach (IPackageFile packageFile in args.Package.GetContentFiles()) { IFile filePath = fileSystem.GetInputFile(packageFile.EffectivePath); IDirectory filePathDirectory = filePath.Directory; if (!filePathDirectory.Exists) { filePathDirectory.Create(); } if (!filePath.Exists) { using (var fileStream = filePath.OpenWrite()) { packageFile.GetStream().CopyTo(fileStream); } } } }; packageManager.PackageUninstalling += (sender, args) => { // Remove all content files on uninstall foreach (IPackageFile packageFile in args.Package.GetContentFiles()) { IFile filePath = fileSystem.GetInputFile(packageFile.EffectivePath); if (filePath.Exists) { filePath.Delete(); } } }; foreach (Package package in _packages) { package.InstallPackage(packageManager, updatePackages); } }