hedgehogqa / fsharp-hedgehog

Release with confidence, state-of-the-art property testing for .NET.
https://hedgehogqa.github.io/fsharp-hedgehog/
Other
271 stars 31 forks source link

Can't build library #411

Closed LyndonGingerich closed 1 year ago

LyndonGingerich commented 2 years ago

I wish to learn more about the library and perhaps contribute to it, but I'm having significant difficulty getting started. I installed .NET Framework 4.5 and .NET 5.0, but I still get this stack of errors when I try to build the solution:

  Error opening binary file 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll': Stream does not support writing.
  Problem reading assembly 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\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\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll': Stream does not support writing.)
  BuildFrameworkTcImports: no successful import of C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll
  Error opening binary file 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll': Stream does not support writing.
  Problem reading assembly 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\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\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll': Stream does not support writing.)
  BuildFrameworkTcImports: no successful import of C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll
  Error opening binary file 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\net45\FSharp.Core.dll': Stream does not support writing.
  Problem reading assembly 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\net45\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\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\net45\FSharp.Core.dll': Stream does not support writing.)
  BuildFrameworkTcImports: no successful import of C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\net45\FSharp.Core.dll
  NuGet.Build.Tasks.Pack.targets(221, 5): [NU5026] The file 'C:\Users\Lyndon.G\Documents\Repos\fsharp-hedgehog\src\Hedgehog\bin\Debug\net45\Hedgehog.dll' to be packed was not found on disk.

How can I resolve this?

Could we perchance upgrade Hedgehog to .NET 6 and .NET Framework 4.8 since .NET 5 and .NET Framework 4.5 have reach EOL?

TysonMN commented 2 years ago

Does this happen when you try to build via the command line or an IDE?

LyndonGingerich commented 2 years ago

That was using an IDE. Here are the errors from building via CLI.

FSC : error FS0229: Error opening binary file 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll': Stream does not support writing. [C:\Users\Lyndon.G\Documents\Repos\fsharp-hedgehog\src\Hedgeh
og\Hedgehog.fsproj]
FSC : error FS3160: Problem reading assembly 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll': The exception has been reported. This internal exception should now be caught at an error recov
ery point on the stack. Original message: Error opening binary file 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll': Stream does not support writing.) [C:\Users\Lyndon.G\Documents\Repos\fsh
arp-hedgehog\src\Hedgehog\Hedgehog.fsproj]
error FS0073 : internal error : BuildFrameworkTcImports: no successful import of C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll [C:\Users\Lyndon.G\Documents\Repos\fsharp-hedgehog\src\Hedgeho
g\Hedgehog.fsproj]
FSC : error FS0229: Error opening binary file 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\net45\FSharp.Core.dll': Stream does not support writing. [C:\Users\Lyndon.G\Documents\Repos\fsharp-hedgehog\src\Hedgehog\Hedgeh
og.fsproj]
FSC : error FS3160: Problem reading assembly 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\net45\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\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\net45\FSharp.Core.dll': Stream does not support writing.) [C:\Users\Lyndon.G\Documents\Repos\fsharp-hedgehog\src\H
edgehog\Hedgehog.fsproj]
FSC : error FS0229: Error opening binary file 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll': Stream does not support writing. [C:\Users\Lyndon.G\Documents\Repos\fsharp-hedgehog\src\Hedgeh
og\Hedgehog.fsproj]
FSC : error FS3160: Problem reading assembly 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll': The exception has been reported. This internal exception should now be caught at an error recov
ery point on the stack. Original message: Error opening binary file 'C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll': Stream does not support writing.) [C:\Users\Lyndon.G\Documents\Repos\fsh
arp-hedgehog\src\Hedgehog\Hedgehog.fsproj]
error FS0073 : internal error : BuildFrameworkTcImports: no successful import of C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\net45\FSharp.Core.dll [C:\Users\Lyndon.G\Documents\Repos\fsharp-hedgehog\src\Hedgehog\Hedgeho
g.fsproj]
error FS0073 : internal error : BuildFrameworkTcImports: no successful import of C:\Users\Lyndon.G\.nuget\packages\fsharp.core\4.1.17\lib\netstandard1.6\FSharp.Core.dll [C:\Users\Lyndon.G\Documents\Repos\fsharp-hedgehog\src\Hedgeho
g\Hedgehog.fsproj]
moodmosaic commented 2 years ago

Thank you for reporting this. Out of curiosity, have you tried dotnet build from the command line?

LyndonGingerich commented 2 years ago

Thank you for reporting this. Out of curiosity, have you tried dotnet build from the command line?

After Tyson suggested doing so, I ran the command and published the resulting errors in my previous post.

moodmosaic commented 2 years ago

Unless @TysonMN has a better idea, this looks like something is corrupted in the .nuget cache? 😕

TysonMN commented 2 years ago

Sure. Trying deleting C:\Users\Lyndon.G\.nuget.

Also, can you figure out what command produces the output seen in this comment from dotnet and share with us your your output from that command?

