Skip to content

Builds against target framework net35/net40 fail with the VS16.5 update -- Cannot read or write file Fsharp.Core.dll #8739

Closed

Description

@SteveGilham

Builds of F# projects against target framework net35 fail with the VS16.5 update. This happens with both old-style long-form projects or the new lightweight ones.

Repro steps

The simplest repro is

  1. dotnet new classlib -lang F#
  2. edit project as follows to target .Net Framework 3.5
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net35</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Library.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Update="FSharp.Core" Version="3.0.2" />
  </ItemGroup>

</Project>
  1. dotnet restore
  2. msbuild [project]

Expected behavior

Trivial compilation just works

Actual behavior

"C:\Users\steve\Documents\scratch\scratch.fsproj" (default target) (1) ->
(CoreCompile target) ->
  FSC : error FS0229: Error opening binary file 'C:\Users\steve\.nuget\packages\fsharp.core\3.0.2\lib\net35\FSharp.Core .dll': Cannot read or write file [C:\Users\steve\Documents\sscratch\scratch.fsproj]
  FSC : error FS3160: Problem reading assembly 'C:\Users\steve\.nuget\packages\fsharp.core\3.0.2\lib\net35\FSharp.Core. dll': The exception has been reported. This internal exception should now be caught at an error recovery point on the stack. Original message: Error opening binary file 'C:\Users\steve\.nuget\packages\fsharp.core\3.0.2\lib\net35\FSharp.Co re.dll': Cannot read or write file) [C:\Users\steve\Documents\scratch\scratch.fsproj]
  error FS0073 : internal error : BuildFrameworkTcImports: no successful import of C:\Users\steve\.nuget\packages\fshar p.core\3.0.2\lib\net35\FSharp.Core.dll [C:\Users\steve\Documents\scratch\scratch.fsproj]

Known workarounds

Using an older compiler version

Related information

Windows 10 Home build 1909
Visual Studio 16.5

