Skip to content
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

Error getting started using FSCS #424

Closed
cognociente opened this issue Sep 25, 2015 · 6 comments
Closed

Error getting started using FSCS #424

cognociente opened this issue Sep 25, 2015 · 6 comments

Comments

@cognociente
Copy link

I'm getting the following error just trying to get the provided sample working (pretty much no matter what I try):

Attempting the first sample in:
http://fsharp.github.io/FSharp.Compiler.Service/compiler.html

In a previous release a similar error could be overcome by being careful about how you reference FSharp.Core st you make sure the optdata & sigdata files are also present. This is now not having an effect on the problem.

Error

[|unknown (1,1)-(1,81) parse error Could not load file or assembly 'Microsoft.Build.Framework, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.|]

This is actually the same root error that has arisen in a downstream project (QuotationCompiler) and has me testing where the root of the problem lies.

Configuration

Visual Studio 2015
F# 4.0 (I could use F# 3.1 if need be for the interim)

Resolution

The following seems to be the only relevant item on the subject:
#337
But I am not 100% sure.

What is the best way forward?

@cognociente
Copy link
Author

Following some threads on issues on this github repo I can see that the dependency on Microsoft.Build.Framework seems to be an issue.

I have added FSharp.Compiler.Tools to my test project (via nuget). I can see that this adds a dll into packages for 'Microsoft.Build.Framework' and that this in the "12.0" range. Unfortunately adding this as a reference in the project does not change the error given.

The error is complaining when looking for a version 12.0.0.0 and the actual version in FSharp.Compiler.Tools is 12.0.40629.0 so I have then tried a binding redirect on app.config as follows:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.4.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.40629.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

I really thought this would work...but it didn't!

Please help.

ASIDE ONE I looked through the dependencies of FSharp.Compiler.Services from the paket file on github and could find no mention of the MSBUILD dependencies. I was just trying to trace the precise version of Microsoft.Build.Framework.dll that I would need. Why?

ASIDE TWO it seems that my machine does not have the version 12.0.x.x of the Microsoft.Build series on the machine. I would imagine that this is because I have VS2015 loaded and have never had VS2013 installed. The thing is, if FSCS is now directed at F# 4.0 (which is kinda equivalent to VS2015) then why have the current version 1.4.x.x+ depend on those outdated assemblies. Just asking to test my own understanding of this dependency soup.

@rneatherway
Copy link
Member

The dependency is there for the project cracking facility. I think we have agreed that the best approach here is to move this out of process, and this other assembly would then take the dependency and handle loading the best MSBuild version available. I have done this for FsAutoComplete, but haven't had time to port it over. In the meantime, have you tried instead redirecting to the 14.0.0.0 version you have installed with VS2015?

@cognociente
Copy link
Author

Was pretty sure that was one of the permutations I tried but I tried it again anyway.

(0) FSCS latest version from Nuget

(1) I referenced version 14.0.23107.0 located at "C:\Program Files (x86)\Reference Assemblies\Microsoft\MSBuild\v14.0"

(2) I adjusted my app.config file as follows:

      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-12.0.40628.0" newVersion="14.0.23107.0" />
        <publisherPolicy apply="no" />
      </dependentAssembly>

I still receive the following run-time error:

[|unknown (1,1)-(1,81) parse error Could not load file or assembly 'Microsoft.Build.Framework, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.|]

It appears "hard-wired" to look for a particular version and no other?! Unfortunately, FSCS is unusable for me at present.

@rneatherway
Copy link
Member

@cognociente I have never used the build numbers in binding redirects, I would suggest just using:

<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="14.0.0.0" />

If that still doesn't work, there are three other options:

  1. Install MSBuild v12: http://www.microsoft.com/en-us/download/details.aspx?id=40760
  2. Add an assembly resolution failure handler to your application. You can just copy and paste from my code: https://github.com/fsharp/FsAutoComplete/blob/master/FsAutoComplete/CompilerServiceInterface.fs#L162
  3. Submit a PR to FCS to remove the hard-wired v12 dependency by moving the project cracking out of process. This would then use a method similar to (2) in a separate console application. I can help review and test such a PR.

@cognociente
Copy link
Author

@rneatherway I tried to adjust app.config to not use the build numbers but it didn't work. Then tried copying your code in (2) above and calling it prior to the compile step... SUCCESS!! Thanks.

@rneatherway
Copy link
Member

I'm glad it works now, but it isn't a long-term solution. I'll see if I can find time for that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants