GithubHelp home page GithubHelp logo

Comments (11)

KirillOsenkov avatar KirillOsenkov commented on June 29, 2024

it’s both, you merge into a dll or an exe

from il-repack.

Aetherinox avatar Aetherinox commented on June 29, 2024

Thanks for the reply. Am I possibly doing something wrong then?

ILRepack.exe /out:"H:\Projects\demo\bin\Release\net481\publish\demoproject.exe" /lib:"H:\Projects\demo\bin\Release\net481\publish" /out:"H:\CSharpProjects\demo\bin\Release\net481\publish\demoproject.exe" "H:\Projects\demo\bin\Release\net481\publish\System.Management.Automation.dll"

Using absolute paths is what got me results, but all I was attempting to test was integrating the Powershell automation DLL into my exe. However, after the process completes, you can't launch the exe. It actually says that the program cannot be ran by windows, almost as if it's corrupted.

The overall project has 4 DLLs, but I've just been trying to do one for now just to test with and confirm that I can still access those features within the exe after the merge is complete.

I do get an affirmative back from ILRepack

Wrote H:\Projects\demo\bin\Release\net481\publish\demoproject.exe

But then I receive:
bGaMbby

from il-repack.

KirillOsenkov avatar KirillOsenkov commented on June 29, 2024

your /out is specified twice

from il-repack.

Aetherinox avatar Aetherinox commented on June 29, 2024

Sorry, bad copy/paste from terminal. Yeah it only had one /out, just checked.

The size increases, but the file becomes corrupted.

ILRepack.exe /out:"H:\Projects\demo\bin\Release\net481\publish\demoproject.exe" /lib:"H:\Projects\demo\bin\Release\net481\publish" "H:\Projects\demo\Release\net481\publish\System.Management.Automation.dll"

Is the actual command that was ran.

Actually tried another DLL, and that time, the size of the exe dramatically went down from 200kb to 11kb. The DLL was 21KB

from il-repack.

KirillOsenkov avatar KirillOsenkov commented on June 29, 2024

oh, indeed, you can’t merge with a .NET apphost exe, it’s not a managed assembly. Merge with demoproject.dll, not demoproject.exe.

We should report an error when we detect this case.

from il-repack.

KirillOsenkov avatar KirillOsenkov commented on June 29, 2024

look into PublishSingleFile perhaps

from il-repack.

Aetherinox avatar Aetherinox commented on June 29, 2024

Thanks, I'll take a look.

I keep on .net 4.8.1 because most people have a lot of those libraries, including Powershell (the automation DLL), but I tried net8, and that powershell DLL is roughly 8MB. So I'd have to ship an 8MB file along with a 200kb exe, which just seems really odd.

I'll see what I can do with publish single file and try to play with this more.

from il-repack.

Aetherinox avatar Aetherinox commented on June 29, 2024

Just an update.

I spent 5 or so hours messing with all of this.

I was able to successfully do exactly what I wanted with the older ILMerge. The only thing of note was that the DLLs had to be merged in a certain order otherwise a series of random errors would occur, even stack exceptions.

But after running the exe on a brand new system, all the features work.

I now need to see if I can take that same process and try it with ILRepack. But I was able to do it with ILMerge just fine by building the exe and then utilizing the command-line.

I could have used SingleFilePublish on NET 8, however, that version requires more DLLs to be integrated with my program, including an 8MB Powershell DLL for me to run powershell commands. Whereas with .net 4.8.1, that automation DLL is provided with all fresh installs of Windows and is not a dependency that needs to be messed with.

So the only option to make this is the easiest, was to stick with 4.8.1, and then get ILMerge / ILRepack to integrate the libraries I did actually need.

from il-repack.

KirillOsenkov avatar KirillOsenkov commented on June 29, 2024

Keeping the issue open to issue an error when we attempt to merge a native exe/dll.

Would you mind pasting the exact command line you ended up using with ILMerge? I'm still curious if there's an actual bug in ILRepack here (other than you can't merge the apphost exe).

from il-repack.

Aetherinox avatar Aetherinox commented on June 29, 2024

Sure thing. To make it easier, I just created a batch file to run the build

SET ILMERGE_VERSION=3.0.41
SET PATH_ILMERGE=%USERPROFILE%\.nuget\packages\ilmerge\%ILMERGE_VERSION%\tools\net452

"%PATH_ILMERGE%"\ILMerge.exe bin\Publish\demoapp.exe  ^
    /lib:bin\Publish ^
    /out:bin\Publish\demoapp.exe ^
    System.Buffers.dll ^
    System.Numerics.Vectors.dll ^
    System.Memory.dll

Was relatively straight forward with ILMerge. I haven't had a lot of time lately, but I do want to go back and try again with li repack. I'd rather use the updated program and not rely on the old version.

But as long as I combine the DLLs in this order, everything works perfect.

Ran the exe on my main desktop, and also in a virtual machine to make sure everything was included, and both machines worked great with the single exe.

from il-repack.

KirillOsenkov avatar KirillOsenkov commented on June 29, 2024

Let me know if you still see issues. If there are still problems I'll need a detailed repro and the logs (/verbose /log:log.txt)

from il-repack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.