private PackageBuilder CreatePackageBuilder(PackageDescriptor packageDesciptor, Package locatedPackage)
        {
            var pb = new PackageBuilder(packageDesciptor.Name);

            pb.Directory = locatedPackage.Directory;
            return(pb);
        }
        private async Task <IPackage> TryInstallAndLocateTool(PackageDescriptor packageDesciptor)
        {
            var dotnet = new Dotnet();

            var installationResult = await dotnet.ToolInstall(
                packageDesciptor.Name,
                _workingDirectory,
                _addSource,
                new Budget());

            if (installationResult.ExitCode != 0)
            {
                Logger <LocalToolInstallingPackageDiscoveryStrategy> .Log.Warning($"Tool not installed: {packageDesciptor.Name}");

                return(null);
            }

            var tool = new PackageTool(packageDesciptor.Name, _workingDirectory);

            if (tool.Exists)
            {
                return(await CreatePackage(packageDesciptor, tool));
            }

            return(null);
        }
Esempio n. 3
0
        protected async Task <IPackage> CreatePackage(PackageDescriptor descriptor, PackageTool tool)
        {
            await tool.Prepare();

            try
            {
                var projectAsset = await tool.LocateProjectAsset();

                var package = new Package2(descriptor.Name, tool.DirectoryAccessor);
                package.Add(projectAsset);
                try
                {
                    var wasmAsset = await tool.LocateWasmAsset();

                    package.Add(wasmAsset);
                }
                catch (WasmAssetNotFoundException)
                {
                }

                return(package);
            }
            catch (ProjectAssetNotFoundException)
            {
                return(null);
            }
        }
Esempio n. 4
0
        private async Task <IPackage> TryInstallAndLocateTool(PackageDescriptor packageDesciptor)
        {
            var dotnet = new Dotnet();

            var installationResult = await dotnet.ToolInstall(
                packageDesciptor.Name,
                _workingDirectory.GetFullyQualifiedRoot(),
                _addSource?.ToString());

            if (installationResult.ExitCode != 0)
            {
                Logger <LocalToolInstallingPackageDiscoveryStrategy> .Log.Warning($"Tool not installed: {packageDesciptor.Name}");

                return(null);
            }

            var tool = PackageTool.TryCreateFromDirectory(packageDesciptor.Name, _workingDirectory);

            if (tool != null)
            {
                return(await CreatePackage(packageDesciptor, tool));
            }

            return(null);
        }
        private async Task <PackageBuilder> TryInstallAndLocateTool(PackageDescriptor packageDesciptor, Budget budget)
        {
            var dotnet = new Dotnet();

            var installationResult = await dotnet.ToolInstall(
                packageDesciptor.Name,
                _workingDirectory,
                _addSource?.ToString());

            if (installationResult.ExitCode != 0)
            {
                Logger <LocalToolInstallingPackageDiscoveryStrategy> .Log.Warning($"Tool not installed: {packageDesciptor.Name}");

                return(null);
            }

            var tool = await _locator.LocatePackageAsync(packageDesciptor.Name, budget);

            if (tool != null)
            {
                return(CreatePackageBuilder(packageDesciptor, tool));
            }

            return(null);
        }
Esempio n. 6
0
        public Package2(
            PackageDescriptor descriptor,
            IDirectoryAccessor directoryAccessor)
        {
            _descriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor));

            DirectoryAccessor = directoryAccessor ?? throw new ArgumentNullException(nameof(directoryAccessor));
        }
