コード例 #1
0
        private async Task <(string packageFile, int packageId)> DownloadPackageFilesAsync(Guid kitGuid)
        {
            //Go get the package file from the package repo
            var packageFile = await _packageService.FetchPackageFileAsync(kitGuid, UmbracoVersion.Current, _umbracoContextAccessor.UmbracoContext.Security.GetUserId().ResultOr(0));

            if (packageFile == null)
            {
                throw new InvalidOperationException("Could not fetch package file " + kitGuid);
            }

            //add an entry to the installedPackages.config
            var compiledPackage   = _packageService.GetCompiledPackageInfo(packageFile);
            var packageDefinition = PackageDefinition.FromCompiledPackage(compiledPackage);

            packageDefinition.PackagePath = packageFile.FullName;

            _packageService.SaveInstalledPackage(packageDefinition);

            _packageService.InstallCompiledPackageFiles(packageDefinition, packageFile, _umbracoContextAccessor.UmbracoContext.Security.GetUserId().ResultOr(-1));

            return(compiledPackage.PackageFile.Name, packageDefinition.Id);
        }