fsprojects / fsprojects/Paket

Paket Pack not working with .exe files

Open
#3,862 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
F#
Stars
2.1k
Forks
528
Avg merge
1d 12m
Merged PRs (30d)
54

Description

Description

Paket pack command fails on projects that contain a .exe, with an error like:

Paket failed with ->
C:\Users\Micael\source\repos\ConsoleApp4\ConsoleApp4\bin\Release\netcoreapp3.1\ConsoleAp>p4.exe: bad cli header, rva 0

with the full error message on verbose mode being:

Paket failed with
-> C:\Users\Micael\source\repos\ConsoleApp4\ConsoleApp4\bin\Release\netcoreapp3.1\ConsoleApp4.exe: bad cli header, rva 0
StackTrace:
at ProviderImplementation.AssemblyReader.look@1727(ILModuleReader this, Int32 v, String n, Int32 i, Int32 pos) in D:\code\Paket\paket-files\fsprojects\FSharp.TypeProviders.SDK\src\AssemblyReader.fs:line 1728
at ProviderImplementation.AssemblyReader.ILModuleReader..ctor(String infile, ByteFile is, ILGlobals ilg, Boolean lowMem) in D:\code\Paket\paket-files\fsprojects\FSharp.TypeProviders.SDK\src\AssemblyReader.fs:line 1737
at ProviderImplementation.AssemblyReader.ILModuleReaderAfterReadingAllBytes(String file, ILGlobals ilGlobals) in D:\code\Paket\paket-files\fsprojects\FSharp.TypeProviders.SDK\src\AssemblyReader.fs:line 3619
at Paket.PackageMetaData.readAssembly(String fileName) in D:\code\Paket\src\Paket.Core\Packaging\PackageMetaData.fs:line 69
at Paket.PackageProcess.merge$cont@29(String buildConfig, String buildPlatform, FSharpMap2 specificVersions, ProjectFile projectFile, TemplateFile templateFile, TemplateFile withVersion, Unit unitVar) in D:\code\Paket\src\Paket.Core\Packaging\PackageProcess.fs:line 29 at Paket.PackageProcess.convertRemainingTemplate@193.Invoke(String fileName) in D:\code\Paket\src\Paket.Core\Packaging\PackageProcess.fs:line 203 at Microsoft.FSharp.Collections.Internal.IEnumerator.map@74.DoMoveNext(b& curr) at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator1.System-Collections-IEnumerator-MoveNext()
at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeOuter@274[T,TResult](ConcatEnumerator2 x, Unit unitVar0) at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable1 source)
at Paket.PackageProcess.Pack[a](String workingDir, DependenciesFile dependenciesFile, String packageOutputPath, FSharpOption1 buildConfig, FSharpOption1 buildPlatform, FSharpOption1 version, IEnumerable1 specificVersions, FSharpOption1 releaseNotes, FSharpOption1 templateFile, FSharpOption1 excludedTemplates, Boolean lockDependencies, Boolean minimumFromLockFile, Boolean pinProjectReferences, FSharpOption1 interprojectReferencesConstraint, Boolean symbols, Boolean includeReferencedProjects, FSharpOption1 projectUrl) in D:\code\Paket\src\Paket.Core\Packaging\PackageProcess.fs:line 221 at Paket.Dependencies.Pack[b](String outputPath, FSharpOption1 buildConfig, FSharpOption1 buildPlatform, FSharpOption1 version, FSharpOption1 specificVersions, FSharpOption1 releaseNotes, FSharpOption1 templateFile, FSharpOption1 workingDir, FSharpOption1 excludedTemplates, FSharpOption1 lockDependencies, FSharpOption1 minimumFromLockFile, FSharpOption1 pinProjectReferences, FSharpOption1 interprojectReferencesConstraint, FSharpOption1 symbols, FSharpOption1 includeReferencedProjects, FSharpOption1 projectUrl) in D:\code\Paket\src\Paket.Core\PublicAPI.fs:line 753
at Paket.Program.handleCommand@853-23.Invoke(ParseResults1 results) in D:\code\Paket\src\Paket\Program.fs:line 853 at Paket.Program.processWithValidationEx$cont@42[a](Boolean silent, FSharpFunc2 commandF, a result, Unit unitVar) in D:\code\Paket\src\Paket\Program.fs:line 43
at Paket.Program.processWithValidationEx[a](FSharpFunc2 printUsage, Boolean silent, FSharpFunc2 validateF, FSharpFunc`2 commandF, a result) in D:\code\Paket\src\Paket\Program.fs:line 35
at Paket.Program.handleCommand(Boolean silent, Command command) in D:\code\Paket\src\Paket\Program.fs:line 853
at Paket.Program.main() in D:\code\Paket\src\Paket\Program.fs:line 934

For reference I tried this with a computer without a D: drive and it still showed as it trying/getting files from D:

Repro steps
  1. Create an F# console project with visual studio on windows (visual studio might not be required but windows is)

  2. Install paket on project and convert from nuget to paket

  3. Create paket.template file in the project ConsoleApp folder and add this to it
    type project

  4. Build project in Release mode.

  5. Run the following command:

dotnet paket pack nugets --version 1.0.0 -v

Alternative skip step 1 to 3 by cloning this git https://github.com/MicaelMor/PaketPackExeError

Expected behavior

Paket should create a .nupkg file on the nugets folder with the name of the project and version provided.

Actual behavior

Paket fails with error

NameOfExecutable.exe: bad cli header, rva 0

Known workarounds

Using .Net SDK command dotnet pack works, but ofc this bypasses Paket.

Other potentially relevant information

The Pack command works fine with a library type project (which ofc has no .exe file), so it is quite likely I am just doing something wrong here,

Fails also on a C# project.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the F# or C# console project and dotnet paket pack nugets --version 1.0.0 -v. Read src/Paket.Core/Packaging/PackageMetaData.fs and PackageProcess.fs, then follow the reported AssemblyReader.fs call. Done means Paket creates the expected versioned .nupkg for a project containing an .exe without the bad CLI header error.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.