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

System.IO.Stream error when using SharpCompress #2702

Closed
babysnakes opened this issue Sep 10, 2022 · 7 comments
Closed

System.IO.Stream error when using SharpCompress #2702

babysnakes opened this issue Sep 10, 2022 · 7 comments

Comments

@babysnakes
Copy link

babysnakes commented Sep 10, 2022

Description

When trying to use the SharpCompress library to create tar.gz archives (It seems that the functionality was removed in Fake 5) I used the following code:

module Archives =
    open SharpCompress.Archives
    open SharpCompress.Archives.Zip
    open SharpCompress.Common
    open SharpCompress.Writers
    open System.IO

    let compressZip dirName =
        let source = buildDir @@ dirName
        let zipFile = distDir @@ $"{dirName}.zip"
        Trace.log $"Creating ZIP archive: {zipFile}"
        using (ZipArchive.Create ()) (fun archive ->
            archive.AddAllFromDirectory(source)
            archive.SaveTo(zipFile, CompressionType.Deflate)
        )

    let compressTarGzip dirName =
        let source = buildDir @@ dirName
        let tarFile = distDir @@ $"{dirName}.tar.gz"
        Trace.log $"Creating TAR archive: {tarFile}"
        let writerOptions = WriterOptions(CompressionType.GZip)
        writerOptions.LeaveStreamOpen <- true
        using (File.OpenWrite(tarFile)) (fun stream ->
            using (WriterFactory.Open(stream, ArchiveType.GZip, writerOptions)) (fun writer ->
                writer.WriteAll(buildDir, "*", SearchOption.AllDirectories)
            )
        )

(The complete script is attached as TXT file).

When running dotnet fake build -t Publish I get the following error:

pwsh  dotnet fake build -t Publish
The last restore is still up to date. Nothing left to do.
Script is not valid:
        unknown (1,0)-(1,0): Error FS0193: The module/namespace 'System.IO' from compilation unit 'System.Runtime' did not contain the namespace, module or type 'SearchOption'
        C:\Users\haim\Code\Personal\roon-tagger\build.fsx (83,12)-(83,47): Error FS1109: A reference to the type 'System.IO.SearchOption' in assembly 'System.Runtime' was found, but the type could not be found in that assembly
        unknown (1,0)-(1,0): Error FS0193: The module/namespace 'System.IO' from compilation unit 'System.Runtime' did not contain the namespace, module or type 'Stream'
        C:\Users\haim\Code\Personal\roon-tagger\build.fsx (84,12)-(84,26): Error FS1109: A reference to the type 'System.IO.Stream' in assembly 'System.Runtime' was found, but the type could not be found in that assembly
        unknown (1,0)-(1,0): Error FS0193: The module/namespace 'System.IO' from compilation unit 'System.Runtime' did not contain the namespace, module or type 'Stream'
        C:\Users\haim\Code\Personal\roon-tagger\build.fsx (94,19)-(94,78): Error FS1109: A reference to the type 'System.IO.Stream' in assembly 'System.Runtime' was found, but the type could not be found in that assembly
        C:\Users\haim\Code\Personal\roon-tagger\build.fsx (95,16)-(95,31): Error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
Performance:
 - Cli parsing: 199 milliseconds
 - Packages: 54 milliseconds
 - Script compiling: 2 seconds
 - Runtime: 3 seconds

Repro steps

I guess running build script in an empty directory will generate the same error, but it could be copied to the top of the this repository to have the required files.

Expected behavior

To run correctly and compress the files 🙂.

Actual behavior

See errors above

Known workarounds

None that I know of.

Related information

Thanks in advance (and thank you for this great library).

@babysnakes babysnakes changed the title System.IO.Stream error when using System.IO.Stream error when using SharpCompress Sep 10, 2022
@github-actions
Copy link
Contributor

Welcome to the FAKE community! Thank you so much for creating your first issue and therefore improving the project!

@babysnakes
Copy link
Author

I accidently pressed the submit button before filling out the bug. I'll update the description and notify when ready. Sorry.

@babysnakes
Copy link
Author

Ok, now the description is ready.

@yazeedobaid
Copy link
Collaborator

Can you please re-try with the latest FAKE release?

@babysnakes
Copy link
Author

Hi, thanks for the update. It might take me a few days. It seems that since the release of dotnet 7 together with the fact that I have global.json pointing at version 6 totally breaks fake and I'm getting all sort of errors. I'll try to fix them first and then I'll update regarding this issue.

@babysnakes
Copy link
Author

Sadly I can not test it at this time. Since the release of dotnet 7 (with my project global.json forces version 6) fake is completely broken for me. As long as I don't change build.fsx.lock everything is ok, but once I delete it (regardless of which version of fake I'm using) I get all sorts of warnings and errors about incompatible versions or other errors if I try to force fsharp.core version. I'll gather the info and open a ticket regarding this. Once it's solved I'll be able to test this error.

Thanks

@babysnakes
Copy link
Author

Hi,

I'm terribly sorry, I completely forgot about this issue. Only a couple of days ago I went to fix something and I was reminded about this issue 🙁.

I'm still having trouble running fake-cli with DotNet 6.0 so I converted the build.fsx to be a build project. Testing the SharpCompress library with FAKE 6 was a success and it seems to work without a problem so I'm closing the ticket.

Sorry again for the long delay ...

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