Merge pull request #754 from eamodio/bug-#735
Fixes #735 - "Running" forever for folder with multiple .NET Core projects
This commit is contained in:
Коммит
fbbf5a13ee
|
@ -30,6 +30,7 @@
|
||||||
"fs-extra-promise": "^0.3.1",
|
"fs-extra-promise": "^0.3.1",
|
||||||
"http-proxy-agent": "^1.0.0",
|
"http-proxy-agent": "^1.0.0",
|
||||||
"https-proxy-agent": "^1.0.0",
|
"https-proxy-agent": "^1.0.0",
|
||||||
|
"lodash": "^4.15.0",
|
||||||
"open": "*",
|
"open": "*",
|
||||||
"semver": "*",
|
"semver": "*",
|
||||||
"tmp": "0.0.28",
|
"tmp": "0.0.28",
|
||||||
|
@ -691,4 +692,4 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import * as vscode from 'vscode';
|
||||||
import * as tasks from 'vscode-tasks';
|
import * as tasks from 'vscode-tasks';
|
||||||
import {OmnisharpServer} from './omnisharp/server';
|
import {OmnisharpServer} from './omnisharp/server';
|
||||||
import * as serverUtils from './omnisharp/utils';
|
import * as serverUtils from './omnisharp/utils';
|
||||||
import * as protocol from './omnisharp/protocol.ts'
|
import * as protocol from './omnisharp/protocol'
|
||||||
|
|
||||||
interface DebugConfiguration {
|
interface DebugConfiguration {
|
||||||
name: string,
|
name: string,
|
||||||
|
@ -60,7 +60,7 @@ interface Paths {
|
||||||
|
|
||||||
function getPaths(): Paths {
|
function getPaths(): Paths {
|
||||||
const vscodeFolder = path.join(vscode.workspace.rootPath, '.vscode');
|
const vscodeFolder = path.join(vscode.workspace.rootPath, '.vscode');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
vscodeFolder: vscodeFolder,
|
vscodeFolder: vscodeFolder,
|
||||||
tasksJsonPath: path.join(vscodeFolder, 'tasks.json'),
|
tasksJsonPath: path.join(vscodeFolder, 'tasks.json'),
|
||||||
|
@ -83,7 +83,7 @@ function hasOperations(operations: Operations) {
|
||||||
function getOperations() {
|
function getOperations() {
|
||||||
const paths = getPaths();
|
const paths = getPaths();
|
||||||
|
|
||||||
return getBuildOperations(paths.tasksJsonPath).then(operations =>
|
return getBuildOperations(paths.tasksJsonPath).then(operations =>
|
||||||
getLaunchOperations(paths.launchJsonPath, operations));
|
getLaunchOperations(paths.launchJsonPath, operations));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ function getBuildOperations(tasksJsonPath: string) {
|
||||||
const text = buffer.toString();
|
const text = buffer.toString();
|
||||||
const tasksJson: tasks.TaskConfiguration = JSON.parse(text);
|
const tasksJson: tasks.TaskConfiguration = JSON.parse(text);
|
||||||
const buildTask = tasksJson.tasks.find(td => td.taskName === 'build');
|
const buildTask = tasksJson.tasks.find(td => td.taskName === 'build');
|
||||||
|
|
||||||
resolve({ updateTasksJson: (buildTask === undefined) });
|
resolve({ updateTasksJson: (buildTask === undefined) });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ function getLaunchOperations(launchJsonPath: string, operations: Operations) {
|
||||||
function promptToAddAssets() {
|
function promptToAddAssets() {
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return new Promise<boolean>((resolve, reject) => {
|
||||||
const item = { title: 'Yes' }
|
const item = { title: 'Yes' }
|
||||||
|
|
||||||
vscode.window.showInformationMessage('Required assets to build and debug are missing from your project. Add them?', item).then(selection => {
|
vscode.window.showInformationMessage('Required assets to build and debug are missing from your project. Add them?', item).then(selection => {
|
||||||
return selection
|
return selection
|
||||||
? resolve(true)
|
? resolve(true)
|
||||||
|
@ -139,7 +139,7 @@ function computeProgramPath(projectData: TargetProjectData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = '${workspaceRoot}';
|
let result = '${workspaceRoot}';
|
||||||
|
|
||||||
if (projectData.projectPath) {
|
if (projectData.projectPath) {
|
||||||
result = path.join(result, path.relative(vscode.workspace.rootPath, projectData.projectPath.fsPath));
|
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) {
|
if (!operations.addTasksJson) {
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const tasksJson = createTasksConfiguration(projectData);
|
const tasksJson = createTasksConfiguration(projectData);
|
||||||
const tasksJsonText = JSON.stringify(tasksJson, null, ' ');
|
const tasksJsonText = JSON.stringify(tasksJson, null, ' ');
|
||||||
|
|
||||||
return fs.writeFileAsync(paths.tasksJsonPath, tasksJsonText);
|
return fs.writeFileAsync(paths.tasksJsonPath, tasksJsonText);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -341,13 +341,13 @@ function hasWebServerDependency(targetProjectData: TargetProjectData): boolean {
|
||||||
if (projectJsonObject == null) {
|
if (projectJsonObject == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var key in projectJsonObject.dependencies) {
|
for (var key in projectJsonObject.dependencies) {
|
||||||
if (key.toLowerCase().startsWith("microsoft.aspnetcore.server")) {
|
if (key.toLowerCase().startsWith("microsoft.aspnetcore.server")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ function addLaunchJsonIfNecessary(projectData: TargetProjectData, paths: Paths,
|
||||||
const isWebProject = hasWebServerDependency(projectData);
|
const isWebProject = hasWebServerDependency(projectData);
|
||||||
const launchJson = createLaunchJson(projectData, isWebProject);
|
const launchJson = createLaunchJson(projectData, isWebProject);
|
||||||
const launchJsonText = JSON.stringify(launchJson, null, ' ');
|
const launchJsonText = JSON.stringify(launchJson, null, ' ');
|
||||||
|
|
||||||
return fs.writeFileAsync(paths.launchJsonPath, launchJsonText);
|
return fs.writeFileAsync(paths.launchJsonPath, launchJsonText);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ export function addAssetsIfNecessary(server: OmnisharpServer) {
|
||||||
if (!vscode.workspace.rootPath) {
|
if (!vscode.workspace.rootPath) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return serverUtils.requestWorkspaceInformation(server).then(info => {
|
return serverUtils.requestWorkspaceInformation(server).then(info => {
|
||||||
// If there are no .NET Core projects, we won't bother offering to add assets.
|
// If there are no .NET Core projects, we won't bother offering to add assets.
|
||||||
if ('DotNet' in info && info.DotNet.Projects.length > 0) {
|
if ('DotNet' in info && info.DotNet.Projects.length > 0) {
|
||||||
|
@ -377,15 +377,15 @@ export function addAssetsIfNecessary(server: OmnisharpServer) {
|
||||||
if (!hasOperations(operations)) {
|
if (!hasOperations(operations)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
promptToAddAssets().then(addAssets => {
|
promptToAddAssets().then(addAssets => {
|
||||||
if (!addAssets) {
|
if (!addAssets) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = findTargetProjectData(info.DotNet.Projects);
|
const data = findTargetProjectData(info.DotNet.Projects);
|
||||||
const paths = getPaths();
|
const paths = getPaths();
|
||||||
|
|
||||||
return fs.ensureDirAsync(paths.vscodeFolder).then(() => {
|
return fs.ensureDirAsync(paths.vscodeFolder).then(() => {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
addTasksJsonIfNecessary(data, paths, operations),
|
addTasksJsonIfNecessary(data, paths, operations),
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {dotnetRestoreForProject} from './commands';
|
||||||
import {basename} from 'path';
|
import {basename} from 'path';
|
||||||
import * as protocol from '../omnisharp/protocol';
|
import * as protocol from '../omnisharp/protocol';
|
||||||
import * as serverUtils from '../omnisharp/utils';
|
import * as serverUtils from '../omnisharp/utils';
|
||||||
|
import {debounce} from 'lodash';
|
||||||
|
|
||||||
export default function reportStatus(server: OmnisharpServer) {
|
export default function reportStatus(server: OmnisharpServer) {
|
||||||
return vscode.Disposable.from(
|
return vscode.Disposable.from(
|
||||||
|
@ -42,6 +43,7 @@ class Status {
|
||||||
export function reportDocumentStatus(server: OmnisharpServer): vscode.Disposable {
|
export function reportDocumentStatus(server: OmnisharpServer): vscode.Disposable {
|
||||||
|
|
||||||
let disposables: vscode.Disposable[] = [];
|
let disposables: vscode.Disposable[] = [];
|
||||||
|
let localDisposables: vscode.Disposable[];
|
||||||
|
|
||||||
let entry = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, Number.MIN_VALUE);
|
let entry = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, Number.MIN_VALUE);
|
||||||
let defaultStatus = new Status(defaultSelector);
|
let defaultStatus = new Status(defaultSelector);
|
||||||
|
@ -107,44 +109,48 @@ export function reportDocumentStatus(server: OmnisharpServer): vscode.Disposable
|
||||||
disposables.push(server.onServerStop(() => {
|
disposables.push(server.onServerStop(() => {
|
||||||
projectStatus = undefined;
|
projectStatus = undefined;
|
||||||
defaultStatus.text = undefined;
|
defaultStatus.text = undefined;
|
||||||
|
|
||||||
|
vscode.Disposable.from(...localDisposables).dispose();
|
||||||
|
localDisposables = undefined;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
disposables.push(server.onServerStart(path => {
|
disposables.push(server.onServerStart(path => {
|
||||||
|
localDisposables = [];
|
||||||
|
|
||||||
defaultStatus.text = '$(flame) Running';
|
defaultStatus.text = '$(flame) Running';
|
||||||
defaultStatus.command = 'o.pickProjectAndStart';
|
defaultStatus.command = 'o.pickProjectAndStart';
|
||||||
defaultStatus.color = '';
|
defaultStatus.color = '';
|
||||||
render();
|
render();
|
||||||
|
|
||||||
function updateProjectInfo() {
|
function updateProjectInfo() {
|
||||||
serverUtils.requestWorkspaceInformation(server).then(info => {
|
serverUtils.requestWorkspaceInformation(server).then(info => {
|
||||||
|
|
||||||
interface Project {
|
interface Project {
|
||||||
Path: string;
|
Path: string;
|
||||||
SourceFiles: string[];
|
SourceFiles: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
let fileNames: vscode.DocumentSelector[] = [];
|
let fileNames: vscode.DocumentSelector[] = [];
|
||||||
let label: string;
|
let label: string;
|
||||||
|
|
||||||
function addProjectFileNames(project: Project) {
|
function addProjectFileNames(project: Project) {
|
||||||
fileNames.push({ pattern: project.Path });
|
fileNames.push({ pattern: project.Path });
|
||||||
|
|
||||||
if (project.SourceFiles) {
|
if (project.SourceFiles) {
|
||||||
for (let sourceFile of project.SourceFiles) {
|
for (let sourceFile of project.SourceFiles) {
|
||||||
fileNames.push({ pattern: sourceFile });
|
fileNames.push({ pattern: sourceFile });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addDnxOrDotNetProjects(projects: Project[]) {
|
function addDnxOrDotNetProjects(projects: Project[]) {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
for (let project of projects) {
|
for (let project of projects) {
|
||||||
count += 1;
|
count += 1;
|
||||||
addProjectFileNames(project);
|
addProjectFileNames(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!label) {
|
if (!label) {
|
||||||
if (count === 1) {
|
if (count === 1) {
|
||||||
label = basename(projects[0].Path); //workspace.getRelativePath(info.Dnx.Projects[0].Path);
|
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) {
|
if (info.MsBuild && info.MsBuild.SolutionPath) {
|
||||||
label = basename(info.MsBuild.SolutionPath); //workspace.getRelativePath(info.MsBuild.SolutionPath);
|
label = basename(info.MsBuild.SolutionPath); //workspace.getRelativePath(info.MsBuild.SolutionPath);
|
||||||
fileNames.push({ pattern: info.MsBuild.SolutionPath });
|
fileNames.push({ pattern: info.MsBuild.SolutionPath });
|
||||||
|
|
||||||
for (let project of info.MsBuild.Projects) {
|
for (let project of info.MsBuild.Projects) {
|
||||||
addProjectFileNames(project);
|
addProjectFileNames(project);
|
||||||
}
|
}
|
||||||
|
@ -182,9 +188,11 @@ export function reportDocumentStatus(server: OmnisharpServer): vscode.Disposable
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
disposables.push(server.onProjectAdded(updateProjectInfo));
|
// Don't allow the same request to slam the server within a "short" window
|
||||||
disposables.push(server.onProjectChange(updateProjectInfo));
|
let debouncedUpdateProjectInfo = debounce(updateProjectInfo, 1500, { leading: true });
|
||||||
disposables.push(server.onProjectRemoved(updateProjectInfo));
|
localDisposables.push(server.onProjectAdded(debouncedUpdateProjectInfo));
|
||||||
|
localDisposables.push(server.onProjectChange(debouncedUpdateProjectInfo));
|
||||||
|
localDisposables.push(server.onProjectRemoved(debouncedUpdateProjectInfo));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return vscode.Disposable.from(...disposables);
|
return vscode.Disposable.from(...disposables);
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче