예제 #1
0
        private WorkloadResolver(IWorkloadManifestProvider manifestProvider, string [] dotnetRootPaths, string [] currentRuntimeIdentifiers)
        {
            _dotnetRootPaths           = dotnetRootPaths;
            _currentRuntimeIdentifiers = currentRuntimeIdentifiers;

            var manifests = new List <WorkloadManifest>();

            foreach (var manifestStream in manifestProvider.GetManifests())
            {
                using (manifestStream)
                {
                    var manifest = WorkloadManifestReader.ReadWorkloadManifest(manifestStream);
                    manifests.Add(manifest);
                }
            }

            foreach (var manifest in manifests)
            {
                foreach (var workload in manifest.Workloads)
                {
                    _workloads.Add(workload.Key, workload.Value);
                }
                foreach (var pack in manifest.Packs)
                {
                    _packs.Add(pack.Key, pack.Value);
                }
            }
        }
예제 #2
0
        public void RefreshWorkloadManifests()
        {
            _workloads.Clear();
            _packs.Clear();

            var manifests = new Dictionary <string, WorkloadManifest>(StringComparer.OrdinalIgnoreCase);

            foreach ((string manifestId, Stream manifestStream) in _manifestProvider.GetManifests())

            {
                using (manifestStream)
                {
                    var manifest = WorkloadManifestReader.ReadWorkloadManifest(manifestId, manifestStream);
                    if (manifests.ContainsKey(manifestId))
                    {
                        throw new Exception($"Duplicate workload manifest {manifestId}");
                    }
                    manifests.Add(manifestId, manifest);
                }
            }

            foreach (var manifest in manifests.Values)
            {
                if (manifest.DependsOnManifests != null)
                {
                    foreach (var dependency in manifest.DependsOnManifests)
                    {
                        if (manifests.TryGetValue(dependency.Key, out var resolvedDependency))
                        {
                            if (FXVersion.Compare(dependency.Value, resolvedDependency.ParsedVersion) > 0)
                            {
                                throw new Exception($"Inconsistency in workload manifest '{manifest.Id}': requires '{dependency.Key}' version at least {dependency.Value} but found {resolvedDependency.Version}");
                            }
                        }
                        else
                        {
                            throw new Exception($"Inconsistency in workload manifest '{manifest.Id}': missing dependency '{dependency.Key}'");
                        }
                    }
                }
                foreach (var workload in manifest.Workloads)
                {
                    _workloads.Add(workload.Key, workload.Value);
                }
                foreach (var pack in manifest.Packs)
                {
                    _packs.Add(pack.Key, pack.Value);
                }
            }
        }
예제 #3
0
        public WorkloadResolver(IWorkloadManifestProvider manifestProvider, string dotNetRootPath)
        {
            this._dotNetRootPath = dotNetRootPath;

            // eventually we may want a series of fallbacks here, as rids have in general
            // but for now, keep it simple
            var platformId = GetHostPlatformId();

            if (platformId != null)
            {
                _platformIds = new[] { platformId, "*" };
            }
            else
            {
                _platformIds = new[] { "*" };
            }

            var manifests = new List <WorkloadManifest>();

            foreach (var manifestStream in manifestProvider.GetManifests())
            {
                using (manifestStream)
                {
                    var manifest = WorkloadManifestReader.ReadWorkloadManifest(manifestStream);
                    manifests.Add(manifest);
                }
            }

            foreach (var manifest in manifests)
            {
                foreach (var workload in manifest.Workloads)
                {
                    _workloads.Add(workload.Key, workload.Value);
                }
                foreach (var pack in manifest.Packs)
                {
                    _packs.Add(pack.Key, pack.Value);
                }
            }
        }