Jump to content

Tutorial - build Portable nLite or any other .NET app


degradacija

Recommended Posts

Portable nLite – tutorial (more like guide then tutorial because there is no explanation but I'll edit this later and add explanations)

1. Download and install thinstall vs 3.2 trial at http://www.thinstall.com/products/virtuali...on_suite_dl.php (must signup first)

2. Download nLruntimeR3.exe at nliteos.com

3. I presume you already have nLite 1.4 beta

4. After you setup Thinstall VS go to c:\program files\Thinstall.VS create folder named Captures and inside create folder named 'nLite'

5. In nLite folder create following folders:

- %ProgramFilesDir%

- %SystemRoot%

- %SystemRoot%\winsxs

- %SystemRoot%\winsxs\Manifests

- %SystemRoot%\winsxs\Policies

- %SystemSystem%

6. Install nLruntimeR3.exe in your nLite-1.4.beta and move nLite-1.4.beta folder to %ProgramFilesDir%.

Note that .net2 should not be installed otherwise use universal extractor to extract nLruntimeR3.

7. nLruntimeR3 installed gdiplus.dll and mscoree.dll to system32 folder.

Copy gdiplus.dll to nLite-1.4.beta and mscoree.dll to %SystemSystem%

8. Check your C:\WINDOWS\WinSxS folder and see if you have VC8 runtimes:

x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd

if yes then continue otherwise move to step 9.

copy folder

C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd

to

Captures\nLite\%SystemRoot%\winsxs

copy folder

C:\WINDOWS\WinSxS\Policies\x86_policy.8.0.Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_x-ww_77c24773

to

Captures\nLite\%SystemRoot%\winsxs\Policies

copy files

C:\WINDOWS\WinSxS\Manifests\x86_Microsoft.Windows.SystemCompatible_6595b64144ccf1df_5.1.0.0_x-ww_fc342b0b.Manifest

C:\WINDOWS\WinSxS\Manifests\x86_Microsoft.Windows.SystemCompatible_6595b64144ccf1df_5.1.0.0_x-ww_fc342b0b.cat

C:\WINDOWS\WinSxS\Manifests\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd.manifest

C:\WINDOWS\WinSxS\Manifests\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd.cat

to

Captures\nLite\%SystemRoot%\winsxs\Manifests

9. Only if you finished step 8 continue otherwise move to step 10.

The following files appear in nLite-1.4.beta and v2.0.50727 folders so delete them from both locations

msvcm80.dll

msvcp80.dll

msvcr80.dll

Microsoft.VC80.CRT.manifest

you could also delete unnecessary language files from Lang folder

10. You also need comctl32.exe v. 6.0.2800.1106 search for it in your C:\WINDOWS\WinSxS folder since it was probably installed with some other application if you cant find it download it microsoft.com or google it.

Put this file in %SystemSystem% folder.

Note that it must be v. 6.0.2800.1106

11. Create .ini file named ##Attributes.ini containing following text:

[isolation]

DirectoryIsolationMode=Full

now copy this file to following folders:

- Captures\nLite-1.4.beta

- Captures\nLite-1.4.beta\Presets

- Captures\nLite-1.4.beta\Lang

- Captures\nLite-1.4.beta\v2.0.50727

- Captures\%SystemRoot%\winsxs

- %SystemRoot%\winsxs\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd

- Captures\%SystemRoot%\winsxs\Manifests

- Captures\%SystemRoot%\winsxs\Policies

-%SystemRoot%\winsxs\Policies\x86_policy.8.0.Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_x-ww_77c24773

Your project tree should look like this

post-61622-1191618677_thumb.jpg

12. Create file Package.ini in folder nLite(your project root folder) containing following text:

[BuildOptions]
CapturedUsingVersion=3.207
OutDir=bin
SandboxName=nLite
AddPageExecutionPermission=1
ChildProcessEnvironmentDefault=External

;ExternalCOMObjects={8BC3F05E-D86B-11D0-A075-00C04FB68820};{7D096C5F-AC08-4F1F-BEB7-5C22C517CE39}

;Enable this option if you want Out-of-process COM objects to be loaded outside of the virtual environment
;By doing this, the application may indirectly modify the machine - for example the MSI installer service COM object
;The default is to create all Out-of-process COM objects inside the virtual environment
;VirtualizeExternalOutOfProcessCOM=0


[Compression]
;CompressionType=None
CompressionType=Fast

[Isolation]
;DirectoryIsolationMode=WriteCopy
DirectoryIsolationMode=Merged

[nLite.exe]
Source=%ProgramFilesDir%\nLite-1.4.beta\nlite.exe
ReadOnlyData=bin\Package.ro.tvr
RetainAllIcons=1

;;cmd.exe shortcut can be used to launch system apps in the virtual environment
;[cmd.exe]
;Source=%SystemSystem%\cmd.exe
;ReadOnlyData=bin\Package.ro.tvr

;;regedit.exe can be used to inspect the virtual registry
;[regedit.exe]
;Source=%SystemRoot%\regedit.exe
;Shortcut=nlite.exe

13. Create 3 empty txt files in nLite folder (project root) named

HKEY_CURRENT_USER.txt

HKEY_LOCAL_MACHINE.txt

HKEY_USERS.txt

edit HKEY_LOCAL_MACHINE.txt to look like this:

@echo off

set PROJECT_DIR=%PROJECT_PATH%
if exist %PROJECT_PATH% goto haspath
set PROJECT_DIR=%CD%
:haspath

if exist "%THINSTALL_BIN%\vregtool.exe" goto found
set THINSTALL_BIN=%PROJECT_DIR%\..\..
if exist "%THINSTALL_BIN%\vregtool.exe" goto found
set THINSTALL_BIN=c:\program files\Thinstall.VS
if exist "%THINSTALL_BIN%\vregtool.exe" goto found
echo Could not find vregtool.exe, please set the environment variable THINSTALL_BIN or install to c:\program files\ThinstallVS
goto failed

:found
if not exist "%THINSTALL_BIN%\vftool.exe" goto failed
if not exist "%THINSTALL_BIN%\tlink.exe" goto failed

if not exist "%PROJECT_DIR%\bin" mkdir "%PROJECT_DIR%\bin"
if exist "%PROJECT_DIR%\bin\*.exe" del /f /q "%PROJECT_DIR%\bin\*.exe"

"%THINSTALL_BIN%\vregtool" "%PROJECT_DIR%\bin\Package.ro.tvr" ImportDir "%PROJECT_DIR%"
IF ERRORLEVEL 1 GOTO failed

"%THINSTALL_BIN%\vftool" "%PROJECT_DIR%\bin\Package.ro.tvr" ImportDir "%PROJECT_DIR%"
IF ERRORLEVEL 1 GOTO failed

"%THINSTALL_BIN%\tlink" "%PROJECT_DIR%\Package.ini" -OutDir "%PROJECT_DIR%\bin"
IF ERRORLEVEL 1 GOTO failed

goto done

:failed
echo *** Build failed ***
goto final

:done
del "%PROJECT_DIR%\bin\*.tvr"
del "%PROJECT_DIR%\bin\*.tvr.thfd"
echo ---------------------------------------------
echo Build complete
:final

Now just execute build.bat and after it's done you will find your portable nLite.exe in bin folder in the root of your project.

That's it, all done.

You could apply this same tutorial for most .NET applications just put that apps folder in %ProgramFilesDir%\ and edit Package.ini accordingly, and put ##Attributes.ini in that apps folder and all subfolders.

For example you could create portable WMP11Slipstreamer

create folder named WMP11S and put WMP11Slipstreamer.exe in.

and just edit Package.ini

replace

SandboxName=nLite

[nLite.exe]

Source=%ProgramFilesDir%\nLite-1.4.beta\nlite.exe

ReadOnlyData=bin\Package.ro.tvr

RetainAllIcons=1

with

SandboxName=wmpslipstreamer

[WMP11Slipstreamer.exe]

Source=%ProgramFilesDir%\WMP11S\WMP11Slipstreamer.exe

ReadOnlyData=bin\Package.ro.tvr

RetainAllIcons=1

and build.

Edited by degradacija
Link to comment
Share on other sites


Interesting :thumbup

But why you are still integrating nLite? If next version will be out should be re-do all this operations again? Why not to do it only for NET? ;) For example, use %ProgramFiles%\nLite folder insted of %ProgramFiles%\nLite-1.4.beta. Will it be possible to use this portable NET installer with the following versions of nLite? :rolleyes:

