Fixes #735 - "Running" forever for folder with multiple .NET Core projects
This commit is contained in:
Dustin Campbell 2016-09-13 15:28:06 -07:00 коммит произвёл GitHub
Родитель 716f2f5df6 a060446308
Коммит fbbf5a13ee
4 изменённых файлов: 18582 добавлений и 28 удалений

Просмотреть файл

@ -30,6 +30,7 @@
"fs-extra-promise": "^0.3.1",
"http-proxy-agent": "^1.0.0",
"https-proxy-agent": "^1.0.0",
"lodash": "^4.15.0",
"open": "*",
"semver": "*",
"tmp": "0.0.28",
@ -691,4 +692,4 @@
}
]
}
}
}

Просмотреть файл

@ -11,7 +11,7 @@ import * as vscode from 'vscode';
import * as tasks from 'vscode-tasks';
import {OmnisharpServer} from './omnisharp/server';
import * as serverUtils from './omnisharp/utils';
import * as protocol from './omnisharp/protocol.ts'
import * as protocol from './omnisharp/protocol'
interface DebugConfiguration {
name: string,
@ -60,7 +60,7 @@ interface Paths {
function getPaths(): Paths {
const vscodeFolder = path.join(vscode.workspace.rootPath, '.vscode');
return {
vscodeFolder: vscodeFolder,
tasksJsonPath: path.join(vscodeFolder, 'tasks.json'),
@ -83,7 +83,7 @@ function hasOperations(operations: Operations) {
function getOperations() {
const paths = getPaths();
return getBuildOperations(paths.tasksJsonPath).then(operations =>
return getBuildOperations(paths.tasksJsonPath).then(operations =>
getLaunchOperations(paths.launchJsonPath, operations));
}
@ -95,7 +95,7 @@ function getBuildOperations(tasksJsonPath: string) {
const text = buffer.toString();
const tasksJson: tasks.TaskConfiguration = JSON.parse(text);
const buildTask = tasksJson.tasks.find(td => td.taskName === 'build');
resolve({ updateTasksJson: (buildTask === undefined) });
});
}
@ -123,7 +123,7 @@ function getLaunchOperations(launchJsonPath: string, operations: Operations) {
function promptToAddAssets() {
return new Promise<boolean>((resolve, reject) => {
const item = { title: 'Yes' }
vscode.window.showInformationMessage('Required assets to build and debug are missing from your project. Add them?', item).then(selection => {
return selection
? resolve(true)
@ -139,7 +139,7 @@ function computeProgramPath(projectData: TargetProjectData) {
}
let result = '${workspaceRoot}';
if (projectData.projectPath) {
result = path.join(result, path.relative(vscode.workspace.rootPath, projectData.projectPath.fsPath));
}
@ -258,10 +258,10 @@ function addTasksJsonIfNecessary(projectData: TargetProjectData, paths: Paths, o
if (!operations.addTasksJson) {
return resolve();
}
const tasksJson = createTasksConfiguration(projectData);
const tasksJsonText = JSON.stringify(tasksJson, null, ' ');
return fs.writeFileAsync(paths.tasksJsonPath, tasksJsonText);
});
}
@ -341,13 +341,13 @@ function hasWebServerDependency(targetProjectData: TargetProjectData): boolean {
if (projectJsonObject == null) {
return false;
}
for (var key in projectJsonObject.dependencies) {
if (key.toLowerCase().startsWith("microsoft.aspnetcore.server")) {
return true;
}
}
return false;
}
@ -360,7 +360,7 @@ function addLaunchJsonIfNecessary(projectData: TargetProjectData, paths: Paths,
const isWebProject = hasWebServerDependency(projectData);
const launchJson = createLaunchJson(projectData, isWebProject);
const launchJsonText = JSON.stringify(launchJson, null, ' ');
return fs.writeFileAsync(paths.launchJsonPath, launchJsonText);
});
}
@ -369,7 +369,7 @@ export function addAssetsIfNecessary(server: OmnisharpServer) {
if (!vscode.workspace.rootPath) {
return;
}
return serverUtils.requestWorkspaceInformation(server).then(info => {
// If there are no .NET Core projects, we won't bother offering to add assets.
if ('DotNet' in info && info.DotNet.Projects.length > 0) {
@ -377,15 +377,15 @@ export function addAssetsIfNecessary(server: OmnisharpServer) {
if (!hasOperations(operations)) {
return;
}
promptToAddAssets().then(addAssets => {
if (!addAssets) {
return;
}
const data = findTargetProjectData(info.DotNet.Projects);
const paths = getPaths();
return fs.ensureDirAsync(paths.vscodeFolder).then(() => {
return Promise.all([
addTasksJsonIfNecessary(data, paths, operations),

Просмотреть файл

@ -10,6 +10,7 @@ import {dotnetRestoreForProject} from './commands';
import {basename} from 'path';
import * as protocol from '../omnisharp/protocol';
import * as serverUtils from '../omnisharp/utils';
import {debounce} from 'lodash';
export default function reportStatus(server: OmnisharpServer) {
return vscode.Disposable.from(
@ -42,6 +43,7 @@ class Status {
export function reportDocumentStatus(server: OmnisharpServer): vscode.Disposable {
let disposables: vscode.Disposable[] = [];
let localDisposables: vscode.Disposable[];
let entry = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, Number.MIN_VALUE);
let defaultStatus = new Status(defaultSelector);
@ -107,44 +109,48 @@ export function reportDocumentStatus(server: OmnisharpServer): vscode.Disposable
disposables.push(server.onServerStop(() => {
projectStatus = undefined;
defaultStatus.text = undefined;
vscode.Disposable.from(...localDisposables).dispose();
localDisposables = undefined;
}));
disposables.push(server.onServerStart(path => {
localDisposables = [];
defaultStatus.text = '$(flame) Running';
defaultStatus.command = 'o.pickProjectAndStart';
defaultStatus.color = '';
render();
function updateProjectInfo() {
serverUtils.requestWorkspaceInformation(server).then(info => {
function updateProjectInfo() {
serverUtils.requestWorkspaceInformation(server).then(info => {
interface Project {
Path: string;
SourceFiles: string[];
}
let fileNames: vscode.DocumentSelector[] = [];
let label: string;
function addProjectFileNames(project: Project) {
fileNames.push({ pattern: project.Path });
if (project.SourceFiles) {
for (let sourceFile of project.SourceFiles) {
fileNames.push({ pattern: sourceFile });
}
}
}
function addDnxOrDotNetProjects(projects: Project[]) {
let count = 0;
for (let project of projects) {
count += 1;
addProjectFileNames(project);
}
if (!label) {
if (count === 1) {
label = basename(projects[0].Path); //workspace.getRelativePath(info.Dnx.Projects[0].Path);
@ -159,7 +165,7 @@ export function reportDocumentStatus(server: OmnisharpServer): vscode.Disposable
if (info.MsBuild && info.MsBuild.SolutionPath) {
label = basename(info.MsBuild.SolutionPath); //workspace.getRelativePath(info.MsBuild.SolutionPath);
fileNames.push({ pattern: info.MsBuild.SolutionPath });
for (let project of info.MsBuild.Projects) {
addProjectFileNames(project);
}
@ -182,9 +188,11 @@ export function reportDocumentStatus(server: OmnisharpServer): vscode.Disposable
});
}
disposables.push(server.onProjectAdded(updateProjectInfo));
disposables.push(server.onProjectChange(updateProjectInfo));
disposables.push(server.onProjectRemoved(updateProjectInfo));
// Don't allow the same request to slam the server within a "short" window
let debouncedUpdateProjectInfo = debounce(updateProjectInfo, 1500, { leading: true });
localDisposables.push(server.onProjectAdded(debouncedUpdateProjectInfo));
localDisposables.push(server.onProjectChange(debouncedUpdateProjectInfo));
localDisposables.push(server.onProjectRemoved(debouncedUpdateProjectInfo));
}));
return vscode.Disposable.from(...disposables);

18545
typings/lodash/lodash.d.ts поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу