@@ -177,14 +177,25 @@ function createAttachConfiguration(): AttachConfiguration {
177177 }
178178}
179179
180- function createLaunchJson ( targetFramework : string , executableName : string ) : any {
181- return {
182- version : '0.2.0' ,
183- configurations : [
184- createLaunchConfiguration ( targetFramework , executableName ) ,
185- createWebLaunchConfiguration ( targetFramework , executableName ) ,
186- createAttachConfiguration ( )
187- ]
180+ function createLaunchJson ( targetFramework : string , executableName : string , isWebProject : boolean ) : any {
181+ let version = '0.2.0' ;
182+ if ( ! isWebProject ) {
183+ return {
184+ version : version ,
185+ configurations : [
186+ createLaunchConfiguration ( targetFramework , executableName ) ,
187+ createAttachConfiguration ( )
188+ ]
189+ }
190+ }
191+ else {
192+ return {
193+ version : version ,
194+ configurations : [
195+ createWebLaunchConfiguration ( targetFramework , executableName ) ,
196+ createAttachConfiguration ( )
197+ ]
198+ }
188199 }
189200}
190201
@@ -220,7 +231,24 @@ function addTasksJsonIfNecessary(info: protocol.DotNetWorkspaceInformation, path
220231 } ) ;
221232}
222233
223- function addLaunchJsonIfNecessary ( info : protocol . DotNetWorkspaceInformation , paths : Paths , operations : Operations ) {
234+ function hasWebServerDependency ( projectJsonPath : string ) {
235+ let projectJson = fs . readFileSync ( projectJsonPath , 'utf8' ) ;
236+ let projectJsonObject = JSON . parse ( projectJson ) ;
237+
238+ if ( projectJsonObject == null ) {
239+ return false ;
240+ }
241+
242+ for ( var key in projectJsonObject . dependencies ) {
243+ if ( key . toLowerCase ( ) . startsWith ( "microsoft.aspnetcore.server" ) ) {
244+ return true ;
245+ }
246+ }
247+
248+ return false ;
249+ }
250+
251+ function addLaunchJsonIfNecessary ( info : protocol . DotNetWorkspaceInformation , paths : Paths , operations : Operations , projectJsonPath : string ) {
224252 return new Promise < void > ( ( resolve , reject ) => {
225253 if ( ! operations . addLaunchJson ) {
226254 return resolve ( ) ;
@@ -248,7 +276,7 @@ function addLaunchJsonIfNecessary(info: protocol.DotNetWorkspaceInformation, pat
248276 }
249277 }
250278
251- const launchJson = createLaunchJson ( targetFramework , executableName ) ;
279+ const launchJson = createLaunchJson ( targetFramework , executableName , hasWebServerDependency ( projectJsonPath ) ) ;
252280 const launchJsonText = JSON . stringify ( launchJson , null , ' ' ) ;
253281
254282 return fs . writeFileAsync ( paths . launchJsonPath , launchJsonText ) ;
@@ -284,7 +312,7 @@ export function addAssetsIfNecessary(server: OmnisharpServer) {
284312 return fs . ensureDirAsync ( paths . vscodeFolder ) . then ( ( ) => {
285313 return Promise . all ( [
286314 addTasksJsonIfNecessary ( info . DotNet , paths , operations ) ,
287- addLaunchJsonIfNecessary ( info . DotNet , paths , operations )
315+ addLaunchJsonIfNecessary ( info . DotNet , paths , operations , projectJsonPath )
288316 ] ) ;
289317 } ) ;
290318 } ) ;
0 commit comments