File tree Expand file tree Collapse file tree 4 files changed +39
-10
lines changed Expand file tree Collapse file tree 4 files changed +39
-10
lines changed Original file line number Diff line number Diff line change 421421 {
422422 "command" : " dotnet.restore" ,
423423 "title" : " Restore Packages" ,
424- "category" : " dotnet "
424+ "category" : " .NET "
425425 },
426426 {
427427 "command" : " csharp.downloadDebugger" ,
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ export class AssetGenerator {
9595 this . hasProject = true ;
9696 this . projectPath = path . dirname ( targetMSBuildProject . Path ) ;
9797 this . projectFilePath = targetMSBuildProject . Path ;
98- this . targetFramework = findNetCoreAppTargetFramework ( targetMSBuildProject ) . ShortName ;
98+ this . targetFramework = protocol . findNetCoreAppTargetFramework ( targetMSBuildProject ) . ShortName ;
9999 this . executableName = targetMSBuildProject . AssemblyName + ".dll" ;
100100 this . configurationName = configurationName ;
101101 return ;
@@ -284,15 +284,11 @@ export class AssetGenerator {
284284 }
285285}
286286
287- function findNetCoreAppTargetFramework ( project : protocol . MSBuildProject ) : protocol . TargetFramework {
288- return project . TargetFrameworks . find ( tf => tf . ShortName . startsWith ( 'netcoreapp' ) ) ;
289- }
290-
291287function findExecutableMSBuildProjects ( projects : protocol . MSBuildProject [ ] ) {
292288 let result : protocol . MSBuildProject [ ] = [ ] ;
293289
294290 projects . forEach ( project => {
295- if ( project . IsExe && findNetCoreAppTargetFramework ( project ) !== undefined ) {
291+ if ( project . IsExe && protocol . findNetCoreAppTargetFramework ( project ) !== undefined ) {
296292 result . push ( project ) ;
297293 }
298294 } ) ;
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ interface Command {
8383 execute ( ) : Thenable < any > ;
8484}
8585
86- function projectsToCommands ( projects : protocol . DotNetProject [ ] ) : Promise < Command > [ ] {
86+ function projectsToCommands ( projects : protocol . ProjectDescriptor [ ] ) : Promise < Command > [ ] {
8787 return projects . map ( project => {
8888 let projectDirectory = project . Path ;
8989
@@ -117,11 +117,13 @@ export function dotnetRestoreAllProjects(server: OmniSharpServer) {
117117
118118 return serverUtils . requestWorkspaceInformation ( server ) . then ( info => {
119119
120- if ( ! info . DotNet || info . DotNet . Projects . length < 1 ) {
120+ let projectDescriptors = protocol . getDotNetCoreProjectDescriptors ( info ) ;
121+
122+ if ( projectDescriptors . length === 0 ) {
121123 return Promise . reject ( "No .NET Core projects found" ) ;
122124 }
123125
124- let commandPromises = projectsToCommands ( info . DotNet . Projects ) ;
126+ let commandPromises = projectsToCommands ( projectDescriptors ) ;
125127
126128 return Promise . all ( commandPromises ) . then ( commands => {
127129 return vscode . window . showQuickPick ( commands ) ;
Original file line number Diff line number Diff line change 55
66'use strict' ;
77
8+ import * as path from 'path' ;
9+
810export module Requests {
911 export const AddToProject = '/addtoproject' ;
1012 export const AutoComplete = '/autocomplete' ;
@@ -509,4 +511,33 @@ export namespace V2 {
509511 Failure : string ;
510512 Pass : boolean ;
511513 }
514+ }
515+
516+ export function findNetCoreAppTargetFramework ( project : MSBuildProject ) : TargetFramework {
517+ return project . TargetFrameworks . find ( tf => tf . ShortName . startsWith ( 'netcoreapp' ) ) ;
518+ }
519+
520+ export interface ProjectDescriptor {
521+ Name : string ;
522+ Path : string ;
523+ }
524+
525+ export function getDotNetCoreProjectDescriptors ( info : WorkspaceInformationResponse ) : ProjectDescriptor [ ] {
526+ let result = [ ] ;
527+
528+ if ( info . DotNet && info . DotNet . Projects . length > 0 ) {
529+ for ( let project of info . DotNet . Projects ) {
530+ result . push ( { Name : project . Name , Path : project . Path } ) ;
531+ }
532+ }
533+
534+ if ( info . MsBuild && info . MsBuild . Projects . length > 0 ) {
535+ for ( let project of info . MsBuild . Projects ) {
536+ if ( findNetCoreAppTargetFramework ( project ) !== undefined ) {
537+ result . push ( { Name : path . basename ( project . Path ) , Path : project . Path } ) ;
538+ }
539+ }
540+ }
541+
542+ return result ;
512543}
You can’t perform that action at this time.
0 commit comments