-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FSharp.Compiler.Service dependency on MSBuild #631
Comments
I was just going to report this too - Fable, which uses FCS 6.0.2 still does not work on machine with just VS 2015 (you need to install MSBUILD 12 to be able to run it). |
There was earlier discussion about this, but apparently, this is still an issue: #337 |
Isn't msbuild used for reference resolution too, except in the case of mono which uses simple resolution. |
Yeah it's used for reference resolution. Would really like to drop the On 11 Sep 2016 7:22 p.m., "Dave Thomas" [email protected] wrote:
|
It would be great to solve this - as more and more projects use FSC and not many people use VS 2013, this is a growing issue. If we don't solve this before Progressive F# tutorials in London, I bet many people coming to Suave and Fable tutorials will be affected by this (with Suave, FSC can provide nice live-reloading experience and Fable relies on this directly). What is a minimal viable solution to make sure we do not give really crappy experience? Should I recover my PR to bundle the DLLs as part of the package? |
I wonder why its so hard to rip out, desperately need a #NO_MSBUILD flag to purge it so reference behavior is mono stylee. |
(more discussion about the earlier PR is here #338 - yes, it's not a nice solution, but I think we need some solution) |
Let's just factor the dependency into another DLL (so you can opt in to Visual F#-Tools compatible MSBuild support). |
@nightroman @tpetricek @7sharp9 @nosami See #649, please take a look over this. |
@dsyme, it looks very promising, thank you very much! This approach, with some minor adjustments on my side, should work for FSharpFar. This module supports two configuration types, .fsproj and .fs.ini. The latter is effectively just arguments of fsc and fsi in a friendly format with some helpers like environment variables expansion. As far as understand, .fs.ini scenario will be able to work without MSBuild. Developers of F# scripts for Far Manager may still use .fsproj with MSBuild / Visual Studio / VS Code. But F# scripts released for Far Manager users come with .fs.ini, so that users do not have to install MSBuild. This is exactly what I needed. |
@dsyme Thank you for looking into this!! Solving this will be fantastic. I should be able to look once I'm done with the training I'm doing over the next two days! |
@tpetricek, it would be interesting to know if it works for you. So I far I cannot make it working and I am not sure if it is my fault or not. Microsoft.Build.Framework.dll is loaded even if I opt out, if it is present, and it fails if it is not. I am trying the latest NuGet package 8.0.0 with |
@nightroman Could you submit repro steps? In particular, which tool is hosting FSHarp.Compiler.Service? |
@dsyme The tool is FSharpFar and the FCS scenarios that it uses are briefly Let me put the latest changes of FSharpFar in order and release its version Here is the summary of the used scenario. When FSharpFar is told to open an |
I am trying to investigate. Here is an interesting result. I added this brutal check and exception: FSharp.Compiler.Service\src\fsharp\SimulatedMSBuildReferenceResolver.fs(168): let internal GetBestAvailableResolver(msbuildEnabled: bool) =
if msbuildEnabled then invalidOp "unexpected msbuildEnabled" Then I ran my case with
The static initializer FSharp.Compiler.Service\src\fsharp\vs\service.fs(2721): static let globalInstance = FSharpChecker.Create() calls As a result, the available MSBuild gets loaded even though I opt out. Before I go further, I would like to know if this is by design or not. The above does not mean that it all is not working on a machine without MSBuild. |
I cannot tell exactly what is wrong on a machine without MSBuild. But according It fails in try/with here FSharp.Compiler.Service\src\fsharp\fsi\fsi.fs: /// The single, global interactive checker that can be safely used in conjunction with other operations
/// on the FsiEvaluationSession.
let checker = FSharpChecker.Create()
let (tcGlobals,frameworkTcImports,nonFrameworkResolutions,unresolvedReferences) =
try
let tcConfig = tcConfigP.Get()
checker.FrameworkImportsCache.Get tcConfig
with e ->
stopProcessingRecovery e range0; failwithf "Error creating evaluation session: %A" e I also tried to buils and test with my change of the global checker let checker = FSharpChecker.Create(msbuildEnabled = false) The result/exception is the same. Now it is getting too cryptic for me. I can make some changes in FCS, build, |
@nightroman Thanks for the update. On the first question: using the global On the second question. If you are not using the ProjectCracker, and you are using Any chance you can list repro steps? I'd be happy to dig into it to help land this cleanly. Are you using the ProjectCracker? |
@dsyme On the first question: please note that I do not use deprecated FSharpChecker.Instance. But it is always created by the FCS library itself in the static initializer of FSharpChecker. Thus MSBuild is always loaded if it is present, even if I opt out. The static initializer FSharp.Compiler.Service\src\fsharp\vs\service.fs(2721): static let globalInstance = FSharpChecker.Create() calls
No. I have the dependency but I do not call it in scenarios related to this topic. MSBuild should not be loaded in my scenarios, per my understanding of 8.0.0 and my use of msbuildEnabled = false. But it happens to be loaded. |
Ah, I see. On a machine without MSBuild this attempted load should not cause a failure since it gets caught. So some other exception is happening. Can you share the stack trace and details of the exception? |
It does not fail in Create(). As I wrote above, it fails in try/with here FSharp.Compiler.Service\src\fsharp\fsi\fsi.fs: /// The single, global interactive checker that can be safely used in conjunction with other operations
/// on the FsiEvaluationSession.
let checker = FSharpChecker.Create()
let (tcGlobals,frameworkTcImports,nonFrameworkResolutions,unresolvedReferences) =
try
let tcConfig = tcConfigP.Get()
checker.FrameworkImportsCache.Get tcConfig
with e ->
stopProcessingRecovery e range0; failwithf "Error creating evaluation session: %A" e That is all I can currently get, not much, unfortunately. |
I will remove try/with, build, and try again on my the only "clean" machine. Hopefully, we will get the stack. I am sorry that my ways to diagnose this issue are very limited. |
ok thanks |
Here is the call stack
|
One more thing. The machine does not have F# runtime installed. I provide |
So here is the best I can get, some obscure error thrown at
Please let me know how I can change something to improve diagnostics. I will be able to publish my changes for 8.0.0 only next week. Then I may explain the steps to install and repro. But a clean machine is needed, too, I presume. |
Investigated. My remaining issue was not related to MSBuild, it was about Thus, all works fine if MSBuild is not present and the issue may be closed. There is one minor imperfection though, as shown before. If MSBuild is present As far as I opt out, MSBuild is not used for resolution, hopefully, it just |
@nightroman Super, thanks. See #657 for the fix to the FSharpChecker.Create() calls. |
I think the issue is resolved completely in 9.0.0. I am closing it. Thank you! |
As far as I know, project related tools moved to FSharp.Compiler.Service.ProjectCracker. At the same time, FSharp.Compiler.Service still depends on MSBuild and cannot be loaded and used without MSBuild installed.
ILSpy shows the following references:
I wonder if this dependency is by design or not. In the latter case, it would be nice if this dependency is removed. FSharp.Compiler.Service is useful on its own without MSBuild related stuff.
The text was updated successfully, but these errors were encountered: