Ejemplo n.º 1
0
        private DirectoryPath InstallPackage(PackageDefinition package, DirectoryPath root)
        {
            var packagePath = root.Combine("libs");

            if (!_fileSystem.Exist(packagePath))
            {
                _fileSystem.GetDirectory(packagePath).Create();
            }
            var toolsPath     = root.Combine("tools");
            var nugetToolPath = toolsPath.CombineWithFilePath("nuget.exe");

            if (!_fileSystem.Exist(toolsPath))
            {
                _fileSystem.GetDirectory(toolsPath).Create();
            }
            if (!_fileSystem.Exist(nugetToolPath))
            {
                DownloadNuget(nugetToolPath);
            }


            if (_fileSystem.Exist(packagePath.Combine(package.PackageName)))
            {
                return(packagePath.Combine(package.PackageName));
            }

            var arguments         = $"install \"{package.PackageName}\" -Source \"https://api.nuget.org/v3/index.json\" -PreRelease -ExcludeVersion -OutputDirectory \"{packagePath.FullPath}\"{(!string.IsNullOrWhiteSpace(package.Version) ? $" -Version \"{package.Version}\"" : string.Empty)}";
            var fallbackarguments = $"install \"{package.PackageName}\" -Source \"https://api.nuget.org/v3/index.json\" -Source \"https://www.myget.org/F/xunit/api/v3/index.json\" -Source \"https://dotnet.myget.org/F/dotnet-core/api/v3/index.json\" -Source \"https://dotnet.myget.org/F/cli-deps/api/v3/index.json\" -PreRelease -ExcludeVersion -OutputDirectory \"{packagePath.FullPath}\"{(!string.IsNullOrWhiteSpace(package.Version) ? $" -Version \"{package.Version}\"" : string.Empty)}";

            ExecuteNuget(nugetToolPath, arguments, fallbackarguments, 3);

            // Return the installation directory.
            return(packagePath.Combine(package.PackageName));
        }
Ejemplo n.º 2
0
 private static DirectoryPath GetPackagePath(DirectoryPath root, PackageReference package)
 {
     if (package.Parameters.ContainsKey("version"))
     {
         var version = package.Parameters["version"].First();
         return(root.Combine($"{package.Package}.{version}".ToLowerInvariant()));
     }
     return(root.Combine(package.Package.ToLowerInvariant()));
 }
Ejemplo n.º 3
0
    public BuildContext(ICakeContext context)
        : base(context)
    {
        BuildConfiguration = context.Argument("Configuration", "Release");
        SkipTests          = context.Argument("SkipTests", false);
        SkipSlowTests      = context.Argument("SkipSlowTests", false);

        RootDirectory       = new DirectoryPath(new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.FullName);
        ArtifactsDirectory  = RootDirectory.Combine("artifacts");
        ToolsDirectory      = RootDirectory.Combine("tools");
        DocsDirectory       = RootDirectory.Combine("docs");
        DocfxDirectory      = ToolsDirectory.Combine("docfx");
        DocfxExeFile        = DocfxDirectory.CombineWithFilePath("docfx.exe");
        DocfxJsonFile       = DocsDirectory.CombineWithFilePath("docfx.json");
        TestOutputDirectory = RootDirectory.Combine("TestResults");

        ChangeLogDirectory    = RootDirectory.Combine("docs").Combine("changelog");
        ChangeLogGenDirectory = RootDirectory.Combine("docs").Combine("_changelog");

        SolutionFile         = RootDirectory.CombineWithFilePath("BenchmarkDotNet.sln");
        UnitTestsProjectFile = RootDirectory.Combine("tests").Combine("BenchmarkDotNet.Tests")
                               .CombineWithFilePath("BenchmarkDotNet.Tests.csproj");
        IntegrationTestsProjectFile = RootDirectory.Combine("tests").Combine("BenchmarkDotNet.IntegrationTests")
                                      .CombineWithFilePath("BenchmarkDotNet.IntegrationTests.csproj");
        TemplatesTestsProjectFile = RootDirectory.Combine("templates")
                                    .CombineWithFilePath("BenchmarkDotNet.Templates.csproj");
        AllPackableSrcProjects = new FilePathCollection(context.GetFiles(RootDirectory.FullPath + "/src/**/*.csproj")
                                                        .Where(p => !p.FullPath.Contains("Disassembler")));

        MsBuildSettings = new DotNetCoreMSBuildSettings
        {
            MaxCpuCount = 1
        };
        MsBuildSettings.WithProperty("UseSharedCompilation", "false");
    }