Link to comment
Share on other sites

Interesting :thumbup

But why you are still integrating nLite? If next version will be out should be re-do all this operations again? Why not to do it only for NET? ;) For example, use %ProgramFiles%\nLite folder insted of %ProgramFiles%\nLite-1.4.beta. Will it be possible to use this portable NET installer with the following versions of nLite? :rolleyes:

Later I'll post another tutorial on how to create portable .NET, but as I've said before it will work only for simple apps (wmpslipstreamer) --nLite needs to be packed together with .NET in order for it to work.

Each new version of nLite will have to be repacked.

I'm not sure if you really understand the result of all this - bin\nLite.exe is binary that contains both nLite and .NET, you can delete nLite project folder just save bin\nLite.exe and try to execute it on another computer that doesn't have .NET installed.

Link to comment
Share on other sites

I understand what's happenning ;) That is why I asked if it is possible to have only NET installer (that runs totally in virtual temporary evnironment ;)

My logic:

1. nLite needs NET.

2. nLite installed, NET is not installed.

3. There is a NET installer that can be run before running nLite so the last one thought this computer has NET installed.

I'm not sure about the 3 statement so I asked :rolleyes:

Link to comment
Share on other sites

I understand what's happenning ;) That is why I asked if it is possible to have only NET installer (that runs totally in virtual temporary evnironment ;)

My logic:

1. nLite needs NET.

2. nLite installed, NET is not installed.

3. There is a NET installer that can be run before running nLite so the last one thought this computer has NET installed.

I'm not sure about the 3 statement so I asked :rolleyes:

Yes you can build portable .NET (an executable, not a installer) environment using thinstall.

nLite 1.4beta will not work with this portable environment because of the mcdbnet2.dll component wich needs to write to virtual registry of Portable.NET and therefore nLite 1.4 beta needs to be packed (thinstalled) together with portable .NET into single exe, however nlite1.0b1 will work because this version doesnt use mcdbnet2.dll component and therefore has no need to use virtual registry of portable.NET

Portable .NET will work with every .NET app as long as that app doesn't need to use registry (for example wmp11slipstreamer).

Edited by degradacija
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...