If neither of those work, you could try <FSharpPreferNetFrameworkTools>false</FSharpPreferNetFrameworkTools> as suggested in that thread.

LyndonGingerich commented 2 years ago

FSharpPreferNetFrameworkTools doesn't help, assuming it's supposed to go in the fsproj PropertyGroups.

Output of dotnet sdk check:

.NET SDKs:
Version      Status
----------------------------------------
3.1.419      Up to date.
5.0.302      .NET 5.0 is out of support.
5.0.408      .NET 5.0 is out of support.
6.0.101      Patch 6.0.105 is available.
6.0.300      Up to date.

.NET Runtimes:
Name                              Version      Status
--------------------------------------------------------------------------
Microsoft.NETCore.App             3.1.23       Patch 3.1.25 is available.
Microsoft.WindowsDesktop.App      3.1.23       Patch 3.1.25 is available.
Microsoft.AspNetCore.App          3.1.25       Up to date.
Microsoft.NETCore.App             3.1.25       Up to date.
Microsoft.WindowsDesktop.App      3.1.25       Up to date.
Microsoft.AspNetCore.App          5.0.17       .NET 5.0 is out of support.
Microsoft.NETCore.App             5.0.17       .NET 5.0 is out of support.
Microsoft.WindowsDesktop.App      5.0.17       .NET 5.0 is out of support.
Microsoft.AspNetCore.App          6.0.5        Up to date.
Microsoft.NETCore.App             6.0.5        Up to date.
Microsoft.WindowsDesktop.App      6.0.5        Up to date.

I'm on Windows 10 Pro 10.0.19044.

Anything else?

TysonMN commented 2 years ago

Could we perchance upgrade Hedgehog to .NET 6 and .NET Framework 4.8 since .NET 5 and .NET Framework 4.5 have reach EOL?

I wonder if you are referring to the version of the SDK, which is used to build the code, or the target version, which sets a lower bound on the version of the runtime.

I don't think we need to change the target version.

For the SDK version, sure. Please create a PR that updates this line and this line to the latest SDK. Then make any changes needed to get the code to build.

However, that just changes the SDK used by the build on GitHub, so I don't think that will help you.

LyndonGingerich commented 2 years ago

@TysonMN Thank you. I understand better now. I'll do that once we get the build working on my machine.

TysonMN commented 2 years ago

How many computers can you test this on? For example, do you have a computer at home and a computer at work?

LyndonGingerich commented 2 years ago

How many computers can you test this on? For example, do you have a computer at home and a computer at work?

I have a computer at home, but even if it built on my home computer, I would be using and contributing to this library only from my work computer.

TysonMN commented 2 years ago

Sure. I was just wondering if you could test this on another computer.

TysonMN commented 1 year ago

@LyndonGingerich, if you change the targets to newer versions (like in PR https://github.com/elmish/Elmish.WPF/pull/488), can you build then?

LyndonGingerich commented 1 year ago

Changing the targets worked after I also used NuGet to upgrade FSharp.Core. Many thanks!

dharmaturtle commented 1 year ago

FWIW I got the same error ("Error opening binary file... Stream does not support writing.") when using VS 2022. This was on a freshly formatted Win10 machine. The error went away when I went down to VS 2019. This is a known issue.

Edit: Oh hah, Tyson already linked that thread.

TysonMN commented 1 year ago

Resolved by PR #416

TysonMN commented 1 year ago

First included in version 0.13.0

TysonMN commented 1 year ago

@LyndonGingerich, if you change the targets to newer versions (like in PR https://github.com/elmish/Elmish.WPF/pull/488), can you build then?

I know I suggested to copy this PR from Elmish.WPF. However, what is the advantage of multi-targeting for this library?

LyndonGingerich commented 1 year ago

What is the advantage of multi-targeting for this library?

Not knowing which targets had active users, I simply upgraded each target to a version under support if possible and removed it otherwise.

TysonMN commented 1 year ago

I am not talking about users.

Projects targeting net48 or net6.0 can depend on projects that target netstandard2.0 (.NET Standard documentation).

A project targeting any version of .NET (Core) can depend on a project that targets netstandard2.0.

I think you were too aggressive when you replaced net45 with net48. The most conservative change would be to replace with net462, the oldest version of .NET Framework that had not reached end of life (except for 3.5). But even a project targeting net462 can depends on a project that targets netstandard2.0.

In conclusion, we can just target netstandard2.0 while maintaining the current applicability.

TysonMN commented 1 year ago

Can you make a PR with that simplification?

TysonMN commented 1 year ago

I think we could target .NET Standard 1.6 (since we were before), but this is not recommended.

We don't recommend targeting .NET Standard 1.x, as you'd limit the available feature set for a minimal increase in reach. [...] Use netstandard2.0 to share code between .NET Framework and all other implementations of .NET.

https://docs.microsoft.com/en-us/dotnet/standard/net-standard

LyndonGingerich commented 1 year ago

@TysonMN If I understand correctly, you would like all projects to target netstandard2.0 (not netstandard2.1) alone, including those currently targeting only net6.0. Is this correct?

TysonMN commented 1 year ago

Only the Hedgehog project