Ejemplo n.º 4
0
        public static void Initialize()
        {
            DataPath = new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))
                       .Combine(new DirectoryPath("Jarvis"));

            LogPath       = DataPath.Combine(new DirectoryPath("Logs"));
            InstallerPath = DataPath.Combine(new DirectoryPath("Installers"));

            var fileSystem = new FileSystem();

            CreatePath(fileSystem, DataPath);
            CreatePath(fileSystem, LogPath);
            CreatePath(fileSystem, InstallerPath);
        }
Ejemplo n.º 5
0
 /// <summary></summary>
 /// <param name="identity"></param>
 /// <param name="rootHomeDir"></param>
 /// <param name="metadata"></param>
 public LocalPluginPackage(PackageIdentity identity,
                           DirectoryPath rootHomeDir,
                           TMeta metadata)
     : base(identity, metadata)
 {
     HomeDir = rootHomeDir.Combine(Id);
 }
Ejemplo n.º 6
0
        async Task ProcessAcmeFqdnAsync(AcmeAccount account, string fqdn, CancellationToken cancel)
        {
            cancel.ThrowIfCancellationRequested();

            DirectoryPath dir = this.AcmeDir.GetSubDirectory(fqdn);

            FilePath crtFileName = dir.Combine(dir.GetThisDirectoryName() + Consts.Extensions.Certificate_Acme);

            Certificate?currentCert = null;

            if (crtFileName.IsFileExists(cancel))
            {
                try
                {
                    currentCert = CertificateUtil.ImportChainedCertificates(crtFileName.ReadDataFromFile().Span).First();
                }
                catch (Exception ex)
                {
                    ex._Debug();
                }
            }

            if (currentCert == null || IsCertificateDateTimeToUpdate(currentCert.CertData.NotBefore, currentCert.CertData.NotAfter))
            {
                //Con.WriteLine($"fqdn = {fqdn}, currentCert = {currentCert}, crtFileName = {crtFileName}");

                await AcmeIssueAsync(account, fqdn, crtFileName, cancel);
            }
        }
Ejemplo n.º 7
0
        public DirectoryPath InstallPackage(PackageDefinition package, DirectoryPath root)
        {
            var packagePath = root.Combine("libs");

            if (!_fileSystem.Exist(packagePath))
            {
                _fileSystem.GetDirectory(packagePath).Create();
            }

            if (!_fileSystem.Exist(packagePath.Combine(package.PackageName)))
            {
                var packageManager = CreatePackageManager(packagePath);
                if (!string.IsNullOrWhiteSpace(package.Version))
                {
                    // Install specific version.
                    packageManager.InstallPackage(package.PackageName, new SemanticVersion(package.Version), true, true);
                }
                else
                {
                    // Install latest version.
                    packageManager.InstallPackage(package.PackageName);
                }
            }

            // Return the installation directory.
            return(packagePath.Combine(package.PackageName));
        }
Ejemplo n.º 8
0
        private IFile[] InstallPackage(
            NuGetPackage package,
            DirectoryPath installationRoot,
            Func <DirectoryPath, IFile[]> fetcher)
        {
            var root        = _fileSystem.GetDirectory(installationRoot);
            var packagePath = installationRoot.Combine(package.PackageId);

            // Create the addin directory if it doesn't exist.
            if (!root.Exists)
            {
                _log.Debug("Creating addin directory {0}", installationRoot);
                root.Create();
            }

            // Fetch available content from disc.
            var content = fetcher(packagePath);

            if (content.Any())
            {
                _log.Debug("Package {0} has already been installed.", package.PackageId);
                return(content);
            }

            // Install the package.
            _log.Debug("Installing package {0}...", package.PackageId);
            _installer.InstallPackage(package, installationRoot);

            // Return the files.
            return(fetcher(packagePath));
        }
Ejemplo n.º 9
0
        // For the root (".") virtual directory, this should just return the child name,
        // but for all others it should include the child directory name
        public IEnumerable <IDirectory> GetDirectories(SearchOption searchOption = SearchOption.TopDirectoryOnly)
        {
            // Get all the relative child directories
            HashSet <DirectoryPath> directories = new HashSet <DirectoryPath>();

            foreach (IDirectory directory in GetExistingDirectories())
            {
                foreach (IDirectory childDirectory in directory.GetDirectories(searchOption))
                {
                    directories.Add(_path.Combine(directory.Path.GetRelativePath(childDirectory.Path)));
                }
            }

            // Return a new virtual directory for each one
            return(directories.Select(x => new VirtualInputDirectory(_fileSystem, x)));
        }
Ejemplo n.º 10
0
        private DirectoryPath GetCakePath(DirectoryPath toolPath)
        {
            var pattern      = string.Concat(toolPath.FullPath, "/**/Cake.exe");
            var cakeCorePath = _globber.GetFiles(pattern).FirstOrDefault();

            return(cakeCorePath?.GetDirectory().MakeAbsolute(_environment) ?? toolPath.Combine("Cake").Collapse());
        }
Ejemplo n.º 11
0
        private void Install(DirectoryPath root)
        {
            if (root == null)
            {
                throw new ArgumentNullException("root");
            }

            var installRoot = root.Combine(Guid.NewGuid().ToString().Replace("-", string.Empty));

            // Install package.
            _log.Verbose("Installing package...");
            var repository     = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2");
            var packageManager = new PackageManager(repository, installRoot.FullPath);

            packageManager.InstallPackage("Roslyn.Compilers.CSharp", new SemanticVersion(new Version(1, 2, 20906, 2)), false, true);

            // Copy files
            _log.Verbose("Copying files...");
            foreach (var path in _paths)
            {
                var source      = _fileSystem.GetFile(installRoot.CombineWithFilePath(path));
                var destination = _fileSystem.GetFile(root.CombineWithFilePath(path.GetFilename()));

                _log.Information("Copying {0}...", source.Path.GetFilename());

                if (!destination.Exists)
                {
                    source.Copy(destination.Path, true);
                }
            }

            // Delete the install directory.
            _log.Verbose("Deleting installation directory...");
            _fileSystem.GetDirectory(installRoot).Delete(true);
        }
        public static LocalDevPluginPackage <TMeta> Create(string packageName, DirectoryPath devDir, CreateMetadata metadataFunc)
        {
            FilePath pluginFilePath = devDir.Combine(packageName).CombineFile(packageName + ".dll");

            if (pluginFilePath.Exists() == false)
            {
                LogTo.Warning($"Couldn't find development plugin dll {pluginFilePath.FullPath}. Skipping.");
                return(null);
            }

            FileVersionInfo pluginVersionInfo = FileVersionInfo.GetVersionInfo(pluginFilePath.FullPath);

            if (pluginVersionInfo.ProductName != packageName)
            {
                LogTo.Warning(
                    $"Development plugin Folder name {packageName} differs from Assembly name {pluginVersionInfo.ProductName}. Skipping.");
                return(null);
            }

            packageName = pluginFilePath.FileNameWithoutExtension;

            return(new LocalDevPluginPackage <TMeta>(
                       new PackageIdentity(packageName, NuGetVersion.Parse(pluginVersionInfo.ProductVersion)),
                       devDir,
                       metadataFunc(packageName, pluginVersionInfo)
                       ));
        }
        private static FilePath GenerateDrillPath()
        {
            var SubsetsDir        = new DirectoryPath(Svc.SM.Collection.Path).Combine("subsets");
            var FilteredDrillsDir = SubsetsDir.Combine("drills");
            var fileName          = DateTime.Now.ToString("yyyyMMddTHHmmss") + "_drill.sub";

            return(FilteredDrillsDir.CombineFile(fileName));
        }
Ejemplo n.º 14
0
 internal static DirectoryPath GetOutputPath(this IEnumerable <XElement> configPropertyGroups, XNamespace ns,
                                             DirectoryPath rootPath)
 {
     return(configPropertyGroups
            .Elements(ns + ProjectXElement.OutputPath)
            .Select(outputPath => rootPath.Combine(DirectoryPath.FromString(outputPath.Value)))
            .FirstOrDefault());
 }
Ejemplo n.º 15
0
        private DirectoryPath GetToolPath(DirectoryPath root)
        {
            var toolPath = _configuration.GetValue("Paths_Tools");

            return(!string.IsNullOrWhiteSpace(toolPath)
                ? new DirectoryPath(toolPath).MakeAbsolute(_environment)
                : root.Combine("tools"));
        }
Ejemplo n.º 16
0
        public static void CopyDirectory(this ICakeContext context, DirectoryPath source, DirectoryPath destination)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }

            if (source.IsRelative)
            {
                source = source.MakeAbsolute(context.Environment);
            }

            // Get the subdirectories for the specified directory.
            var sourceDir = context.FileSystem.GetDirectory(source);

            if (!sourceDir.Exists)
            {
                throw new System.IO.DirectoryNotFoundException(
                          "Source directory does not exist or could not be found: "
                          + source.FullPath);
            }

            var dirs = sourceDir.GetDirectories("*", SearchScope.Current);

            var destinationDir = context.FileSystem.GetDirectory(destination);

            if (!destinationDir.Exists)
            {
                destinationDir.Create();
            }

            // Get the files in the directory and copy them to the new location.
            var files = sourceDir.GetFiles("*", SearchScope.Current);

            foreach (var file in files)
            {
                var temppath = destinationDir.Path.CombineWithFilePath(file.Path.GetFilename());
                context.Log.Verbose("Copying file {0} to {1}", file.Path, temppath);
                file.Copy(temppath, true);
            }

            // Copy all of the subdirectories
            foreach (var subdir in dirs)
            {
                var temppath = destination.Combine(subdir.Path.GetDirectoryName());
                CopyDirectory(context, subdir.Path, temppath);
            }
        }
        public static DirectoryPath GetArtifactsPath(this IConfiguration configuration)
        {
            DirectoryPath artifactsRoot = configuration.GetSimple <DirectoryPath>(ConfigurationConstants.ARTIFACTS_PATH_KEY);
            DirectoryPath result        = artifactsRoot.Combine(configuration.GetApplicationName())
                                          .Combine(configuration.GetTargetName()).Combine(configuration.GetPlatformName());

            configuration.Context.CakeContext.EnsureDirectoryExists(result);
            return(result);
        }
        public static DirectoryPath GetBuildPath(this IConfiguration configuration)
        {
            DirectoryPath buildRoot = configuration.GetSimple <DirectoryPath>(ConfigurationConstants.BUILD_PATH_KEY);
            DirectoryPath result    = buildRoot.Combine(configuration.GetApplicationName())
                                      .Combine(configuration.GetTargetName()).Combine(configuration.GetPlatformName());

            configuration.Context.CakeContext.EnsureDirectoryExists(result);
            return(result);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Installs the specified resource at the given location.
        /// </summary>
        /// <param name="package">The package reference.</param>
        /// <param name="type">The package type.</param>
        /// <param name="path">The location where to install the package.</param>
        /// <returns>The installed files.</returns>
        public IReadOnlyCollection <IFile> Install(PackageReference package, PackageType type, DirectoryPath path)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            path = path.MakeAbsolute(_environment);

            var root        = _fileSystem.GetDirectory(path);
            var packagePath = path.Combine(package.Package);

            // Create the addin directory if it doesn't exist.
            if (!root.Exists)
            {
                _log.Debug("Creating directory {0}", path);
                root.Create();
            }

            // Fetch available content from disc.
            var content = _contentResolver.GetFiles(packagePath, type);

            if (content.Any())
            {
                _log.Debug("Package {0} has already been installed.", package.Package);
                return(content);
            }

            // Install the package.
            _log.Debug("Installing NuGet package {0}...", package.Package);
            var nugetPath = GetNuGetPath();
            var process   = _processRunner.Start(nugetPath, new ProcessSettings
            {
                Arguments = GetArguments(package, path, _config),
                RedirectStandardOutput = true,
                Silent = _log.Verbosity < Verbosity.Diagnostic
            });

            process.WaitForExit();

            var exitCode = process.GetExitCode();

            if (exitCode != 0)
            {
                _log.Warning("NuGet exited with {0}", exitCode);
                var output = string.Join(Environment.NewLine, process.GetStandardOutput());
                _log.Verbose(Verbosity.Diagnostic, "Output:\r\n{0}", output);
            }

            // Return the files.
            return(_contentResolver.GetFiles(packagePath, type));
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Dumps file members into an array of file artifacts.
 /// </summary>
 public void GetArtifacts(Context context, EvaluationResult[] files, bool asDirectory)
 {
     for (int i = 0; i < m_files.Count; ++i)
     {
         var path = DirectoryPath.Combine(context.PathTable, m_files[i]);
         files[Index + i] = asDirectory
                 ? EvaluationResult.Create(DirectoryArtifact.CreateWithZeroPartialSealId(path))
                 : EvaluationResult.Create(FileArtifact.CreateSourceFile(path));
     }
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Gets the tool directory path.
        /// </summary>
        /// <param name="configuration">The Cake configuration.</param>
        /// <param name="defaultRoot">The default root path.</param>
        /// <param name="environment">The environment.</param>
        /// <returns>The tool directory path.</returns>
        public static DirectoryPath GetToolPath(this ICakeConfiguration configuration, DirectoryPath defaultRoot, ICakeEnvironment environment)
        {
            var toolPath = configuration.GetValue(Constants.Paths.Tools);

            if (!string.IsNullOrWhiteSpace(toolPath))
            {
                return(new DirectoryPath(toolPath).MakeAbsolute(environment));
            }
            return(defaultRoot.Combine("tools"));
        }
Ejemplo n.º 22
0
        private DirectoryPath GetToolPath(DirectoryPath root)
        {
            var toolPath = _configuration.GetValue(Constants.Paths.Tools);

            if (!string.IsNullOrWhiteSpace(toolPath))
            {
                return(new DirectoryPath(toolPath).MakeAbsolute(_environment));
            }

            return(root.Combine("tools"));
        }
Ejemplo n.º 23
0
            public void Should_Throw_If_Path_Is_Null()
            {
                // Given
                var path = new DirectoryPath("assets");

                // When
                var result = Record.Exception(() => path.Combine(null));

                // Then
                Assert.IsArgumentNullException(result, "path");
            }
Ejemplo n.º 24
0
            public void Should_Combine_Paths(string first, string second, string expected)
            {
                // Given
                var path = new DirectoryPath(first);

                // When
                var result = path.Combine(new DirectoryPath(second));

                // Then
                Assert.Equal(expected, result.FullPath);
            }
Ejemplo n.º 25
0
            public void Should_Combine_Windows_Paths(string first, string second, string expected)
            {
                // Given
                var path = new DirectoryPath(first);

                // When
                var result = path.Combine(new DirectoryPath(second));

                // Then
                result.FullPath.ShouldBe(expected);
            }
        public static string AddRootDirectory(this IConfiguration configuration, string path)
        {
            if (!configuration.Has(ConfigurationConstants.ROOT_PATH_KEY))
            {
                return(path);
            }

            DirectoryPath rootDirectory = configuration.GetSimple <DirectoryPath>(ConfigurationConstants.ROOT_PATH_KEY);

            return(rootDirectory.Combine(path).FullPath);
        }
Ejemplo n.º 27
0
        private static DirectoryPath GetMonoPathWindows()
        {
            var programFiles = _environment.Is64BitOperativeSystem()
                ? Environment.SpecialFolder.ProgramFilesX86
                : Environment.SpecialFolder.ProgramFiles;

            var programFilesPath = new DirectoryPath(Environment.GetFolderPath(programFiles));
            var monoPath         = programFilesPath.Combine("Mono").Combine("bin");

            return(_fileSystem.GetDirectory(monoPath).Exists ? monoPath : null);
        }
Ejemplo n.º 28
0
            public void ShouldThrowIfPathIsNull()
            {
                // Given
                DirectoryPath path = new DirectoryPath("assets");

                // When
                TestDelegate test = () => path.Combine(null);

                // Then
                Assert.Throws <ArgumentNullException>(test);
            }
Ejemplo n.º 29
0
            public void CombiningWithAbsolutePathKeepsSecondProvider(string first, string second)
            {
                // Given
                DirectoryPath path = new DirectoryPath(new Uri("first:///"), first);

                // When
                DirectoryPath result = path.Combine(new DirectoryPath(new Uri("second:///"), second));

                // Then
                Assert.AreEqual(new Uri("second:///"), result.FileProvider);
            }
Ejemplo n.º 30
0
            public void CombiningWithRelativePathKeepsFirstProvider(string first, string second)
            {
                // Given
                DirectoryPath path = new DirectoryPath(new Uri("foo:///"), first);

                // When
                DirectoryPath result = path.Combine(new DirectoryPath(second));

                // Then
                Assert.AreEqual(new Uri("foo:///"), result.FileProvider);
            }
Ejemplo n.º 31
0
        public DirectoryPath InstallPackage(PackageDefinition package, DirectoryPath root)
        {
            var packagePath = root.Combine("libs");
            if (!_fileSystem.Exist(packagePath))
            {
                _fileSystem.GetDirectory(packagePath).Create();
            }

            if (!_fileSystem.Exist(packagePath.Combine(package.PackageName)))
            {
                var packageManager = CreatePackageManager(packagePath);
                packageManager.InstallPackage(package.PackageName);
            }

            // Return the installation directory.
            return packagePath.Combine(package.PackageName);
        }
Ejemplo n.º 32
0
        protected void Application_Start()
        {
            // Get the application data path.
            var appDataPath = new DirectoryPath(AppDomain.CurrentDomain.GetData("DataDirectory").ToString());

            // Read all addins.
            // TODO: Fix this container hack.
            var addinReader = new AddinReader(new FileSystem());
            var addins = addinReader.Read(appDataPath.CombineWithFilePath("addins.xml"));

            // Define packages.
            var packageDefinitions = new List<PackageDefinition>();
            packageDefinitions.AddRange(addins.GetAddins()
                .Where(x => x.PackageDefinition != null)
                .Where(x => x.PackageDefinition.Filters.Count > 0)
                .Select(x => x.PackageDefinition));

            // Add core packages.
            packageDefinitions.Add(new PackageDefinition
            {
                Filters = new List<string>
                {
                    "/**/Cake.Core.dll",
                    "/**/Cake.Common.dll",
                    "/**/Cake.Core.xml",
                    "/**/Cake.Common.xml"
                },
                PackageName = "Cake",
                Metadata = new CakeMetadata()
            });

            // Create the document model by downloading the nuget package.
            var cakeVersion = (string)null;
            var documentModel = NuGetBootstrapper.Download(appDataPath,
                new NuGetConfiguration {
                    Packages = packageDefinitions
                }, out cakeVersion);

            // Build the DSL model.
            var dslModel = DslModelBuilder.Build(documentModel);

            // Generate packages.config content.
            var packagesConfig = new PackagesConfigContent(cakeVersion);

            // Build the container.
            var builder = new ContainerBuilder();
            builder.RegisterModule<CoreModule>();
            builder.RegisterControllers(typeof(MvcApplication).Assembly);
            builder.RegisterInstance(documentModel).As<DocumentModel>().SingleInstance();
            builder.RegisterInstance(dslModel).As<DslModel>().SingleInstance();
            builder.RegisterType<DocumentModelResolver>().SingleInstance();
            builder.RegisterType<RouteService>().SingleInstance();
            builder.RegisterType<UrlResolver>().As<IUrlResolver>().As<UrlResolver>().SingleInstance();
            builder.RegisterType<SignatureCache>().SingleInstance();
            builder.RegisterType<ApiServices>().SingleInstance();
            builder.RegisterType<LanguageProvider>().SingleInstance();
            builder.RegisterType<SyntaxRenderer>().SingleInstance();
            builder.RegisterType<SignatureRenderer>().SingleInstance();
            builder.RegisterType<ApiServices>().SingleInstance();
            builder.RegisterInstance(packagesConfig).SingleInstance();
            var container = builder.Build();

            // Read the topics and register.
            var reader = container.Resolve<ITopicReader>();
            var topics = reader.Read(appDataPath.CombineWithFilePath("docs.xml"));

            // Read all blog entries.
            var blogReader = container.Resolve<IBlogReader>();
            var blogIndex = blogReader.Parse(appDataPath.Combine("blog"));

            // Update the container.
            builder = new ContainerBuilder();
            builder.RegisterInstance(topics).As<TopicTree>().SingleInstance();
            builder.RegisterInstance(blogIndex).As<BlogIndex>().SingleInstance();
            builder.RegisterInstance(addins).As<AddinIndex>().SingleInstance();
            builder.Update(container);

            // Perform registrations.
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
Ejemplo n.º 33
0
        private DirectoryPath InstallPackage(PackageDefinition package, DirectoryPath root)
        {
            var packagePath = root.Combine("libs");
            if (!_fileSystem.Exist(packagePath))
            {
                _fileSystem.GetDirectory(packagePath).Create();
            }
            var toolsPath = root.Combine("tools");
            var nugetToolPath = toolsPath.CombineWithFilePath("nuget.exe");
            if (!_fileSystem.Exist(toolsPath))
            {
                _fileSystem.GetDirectory(toolsPath).Create();
            }
            if (!_fileSystem.Exist(nugetToolPath))
            {
                DownloadNuget(nugetToolPath);
            }

            if (_fileSystem.Exist(packagePath.Combine(package.PackageName)))
            {
                return packagePath.Combine(package.PackageName);
            }

            var arguments = $"install \"{package.PackageName}\" -Source \"https://api.nuget.org/v3/index.json\" -PreRelease -ExcludeVersion -OutputDirectory \"{packagePath.FullPath}\"{(!string.IsNullOrWhiteSpace(package.Version) ? $" -Version \"{package.Version}\"" : string.Empty)}";
            var fallbackarguments = $"install \"{package.PackageName}\" -Source \"https://api.nuget.org/v3/index.json\" -Source \"https://www.myget.org/F/xunit/api/v3/index.json\" -Source \"https://dotnet.myget.org/F/dotnet-core/api/v3/index.json\" -Source \"https://dotnet.myget.org/F/cli-deps/api/v3/index.json\" -PreRelease -ExcludeVersion -OutputDirectory \"{packagePath.FullPath}\"{(!string.IsNullOrWhiteSpace(package.Version) ? $" -Version \"{package.Version}\"" : string.Empty)}";

            ExecuteNuget(nugetToolPath, arguments, fallbackarguments, 3);

            // Return the installation directory.
            return packagePath.Combine(package.PackageName);
        }