async Task InitializeCompilationWorkspaceAsync(CancellationToken cancellationToken) { WorkingDirectory = Workbook.WorkingBasePath; if (!WorkingDirectory.DirectoryExists) { WorkingDirectory = Uri.WorkingDirectory; } if (!WorkingDirectory.DirectoryExists) { WorkingDirectory = FilePath.Empty; } if (agent.IsConnected) { await GacCache.InitializingTask; await Agent.Api.AssociateClientSession( ClientSessionAssociationKind.Initial, WorkingDirectory); CompilationWorkspace = new RoslynCompilationWorkspace( await WorkspaceConfiguration.CreateAsync( Agent, SessionKind, cancellationToken)); } await RefreshForAgentIntegration(); if (CompilationWorkspace == null) { throw new Exception("Unable to get compilation workspace for agent."); } var dependencyResolver = CompilationWorkspace.DependencyResolver; if (WorkingDirectory.DirectoryExists) { dependencyResolver.BaseDirectory = WorkingDirectory; dependencyResolver.AddAssemblySearchPath(WorkingDirectory); } Workbook.WorkingPathChanged += (o, e) => { if (dependencyResolver != null) { dependencyResolver.RemoveAssemblySearchPath(WorkingDirectory); dependencyResolver.RemoveAssemblySearchPath(e.OldBasePath); WorkingDirectory = e.NewBasePath; dependencyResolver.BaseDirectory = WorkingDirectory; dependencyResolver.AddAssemblySearchPath(WorkingDirectory); } }; PostEvent(ClientSessionEventKind.CompilationWorkspaceAvailable); }
public async Task TwoPlusTwo() { var evaluationContextManager = new EvaluationContextManager( new RepresentationManager(RepresentationManagerOptions.YieldOriginal) ); var workspaceConfiguration = await WorkspaceConfiguration .CreateAsync(evaluationContextManager); var workspaceService = await WorkspaceServiceFactory .CreateWorkspaceServiceAsync("csharp", workspaceConfiguration); var evaluationService = new EvaluationService( workspaceService,