Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 39 additions & 11 deletions src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,25 @@ function createAttachConfiguration(): AttachConfiguration {
}
}

function createLaunchJson(targetFramework: string, executableName: string): any {
return {
version: '0.2.0',
configurations: [
createLaunchConfiguration(targetFramework, executableName),
createWebLaunchConfiguration(targetFramework, executableName),
createAttachConfiguration()
]
function createLaunchJson(targetFramework: string, executableName: string, isWebProject: boolean): any {
let version = '0.2.0';
if (!isWebProject) {
return {
version: version,
configurations: [
createLaunchConfiguration(targetFramework, executableName),
createAttachConfiguration()
]
}
}
else {
return {
version: version,
configurations: [
createWebLaunchConfiguration(targetFramework, executableName),
createAttachConfiguration()
]
}
}
}

Expand Down Expand Up @@ -220,7 +231,24 @@ function addTasksJsonIfNecessary(info: protocol.DotNetWorkspaceInformation, path
});
}

function addLaunchJsonIfNecessary(info: protocol.DotNetWorkspaceInformation, paths: Paths, operations: Operations) {
function hasWebServerDependency(projectJsonPath: string) {
let projectJson = fs.readFileSync(projectJsonPath, 'utf8');
let projectJsonObject = JSON.parse(projectJson);

if (projectJsonObject == null) {
return false;
}

for (var key in projectJsonObject.dependencies) {
if (key.toLowerCase().startsWith("microsoft.aspnetcore.server")) {
return true;
}
}

return false;
}

function addLaunchJsonIfNecessary(info: protocol.DotNetWorkspaceInformation, paths: Paths, operations: Operations, projectJsonPath: string) {
return new Promise<void>((resolve, reject) => {
if (!operations.addLaunchJson) {
return resolve();
Expand Down Expand Up @@ -248,7 +276,7 @@ function addLaunchJsonIfNecessary(info: protocol.DotNetWorkspaceInformation, pat
}
}

const launchJson = createLaunchJson(targetFramework, executableName);
const launchJson = createLaunchJson(targetFramework, executableName, hasWebServerDependency(projectJsonPath));
const launchJsonText = JSON.stringify(launchJson, null, ' ');

return fs.writeFileAsync(paths.launchJsonPath, launchJsonText);
Expand Down Expand Up @@ -284,7 +312,7 @@ export function addAssetsIfNecessary(server: OmnisharpServer) {
return fs.ensureDirAsync(paths.vscodeFolder).then(() => {
return Promise.all([
addTasksJsonIfNecessary(info.DotNet, paths, operations),
addLaunchJsonIfNecessary(info.DotNet, paths, operations)
addLaunchJsonIfNecessary(info.DotNet, paths, operations, projectJsonPath)
]);
});
});
Expand Down