@@ -128,35 +128,39 @@ export class AssetGenerator {
128128 public hasWebServerDependency ( ) : boolean {
129129 // TODO: Update to handle .NET Core projects.
130130
131- if ( ! this . projectFilePath || path . extname ( this . projectFilePath ) !== 'json' ) {
131+ if ( ! this . projectFilePath ) {
132132 return false ;
133133 }
134134
135- let projectJson = fs . readFileSync ( this . projectFilePath , 'utf8' ) ;
136- projectJson = projectJson . replace ( / ^ \uFEFF / , '' ) ;
135+ let projectFileText = fs . readFileSync ( this . projectFilePath , 'utf8' ) ;
136+ projectFileText = projectFileText . replace ( / ^ \uFEFF / , '' ) ;
137137
138- let projectJsonObject : any ;
138+ if ( path . basename ( this . projectFilePath ) . toLowerCase ( ) === 'project.json' ) {
139+ let projectJsonObject : any ;
139140
140- try {
141- // TODO: This error should be surfaced to the user. If the JSON can't be parsed
142- // (maybe due to a syntax error like an extra comma), the user should be notified
143- // to fix up their project.json.
144- projectJsonObject = JSON . parse ( projectJson ) ;
145- } catch ( error ) {
146- projectJsonObject = null ;
147- }
141+ try {
142+ // TODO: This error should be surfaced to the user. If the JSON can't be parsed
143+ // (maybe due to a syntax error like an extra comma), the user should be notified
144+ // to fix up their project.json.
145+ projectJsonObject = JSON . parse ( projectFileText ) ;
146+ } catch ( error ) {
147+ projectJsonObject = null ;
148+ }
148149
149- if ( projectJsonObject == null ) {
150- return false ;
151- }
150+ if ( projectJsonObject == null ) {
151+ return false ;
152+ }
152153
153- for ( let key in projectJsonObject . dependencies ) {
154- if ( key . toLowerCase ( ) . startsWith ( "microsoft.aspnetcore.server" ) ) {
155- return true ;
154+ for ( let key in projectJsonObject . dependencies ) {
155+ if ( key . toLowerCase ( ) . startsWith ( "microsoft.aspnetcore.server" ) ) {
156+ return true ;
157+ }
156158 }
157159 }
158160
159- return false ;
161+ // Assume that this is an MSBuild project. In that case, look for the 'Sdk="Microsoft.NET.Sdk.Web"' attribute.
162+ // TODO: Have OmniSharp provide the list of SDKs used by a project and check that list instead.
163+ return projectFileText . toLowerCase ( ) . indexOf ( 'sdk="microsoft.net.sdk.web"' ) >= 0 ;
160164 }
161165
162166 private computeProgramPath ( ) {
0 commit comments