microsoft / MSBuildLocator

An API to locate MSBuild assemblies from an installed Visual Studio location. Use this to ensure that calling the MSBuild API will use the same toolset that a build from Visual Studio or msbuild.exe would.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MSBuildLocator.QueryVisualStudioInstances() returns zero results

MisinformedDNA opened this issue · comments

Similar to #17, MSBuildLocator.QueryVisualStudioInstances() returns zero results.

Project is targeting netcoreapp3.1 and I'm running within VS 16.8.4 (Enterprise).

Packages:

<PackageReference Include="Microsoft.Build.Locator" Version="1.4.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.8.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="3.8.0" />

NOTE: It works fine if I target net5.0.

See #92
Assuming you do not have earlier versions of VS, this is as intended. If you target an earlier runtime then grab an SDK/VS instance that expects a later runtime, it will try to use props, targets, etc. that don't exist and fail in weird and unclear ways. It would be like if I used a product that added method foo in version x, and I call foo but use an earlier version—it would have no idea what foo is.

Does that sound reasonable?

Sorry, I'm not following. MSBuildLocator targets net46;netcoreapp2.1, so why would net5.0 work and not netcoreapp3.1?

MSBuildLocator does support netcoreapp3.1, but if you want to target it, you need an MSBuild that was built with netcoreapp3.1 (or something older) in mind, or else it will try to use things netcoreapp3.1 doesn't know about. So if you have an older VS, SDK, etc., it can find those; it just won't find the 16.8 version because it's too new.

Are you able to target net5.0? If not, can you try downloading an older version of VS, say, 16.4, and checking that it finds it?

No I can target net5.0, I'm just not understanding. It's fine.