Activity

  1. changed the title [-]Builds against target framework net35 fail with the VS16.5 update -- Cannot read or write file FsharpCore.dll[/-] [+]Builds against target framework net35 fail with the VS16.5 update -- Cannot read or write file Fsharp.Core.dll[/+] on Mar 18, 2020
  2. changed the title [-]Builds against target framework net35 fail with the VS16.5 update -- Cannot read or write file Fsharp.Core.dll[/-] [+]Builds against target framework net35/net40 fail with the VS16.5 update -- Cannot read or write file Fsharp.Core.dll[/+] on Mar 18, 2020
  3. SteveGilham commented on Mar 18, 2020

    @SteveGilham
    Author

    Also failing in similar style
    net35 and fsharp.core 4.1.18
    net40 and 4.1.18
    and net4x and 3.0.2

  4. SteveGilham commented on Mar 18, 2020

    @SteveGilham
    Author

    Using Microsoft.NETFramework.ReferenceAssemblies.net20, the issue can be reproduced in a pure dotnet build context

    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <TargetFramework>net20</TargetFramework>
      </PropertyGroup>
    
      <ItemGroup>
        <Compile Include="Library.fs" />
      </ItemGroup>
    
      <ItemGroup>
        <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net20" Version="1.0.0">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
      </ItemGroup>
    
      <ItemGroup>
        <PackageReference Update="FSharp.Core" Version="4.1.18" />
      </ItemGroup>
    
    </Project>
    
  5. TIHan commented on Mar 18, 2020

    @TIHan
    Contributor

    Thank you for reporting this. This looks to be a regression and will make this the highest priority.

  6. added
    Impact-High
    on Mar 18, 2020
  7. added this to the 16.5 milestone on Mar 19, 2020
  8. inosik commented on Mar 19, 2020

    @inosik

    Same with FSharp.Core 4.0.0.1.

  9. macdonald-keith-vmware commented on Mar 23, 2020

    @macdonald-keith-vmware

    and same with FSharp.Core.4.0.0.0
    but I'm sure you knew that... :)

  10. cartermp commented on Mar 23, 2020

    @cartermp
    Contributor

    Just to update folks on this - the fix is already deployed in master and will be released in the VS 16.6 release. We're currently going through the process of getting a backport of that fix into a servicing release of 16.5. If any folks here who were affects (@SteveGilham @inosik @macdonald-keith-vmware) have time to verify if it works/fails on the 16.6 preview, that would be appreciated.

    Just to set expectations, servicing a release carries a high bar. The more servicing fixes we take, the higher the risk of accidentally breaking something else in an otherwise stable release. We're currently going through the approval process and we'll report back on the outcome of that.

  11. SteveGilham commented on Mar 24, 2020

    @SteveGilham
    Author

    I've installed VS2019 16.6 preview 1.0 and reset my work to the point where I spotted the issue.

    • v16.5 -- fails as reported
    • v16.6 preview 1.0 -- SUCCESS
  12. Tener commented on Mar 24, 2020

    @Tener

    Is there a workaround that can be applied to make it work with v16.5 so that one can avoid having to install v16.6 preview 1.0?

  13. 3 remaining items

  14. Tener commented on Mar 24, 2020

    @Tener

    Thanks @SteveGilham, looks very simple. VS2019 crashes a lot less for me than VS2017 so this is really valuable thing.
    @cartermp really good news about the service release.

  15. cartermp commented on Mar 24, 2020

    @cartermp
    Contributor

    @Tener sorry to hear about crashes. Would you mind filing an issue so we can look into it? We've been addressing various VS perf problems for a while now, but we'd love to see what we can do to help more. We've got some more coming down the pipeline, too, but only a few test cases we've been using to test it out with.

    Also happy to chat over email (phcart at microsoft dot com) if it involves more sensitive info about the codebase. I'm subject to an NDA when communicating over email. We've done a few engagements with folks before including looking directly at build logs and helping with suggestions that can make their lives a lot better while fixes are being developed.

  16. Tener commented on Mar 25, 2020

    @Tener

    @cartermp I was thinking about filing an issue but first wanted to check how things are with the latest fixes. Happy to share more details over email, I'll reach out soon. I was able to apply workaround from @SteveGilham - the projects now compile - but it looks like Intellisense is still disabled (no type information, go to definition does not work etc.). I assumed this was caused by the same underlying problem but now I'm not completely sure. I'll see if I can install the preview to test this.

  17. cartermp commented on Mar 25, 2020

    @cartermp
    Contributor

    @Tener thanks for reaching out over mail. re: the workaround - this does allow for compilation, but that package does indeed disable intellisense since it's not using the actual compiler/language service that VS ships with. So it's a quick workaround in the short term but not something to use beyond unblocking compilation.

  18. cartermp commented on Mar 26, 2020

    @cartermp
    Contributor

    Sorry for an additional delay here, folks. The chain of insertions has made this risky to get in for the 16.5.2 patch:

    • F# compiler and tools --> VS
    • F# coreclr compiler --> .NET SDK --> new SDK servicing release --> VS

    The latter is too risky to do for the 16.5.2 release since the SDK patch for 16.5.2 has already been inserted and can't rev yet. So we're bouncing this out to the 16.5.3 patch which will be April 7th or so. Until then, VS preview does have the fix and should be stable enough for regular use.

  19. Happypig375 commented on Mar 26, 2020

    @Happypig375
    Member

    March 7th is nearly one year later though

  20. cartermp commented on Mar 26, 2020

    @cartermp
    Contributor

    thanks

  21. SteveGilham commented on Apr 8, 2020

    @SteveGilham
    Author

    Confirming that SDK 3.1.201 and VS 16.5.3 are good.

  22. cartermp commented on Apr 8, 2020

    @cartermp
    Contributor
  23. inosik commented on Apr 27, 2020

    @inosik

    Still getting this error with SDK 3.1.201 when trying to build Hedgehog.

  24. cartermp commented on Apr 27, 2020

    @cartermp
    Contributor

    @inosik It'll be in the next rev of the SDK. The last build available that isn't a preview is from March 24th.

  25. inosik commented on Apr 28, 2020

    @inosik

    OK, I thought 3.1.201 was already patched.

  26. 0x53A commented on May 8, 2020

    @0x53A
    Contributor

    Do you have a timeline for the next SDK 3.1.x release?

  27. cartermp commented on May 8, 2020

    @cartermp
    Contributor

    Nope, no timeline. It should be aligned with the VS 16.6 release though

  28. inosik commented on May 13, 2020

    @inosik

    SDK 3.1.202 seems to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugImpact-HighRegression

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions