From ff66bf95b76417d22cad4bb6fbfbb636e122b016 Mon Sep 17 00:00:00 2001 From: Adam Hartford Date: Tue, 6 Jun 2017 09:29:32 -0400 Subject: [PATCH] Fix Restore Packages when targeting .NET Framework. Issue #1507. --- src/omnisharp/protocol.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/omnisharp/protocol.ts b/src/omnisharp/protocol.ts index 86a701946..bec9ce9f8 100644 --- a/src/omnisharp/protocol.ts +++ b/src/omnisharp/protocol.ts @@ -565,6 +565,11 @@ export namespace V2 { } } +export function findNetFrameworkTargetFramework(project: MSBuildProject): TargetFramework { + let regexp = new RegExp('^net[1-4]'); + return project.TargetFrameworks.find(tf => regexp.test(tf.ShortName)); +} + export function findNetCoreAppTargetFramework(project: MSBuildProject): TargetFramework { return project.TargetFrameworks.find(tf => tf.ShortName.startsWith('netcoreapp')); } @@ -573,6 +578,12 @@ export function findNetStandardTargetFramework(project: MSBuildProject): TargetF return project.TargetFrameworks.find(tf => tf.ShortName.startsWith('netstandard')); } +export function isDotNetCoreProject(project: MSBuildProject): Boolean { + return findNetCoreAppTargetFramework(project) !== undefined || + findNetStandardTargetFramework(project) !== undefined || + findNetFrameworkTargetFramework(project) !== undefined; +} + export interface ProjectDescriptor { Name: string; Directory: string; @@ -594,8 +605,7 @@ export function getDotNetCoreProjectDescriptors(info: WorkspaceInformationRespon if (info.MsBuild && info.MsBuild.Projects.length > 0) { for (let project of info.MsBuild.Projects) { - if (findNetCoreAppTargetFramework(project) !== undefined || - findNetStandardTargetFramework(project) !== undefined) { + if (isDotNetCoreProject(project)) { result.push({ Name: path.basename(project.Path), Directory: path.dirname(project.Path),