dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.84k stars 666 forks source link

Only checks assemblies for first framework in TargetFrameworks #1783

Open sofam opened 6 years ago

sofam commented 6 years ago

Environment data

dotnet --info output:

.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.0.0/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

VS Code version:

1.17.0
be377c0faf7574a59f84940f593a6849f12e4de7

C# Extension version:

ms-vscode.csharp-1.12.1

Steps to reproduce

Using https://github.com/Inumedia/SlackAPI/blob/master/SlackAPI/SlackAPI.NetCore.csproj as a ProjectReference in my own project I get the following error:

[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Loading project: /Users/oel/Documents/Development/slackseNET/SlackAPI/SlackAPI/SlackAPI.NetCore.csproj
[fail]: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo
        The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

However, if I manually change the <TargetFrameworks>net45;netstandard1.6;netstandard1.3</TargetFrameworks> to <TargetFrameworks>netstandard1.6;net45;netstandard1.3</TargetFrameworks>

The assemblies load just fine.

Expected behavior

[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Found referenced project outside root directory: /Users/oel/Documents/Development/SlackAPI/SlackAPI/SlackAPI.NetCore.csproj
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Loading project: /Users/oel/Documents/Development/SlackAPI/SlackAPI/SlackAPI.NetCore.csproj
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Update project: SlackAPI.NetCore

I would expect it to try the next supported framework if the first one fails.

Actual behavior

It fails when it can't load net45.

rchande commented 6 years ago

This also seems to be fixed by @DustinCampbell's branch https://github.com/DustinCampbell/omnisharp-roslyn/tree/locate-msbuild

DustinCampbell commented 6 years ago

Sort of. I think the difference is simply that it's succeeding to find all of the target frameworks. Also, did you try this on OSX?

sofam commented 6 years ago

@DustinCampbell @rchande I am running OS X, yes.

DustinCampbell commented 6 years ago

Sorry, @sofam. I'd meant that question for @rchande.

@rchande : Did you verify on OSX?