Page 1 of 1

squeeze multiple files (.dll and .xaml) into an one .exe package

Posted: Sat Jan 25, 2020 6:47 am
by Patrick9999
Hello , how can I squeeze multiple files (.dll and .xaml) into an one .exe package ?

Many thanks
Patrick

Re: squeeze multiple files (.dll and .xaml) into an one .exe package

Posted: Sat Jan 25, 2020 7:34 am
by jvierra
Place all of your files into a project. They should all be included in the EXE.

Re: squeeze multiple files (.dll and .xaml) into an one .exe package

Posted: Sat Jan 25, 2020 8:04 am
by Alexander Riedel
No they won't. Sorry James. :D
Our packager does not place external programs (dlls are in essence programs, just like exe files) and data files into a packaged executable.
There are many reasons for not doing this anymore.
If you want this for deployment purposes you would generally create an MSI file to install your applications and all associated files.
But it would help to know what it is you are trying to accomplish. Your question is a little bit too 'global'....

Re: squeeze multiple files (.dll and .xaml) into an one .exe package

Posted: Sat Jan 25, 2020 8:15 am
by jvierra
Yes - I missed the DLL. DLLs (and other files) can be distributed with an MSI.

Re: squeeze multiple files (.dll and .xaml) into an one .exe package

Posted: Thu Feb 06, 2020 10:35 pm
by Nillth
Actually, I found a way to do exactly this... :)

I have a little script I use that compresses dll's, files, etc into a self extracting ps1 file...
you point it at all of your required extra files, and it will compress them all to ps1's.
then its just a matter of adding them to the project and calling the invoke on them.
When you compress them, you can specify if you want the file (e.g. dll) to be loaded into memory, import as a powershell module, or export the file to disk before doing something with it.

Code: Select all

#Created: 2020-02-07 17:30:57Z
$EncodedCompressedFile = @'
	Fcs7CoAwDADQveAdgrpWT+AodBSXzn6CLaSNpCl4fHV/r7uihroPB6cxRyINjfESFW3gotA6JGLwLHS2jelzJYIJVtxO635gF+F0f3ARLAXmrCigDPMT9Qsv
'@
Write-Verbose "Loading HelloWorld.ps1"
$DeflatedStream = New-Object IO.Compression.DeflateStream([IO.MemoryStream][Convert]::FromBase64String($EncodedCompressedFile),[IO.Compression.CompressionMode]::Decompress)
$UncompressedFileBytes = New-Object Byte[](95)
$DeflatedStream.Read($UncompressedFileBytes, 0, 95) | Out-Null

#write to file
[io.file]::WriteAllBytes('HelloWorld.ps1', $UncompressedFileBytes)

#run as script block
$SB = [scriptblock]::Create([System.Text.Encoding]::ASCII.GetString($UncompressedFileBytes))
Invoke-Command $SB

Code: Select all

