void NotifyCore(IFile wrapPath, IEnumerable <IResolvedAssembliesUpdateListener> listeners = null)
        {
            var subscriptions = GetSubsriptionsFor(wrapPath);

            if (subscriptions == null)
            {
                return;
            }

            subscriptions.Repository.RefreshPackages();
            var descriptor = new PackageDescriptorReader()
                             .ReadAll(wrapPath.Parent)
                             .Where(x => x.Value.File.Path == wrapPath.Path)
                             .Select(x => x.Value.Value)
                             .SingleOrDefault();

            foreach (var listener in listeners ?? subscriptions.Clients)
            {
                if (descriptor == null)
                {
                    listener.AssembliesError(string.Format("Descriptor for '{0}' has a file name that does not match the package name, or is in an invalid scope. Check the scope of the project is correct.", wrapPath.Path));
                }
                else
                {
                    listener.AssembliesUpdated(PackageManager.GetProjectAssemblyReferences(descriptor, subscriptions.Repository, listener.Environment, false));
                }
            }
        }
        public void Initialize()
        {
            FileSystem = LocalFileSystem.Instance;
            SystemRepositoryDirectory = SystemRepositoryDirectory ?? FileSystem.GetDirectory(DefaultInstallationPaths.SystemRepositoryDirectory);
            var descriptors = new PackageDescriptorReader().ReadAll(CurrentDirectory);

            if (descriptors.ContainsKey(string.Empty))
            {
                DescriptorFile = descriptors[string.Empty].File;
                Descriptor     = descriptors[string.Empty].Value;
            }

            ScopedDescriptors = descriptors;
            TryInitializeProjectRepository();

            CurrentDirectoryRepository = new CurrentDirectoryRepository();

            SystemRepository = new FolderRepository(SystemRepositoryDirectory)
            {
                Name = "System repository"
            };

            ConfigurationDirectory = FileSystem.GetDirectory(DefaultInstallationPaths.ConfigurationDirectory);

            RemoteRepositories   = new RemoteRepositoryBuilder(FileSystem, Services.ServiceLocator.GetService <IConfigurationManager>()).GetConfiguredPackageRepositories().ToList();
            ExecutionEnvironment = new ExecutionEnvironment
            {
                Platform = IntPtr.Size == 4 ? "x86" : "x64",
                Profile  = Environment.Version.Major >= 4 ? "net40" : "net35"
            };
        }
 // TODO: Read-retry should be part of an extension method that can be reused for reading the index in indexed folder repositories.
 public IPackageDescriptor Read(IFile filePath)
 {
     if (!filePath.Exists)
         return null;
     IOException ioException = null;
     int tries = 0;
     while (tries < FILE_READ_RETRIES)
     {
         try
         {
             using (var fileStream = filePath.OpenRead())
             {
                 var descriptor = new PackageDescriptorReader().Read(fileStream);
                 if (descriptor.Name == null)
                     descriptor.Name = PackageNameUtility.GetName(filePath.NameWithoutExtension);
                 return descriptor;
             }
         }
         catch (InvalidPackageException ex)
         {
             throw new InvalidPackageException(String.Format("Invalid package for file '{0}'.", filePath.Path), ex);
         }
         catch (IOException ex)
         {
             ioException = ex;
             tries++;
             Thread.Sleep(FILE_READ_RETRIES_WAIT);
             continue;
         }
     }
     throw ioException;
 }
        void RefreshProjects()
        {
            var descriptors = new PackageDescriptorReader().ReadAll(_rootDirectory);
            var projects =
                _solution.AllProjects.Where(x => x.OpenWrapEnabled)
                    .Select(x => new
                    {
                        project = x,
                        scope = PathFinder.GetCurrentScope(descriptors[string.Empty].Value.DirectoryStructure, x.File.Path)
                    });

            var resolvedAssemblies = (
                                         from project in projects
                                         where descriptors.ContainsKey(project.scope)
                                         let descriptor = descriptors[project.scope].Value
                                         let ee = new ExecutionEnvironment(project.project.TargetPlatform, project.project.TargetFramework.ToOpenWrapMoniker())
                                         let projectAssemblyReferences = _packageManager.GetProjectAssemblyReferences(descriptor, _projectRepository, ee, false)
                                         select new { path = project.project.File.Path.FullPath, asm = projectAssemblyReferences.Select(x => x.File.Path.FullPath).ToList() }
                                     ).ToDictionary(_ => _.path, _ => _.asm);

            var vsAppDomain = (AppDomain)AppDomain.CurrentDomain.GetData("openwrap.vs.appdomain");

            vsAppDomain.SetData(ASSEMBLY_DATA, resolvedAssemblies);
            _assembliesChanged.Set();
        }
 public static IFile TryGenerateAssemblyInfo(IFile descriptorPath, SemanticVersion providedVersion = null)
 {
     IPackageDescriptor descriptor;
     using (var str = descriptorPath.OpenRead())
         descriptor = new PackageDescriptorReader().Read(str);
     var versionFile = descriptorPath.Parent.GetFile("version");
     var version = providedVersion ?? GenerateVersion(descriptor, versionFile);
     if (version == null) return null;
     var generator = new AssemblyInfoGenerator(descriptor) { Version = version };
     var projectAsmFile = descriptorPath.Parent.GetUniqueFile("SharedAssemblyInfo.cs");
     generator.Write(projectAsmFile);
     return projectAsmFile;
 }
        void NotifyClient(IFile wrapPath, IResolvedAssembliesUpdateListener listener)
        {
            var subscriptions = GetSubsriptionsFor(wrapPath);

            if (subscriptions == null)
            {
                return;
            }

            subscriptions.Repository.RefreshPackages();
            var descriptor = new PackageDescriptorReader()
                             .ReadAll(wrapPath.Parent)
                             .Where(x => x.Value.File.Path == wrapPath.Path)
                             .Select(x => x.Value.Value)
                             .Single();


            listener.AssembliesUpdated(PackageManager.GetProjectAssemblyReferences(descriptor, subscriptions.Repository, listener.Environment, false));
        }
        void NotifyAllClients(IFile wrapPath)
        {
            var subscriptions = GetSubsriptionsFor(wrapPath);

            if (subscriptions == null)
            {
                return;
            }

            subscriptions.Repository.RefreshPackages();
            var descriptor = new PackageDescriptorReader()
                             .ReadAll(wrapPath.Parent)
                             .Where(x => x.Value.File.Path == wrapPath.Path)
                             .Select(x => x.Value.Value)
                             .Single();

            foreach (var client in subscriptions.Clients)
            {
                client.AssembliesUpdated(PackageManager.GetProjectAssemblyReferences(descriptor, subscriptions.Repository, client.Environment, false));
            }
        }