Esempio n. 7
0
            public Task <T> Find <T>(PackageDescriptor descriptor) where T : class, IPackage
            {
                if (_package is T package)
                {
                    return(Task.FromResult(package));
                }

                return(default);
        public async Task <PackageBuilder> Locate(PackageDescriptor packageDesciptor, Budget budget = null)
        {
            var locatedPackage = await _locator.LocatePackageAsync(packageDesciptor.Name, budget);

            if (locatedPackage != null)
            {
                return(CreatePackageBuilder(packageDesciptor, locatedPackage));
            }

            return(await TryInstallAndLocateTool(packageDesciptor, budget));
        }
Esempio n. 9
0
        public Task <PackageBuilder> Locate(PackageDescriptor packageDescriptor, Budget budget)
        {
            var directory = new DirectoryInfo(Path.Combine(
                                                  Package.DefaultPackagesDirectory.FullName, packageDescriptor.Name));

            if (directory.Exists)
            {
                var packageBuilder = new PackageBuilder(packageDescriptor.Name);
                packageBuilder.CreateRebuildablePackage = _createRebuildablePackage;
                return(Task.FromResult(packageBuilder));
            }

            return(Task.FromResult <PackageBuilder>(null));
        }
Esempio n. 10
0
        protected async Task <IPackage> CreatePackage(PackageDescriptor descriptor, PackageTool tool)
        {
            await tool.Prepare();

            var wasmAsset = await tool.LocateWasmAsset();

            if (wasmAsset != null)
            {
                var package = new Package2(descriptor.Name, new FileSystemDirectoryAccessor(wasmAsset.DirectoryAccessor.GetFullyQualifiedRoot().Parent));
                package.Add(wasmAsset);
                return(package);
            }

            return(null);
        }
        public Task <PackageBuilder> Locate(
            PackageDescriptor packageDescriptor,
            Budget budget = null)
        {
            var projectFile = packageDescriptor.Name;

            if (Path.GetExtension(projectFile) == ".csproj" && File.Exists(projectFile))
            {
                PackageBuilder packageBuilder = new PackageBuilder(packageDescriptor.Name);
                packageBuilder.CreateRebuildablePackage = _createRebuildablePackage;
                packageBuilder.Directory = new DirectoryInfo(Path.GetDirectoryName(projectFile));
                return(Task.FromResult(packageBuilder));
            }

            return(Task.FromResult <PackageBuilder>(null));
        }
Esempio n. 12
0
        async Task <TPackage> IPackageFinder.Find <TPackage>(PackageDescriptor descriptor)
        {
            if (descriptor.IsPathSpecified)
            {
                return(null);
            }

            var candidate = new PackageTool(descriptor.Name, _workingDirectory);

            if (candidate.Exists)
            {
                var package = await CreatePackage(descriptor, candidate);

                return(package as TPackage);
            }

            return(null);
        }
Esempio n. 13
0
        async Task <IMightSupportBlazor> IPackageFinder.Find <IMightSupportBlazor>(PackageDescriptor descriptor)
        {
            if (descriptor.IsPathSpecified)
            {
                return(null);
            }

            var candidate = new PackageTool(descriptor.Name, _workingDirectory);

            if (candidate.Exists)
            {
                var package = await CreatePackage(descriptor, candidate);

                return((IMightSupportBlazor)package);
            }

            return((IMightSupportBlazor)(await TryInstallAndLocateTool(descriptor)));
        }
Esempio n. 14
0
        async Task <TPackage> IPackageFinder.Find <TPackage>(PackageDescriptor descriptor)
        {
            if (descriptor.IsPathSpecified)
            {
                return(null);
            }

            var candidate = PackageTool.TryCreateFromDirectory(descriptor.Name, _workingDirectory);

            if (candidate != null)
            {
                var package = await CreatePackage(descriptor, candidate);

                return(package as TPackage);
            }

            return(await TryInstallAndLocateTool(descriptor) as TPackage);
        }
Esempio n. 15
0
        protected async Task <IPackage> CreatePackage(PackageDescriptor descriptor, PackageTool tool)
        {
            await tool.Prepare();

            var projectAsset = await tool.LocateProjectAsset();

            if (projectAsset != null)
            {
                var package = new Package2(descriptor.Name, tool.DirectoryAccessor);
                package.Add(projectAsset);

                var wasmAsset = await tool.LocateWasmAsset();

                if (wasmAsset != null)
                {
                    package.Add(wasmAsset);
                    return(package);
                }
            }

            return(null);
        }