#Created: 2020-02-07 17:28:22Z
$EncodedCompressedFile = @'
	7VfNb9zGFX9crRRZiSR/5Mtp6zAr13Zsi/pYwZZdSZasle2tZUnVyjIaC7G55OyKMZdkZriyNkCL9NAgAXJwihbIH5ACDdAAKRAgQeu2QA8pWthB0FOPOfRUoMjBpwZF3d8MuVxK2iA6BAUKdFb8cea9mTe/eZx5b3TlhTvUQURZPA8fEn1EUZmmry6v4ul79td99MGe+899pM3ff25l3RF6wP0qN2u6ZXqeH+plpvO6pzueXlgs6TXfZkZvb8/h2MbSHNG81kFr7ylzqnxGOXpUGybqpuhBee0oQG8Sm47qmYi3LF1pUpmo2kE3f0y0V/213slLlTzsLsYm73a2WeRNosfwevsI0fgufJIUPaGuSjfal1JtI2SbId5vPhKvq7vFO2XipsEFtyjmBo5qoT1b+0E8bXDm+lbEVXJWtvbu6Hd+O83q0eh9SQ3ppE1MqndJ32VIS7l1t+UV4hgWHOuXLPnBpHoMXHqOHM9lju2TzePnS989r8kZKOK8MWYMG/nh/MgZKekkF/hXqAd+SFTAWgI8A6WQO15VyB4fZCPOA1dL9K9stNSBi1eLBWkPvnpcjj3v+uWYF4ZrF58g2iMbX2h5epLU7PtjV8lHtsGO+uJ6xO5nWvTuoh7tRKaLbiucon9q/XQ5I+UV+ovWRf9Q+InCFzWJxxXOKvyBki/TYxg7rPBXSvI2vQO8kfkYeIgk/k37WE0YzRr5aC/9TjtAM6q1pEv5W3RfG0TLV63Xnn6AkdEaXsjsoQfgvI+k7CCwh54H7qURhWcUzigsKvyewu8rNIFPkKPqLytsKHyDjtAzwErmWfqRsmzQo5QHHqAJ4DfoOnCAbOAJCoF5hd9ROKvkl7E7DCopyXWFFv0EeIvuAgX9ibKvNtfdLAeodcZlOZze/BNXfLvusimqCcvnrlOmS8x1/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cVT9nXAx83xardPIaKdCzmsR/j59GqqpFydQHWJRlXsStkNNwp0+ldPDqNgsOo4nFc+aZlJ/pCNto19S1vJV4krE5yXoztOTHn5pq9XXM/pXwt47oPTR1+Drd8jy/z8Zjy8dZx2z293c/jasyMyh9yTWVYk5njq8bdmyX6e2qTf/6b30+c26y5+kYcdXOIzDmdeZZvI7VN5q6uXBgcz+kiND3bdH2PTeYaTOTOTfX29PZMmHHC12HCE5O5OvfOCmsdlxsxWHMs7gu/Eg5afu2sKWrGxkhOr5meU2EiXE3PB2O6nhgr2gwpN2xs4SR/Od1DvJ/MXWnMBIHrWOrKYphBkBuKLIS8LkKZ9HfJZzSaGSMFs+q49DXiNiScvVwHT2YvcWcDib/KxC6t5nOJlbQdRHKrLhnPsw3m6q7EyZwpit6Gf4vxnF53ZixcLDBBxXQFixeljAy1YdOkPrSF+8RQ4gS0J4aaTp2ir6/o0f9fr5/+Gm3+v/zPlP8A
'@
Write-Verbose "Loading HelloWorld"
$DeflatedStream = New-Object IO.Compression.DeflateStream([IO.MemoryStream][Convert]::FromBase64String($EncodedCompressedFile),[IO.Compression.CompressionMode]::Decompress)
$UncompressedFileBytes = New-Object Byte[](4608)
$DeflatedStream.Read($UncompressedFileBytes, 0, 4608) | Out-Null
	[io.file]::WriteAllBytes('HelloWorld.exe', $UncompressedFileBytes)

Re: squeeze multiple files (.dll and .xaml) into an one .exe package

Posted: Thu Feb 06, 2020 11:09 pm
by Alexander Riedel
Just make sure you don't install your scripts in any protected folder like "Program Files" or below, as the extract will fail without elevation.

Re: squeeze multiple files (.dll and .xaml) into an one .exe package

Posted: Fri Feb 07, 2020 12:56 am
by Nillth
Alexander Riedel wrote:
Thu Feb 06, 2020 11:09 pm
Just make sure you don't install your scripts in any protected folder like "Program Files" or below, as the extract will fail without elevation.
this is true, however they can be run in memory if you are not extracting to disk...

Re: squeeze multiple files (.dll and .xaml) into an one .exe package

Posted: Fri Feb 07, 2020 1:48 am
by Alexander Riedel
Yeah, that will make it look like malware. I wouldn't run that :D
Can I ask what the reason behind this is? Why are you trying to hide DLLs and other files?

Re: squeeze multiple files (.dll and .xaml) into an one .exe package

Posted: Sun Feb 09, 2020 1:00 am
by Nillth
Not trying to hide the DLL's just trying to have a single, portable exe, that does not need to be installed to run