Fsharp: Cannot Reference .NET Standard project from F# .NET Framework project in VS

Created on 21 Feb 2017  路  17Comments  路  Source: dotnet/fsharp

Repro steps

  1. Create F# Console App targeting .NET Framework 4.6.
  2. Create .NET Standard project (C#) and retarget to .NET Standard 1.3.
  3. Attempt to add a reference to the .NET Standard project from the F# Console App.

Expected behavior

It adds the reference, since .NET Standard 1.3 is compatible with .NET Framework 4.6

Actual behavior

It cannot add the reference:

netstandard-fail

Known workarounds

None.

Related information

Running VS 2017 RC4.

Note that you can add a reference to an F# project running on .NET Framework 4.6 to a .NET Standard project just fine.

You can also perform the above repro steps to no error using C# only. So this is an issue on our end.

Severity-High bug

All 17 comments

@cartermp Looks really important - any idea where we are with this? thanks :)

I think we're at the same place we were when I first created the issue. It's likely related to lack of support for .NET Standard/.NET Core reference model in our own project system, which may mean quite a bit of work on our own project system. Since @brettfo is going to be working on F# support on the Roslyn Project system so that we can replace what we currently have, it may be best to hold off on any work here until then. This is something we'll have to make a decision on soon, though.

This is a critical issue for us as we have some portable libraries consumed by other F# portable libraries and we are considering to move these portables to .NET Standard.
Can we estimate, _among friends_, this will be supported during some time in 2017? If not we might consider rewriting those F# libraries in C#.

doesn it work from cmd line?

@OnurGumus Definitely this year. I've asked @brettfo to take a look at this and see how easy it would be to address this problem before he moves to Roslyn Project System support (where it will be fixed, just it'll take longer). We're targeting .NET Standard/.NET Core 2.0 as the release where our VS support is up to par.

@forki Yes. You can manually add the reference to a project file:

<ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj">
    <Project>{5299ee6e-7dd0-44e3-8ddc-97cf2ef8f10e}</Project>
        <Name>ClassLibrary1</Name>
</ProjectReference>

Though that puts the editor in a bad state where you can't hit enter or delete text. Your option here is to use Ionide if you must consume a C# .NET Standard project.

@cartermp Can you also use a <Reference> node directly to the DLL, rather than the project?

@dsyme Yeah, in fact that actually works best:

add-disk-dll

Editor doesn't lock up or anything.

But it won't track configuration switches.

If you are looking for a short term hack,.. then fine. However, part of the CPS / net SDK work is going to involve getting this all working and tested.

@brettfo is tasked to work on this next, now that he has done the work to get the nightly VSIXshipped OOB.

Kevin

@brettfo is tasked to work on this next, now that he has done the work to get the nightly VSIXshipped OOB

That's great news. A workaround is good, but doing it properly much better

But it won't track configuration switches.

It can track those, you need to use $(Configuration) in the path instead of hardcoding to release/debug

Also, adjusting solution build order might be required to make sure the assembly is being built before the project.

Any update on this? We are using VS2017 15.5 Preview 2 and are hitting this problem with .NET 4.7.1 trying to reference .netstandard 2.0. We can directly reference the DLLs however we seem to lose intellisense

EDIT: seems we have restored intellisense so it's still just a workaround.

@slawlor No update at the moment. We're finalizing the support for .NET Core/.NET Standard/.NET Core SDK projects for 15.5 and this will be one of the issues we look at after we land the current work.

Note that you may have issues with .NET Framework 4.7.1 and .NET Standard, mentioned here: https://github.com/dotnet/standard/issues/567

Those issues are unrelated to this issue, but might be worth knowing about.

@cartermp Thanks for the heads up. I don't think it speaks directly to our environment thankfully but it's definitely good to know of.

Still reproducible on VS 15.5.5
Console app: F# 4.1 .NET 4.7
Library: F# .NET Standard 2.0
Message: A reference to library 'Library' cannot be added. This project targets a different framework (.NETStandard) from the current project (.NETFramework).

This is fixed in 15.6.

Was this page helpful?
0 / 5 - 0 ratings