Beispiel #8
0
        public static IFile TryGenerateAssemblyInfo(IFile descriptorPath, SemanticVersion providedVersion = null)
        {
            IPackageDescriptor descriptor;

            using (var str = descriptorPath.OpenRead())
                descriptor = new PackageDescriptorReader().Read(str);
            var versionFile = descriptorPath.Parent.GetFile("version");
            var version     = providedVersion ?? GenerateVersion(descriptor, versionFile);

            if (version == null)
            {
                return(null);
            }
            var generator = new AssemblyInfoGenerator(descriptor)
            {
                Version = version
            };
            var projectAsmFile = descriptorPath.Parent.GetUniqueFile("SharedAssemblyInfo.cs");

            generator.Write(projectAsmFile);
            return(projectAsmFile);
        }
Beispiel #9
0
        void RefreshProjects()
        {
            var descriptors = new PackageDescriptorReader().ReadAll(_rootDirectory);
            var projects    =
                _solution.AllProjects.Where(x => x.OpenWrapEnabled)
                .Select(x => new
            {
                project = x,
                scope   = PathFinder.GetCurrentScope(descriptors[string.Empty].Value.DirectoryStructure, x.File.Path)
            });
            var resolvedAssemblies = (
                from project in projects
                where descriptors.ContainsKey(project.scope)
                let descriptor = descriptors[project.scope].Value
                                 let ee = new ExecutionEnvironment(project.project.TargetPlatform, project.project.TargetFramework.ToOpenWrapMoniker())
                                          let projectAssemblyReferences = _packageManager.GetProjectAssemblyReferences(descriptor, _projectRepository, ee, false)
                                                                          select new { path = project.project.File.Path.FullPath, asm = projectAssemblyReferences.Select(x => x.File.Path.FullPath).ToList() }
                ).ToDictionary(_ => _.path, _ => _.asm);

            var vsAppDomain = (AppDomain)AppDomain.CurrentDomain.GetData("openwrap.vs.appdomain");

            vsAppDomain.SetData(ASSEMBLY_DATA, resolvedAssemblies);
            _assembliesChanged.Set();
        }
        public void Initialize()
        {
            FileSystem = LocalFileSystem.Instance;

            var descriptors = new PackageDescriptorReader().ReadAll(CurrentDirectory);
            if (descriptors.ContainsKey(string.Empty))
            {
                DescriptorFile = descriptors[string.Empty].File;
                Descriptor = descriptors[string.Empty].Value;
            }

            ScopedDescriptors = descriptors;
            TryInitializeProjectRepository();

            CurrentDirectoryRepository = new CurrentDirectoryRepository();

            SystemRepository = new FolderRepository(FileSystem.GetDirectory(DefaultInstallationPaths.SystemRepositoryDirectory))
            {
                    Name = "System repository"
            };

            ConfigurationDirectory = FileSystem.GetDirectory(DefaultInstallationPaths.ConfigurationDirectory);

            RemoteRepositories = new RemoteRepositoryBuilder(FileSystem, Services.Services.GetService<IConfigurationManager>()).GetConfiguredPackageRepositories().ToList();
            ExecutionEnvironment = new ExecutionEnvironment
            {
                    Platform = IntPtr.Size == 4 ? "x86" : "x64",
                    Profile = Environment.Version.Major >= 4 ? "net40" : "net35"
            };
        }
        void NotifyCore(IFile wrapPath, IEnumerable<IResolvedAssembliesUpdateListener> listeners = null)
        {
            var subscriptions = GetSubsriptionsFor(wrapPath);
            if (subscriptions == null) return;

            subscriptions.Repository.RefreshPackages();
            var descriptor = new PackageDescriptorReader()
                    .ReadAll(wrapPath.Parent)
                    .Where(x => x.Value.File.Path == wrapPath.Path)
                    .Select(x => x.Value.Value)
                    .SingleOrDefault();

            foreach (var listener in listeners ?? subscriptions.Clients)
            {
                if (descriptor == null)
                    listener.AssembliesError(string.Format("Descriptor for '{0}' has a file name that does not match the package name, or is in an invalid scope. Check the scope of the project is correct.", wrapPath.Path));
                else
                    listener.AssembliesUpdated(PackageManager.GetProjectAssemblyReferences(descriptor, subscriptions.Repository, listener.Environment, false));
            }
        }
        void NotifyAllClients(IFile wrapPath)
        {
            var subscriptions = GetSubsriptionsFor(wrapPath);
            if (subscriptions == null) return;

            subscriptions.Repository.RefreshPackages();
            var descriptor = new PackageDescriptorReader()
                    .ReadAll(wrapPath.Parent)
                    .Where(x => x.Value.File.Path == wrapPath.Path)
                    .Select(x=>x.Value.Value)
                    .Single();

            foreach (var client in subscriptions.Clients)
                client.AssembliesUpdated(PackageResolver.GetAssemblyReferences(false, client.Environment, descriptor, subscriptions.Repository));
        }
        void NotifyClient(IFile wrapPath, IResolvedAssembliesUpdateListener listener)
        {
            var subscriptions = GetSubsriptionsFor(wrapPath);
            if (subscriptions == null) return;

            subscriptions.Repository.RefreshPackages();
            var descriptor = new PackageDescriptorReader()
                    .ReadAll(wrapPath.Parent)
                    .Where(x => x.Value.File.Path == wrapPath.Path)
                    .Select(x => x.Value.Value)
                    .Single();

            listener.AssembliesUpdated(PackageResolver.GetAssemblyReferences(false, listener.Environment, descriptor, subscriptions.Repository));
        }