Get directory of installed .NET runtime: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
Line 17: Line 17:
Push "v2.0"
Push "v2.0"
Call GetDotNetDir
Call GetDotNetDir
Pop $R0 ; .net framework installation directory
Pop $R0 ; .net framework v2.0 installation directory
StrCmpS "" $R0 err_dot_net_not_found
StrCmpS "" $R0 err_dot_net_not_found


; Perform our install
; Perform our install
; e.g. use the .Net path in $R0 to call RegAsm.exe
SetOutPath $INSTDIR
SetOutPath $INSTDIR
File "MyDll.dll"
File "MyDll.dll"
ExecWait '"$R0\RegAsm.exe" /tlb /codebase /nologo HabitatCaptureDll.dll'
ExecWait '"$R0\RegAsm.exe" MyDll.dll'


Return
Return


err_dot_net_not_found:
err_dot_net_not_found:
MessageBox MB_OK|MB_ICONEXCLAMATION|MB_DEFBUTTON1 \
"Can't find the required version of the .Net framework."
Abort "Aborted: .Net framework not found."
Abort "Aborted: .Net framework not found."



Revision as of 00:11, 4 March 2006

Description

Given a .Net version number, this function returns that .Net framework's install directory. This is useful if you intend to call 'RegAsm.exe', or 'GACUtil.exe' on one of your .Net assembly DLLs, since these executables are stored in the directory this function returns.

Parameters

in: version of .Net framework required (eg. "v2.0") out: directory in which it is installed (eg. "C:\WINNT\Microsoft.NET\Framework\v2.0.50727")

Returns "" if the specified version of the .Net framework does not appear to be installed.


Usage

Section "Install"
 
	; get directory of .NET framework installation
	Push "v2.0"
	Call GetDotNetDir
	Pop $R0 ; .net framework v2.0 installation directory
	StrCmpS "" $R0 err_dot_net_not_found
 
	; Perform our install
	; e.g. use the .Net path in $R0 to call RegAsm.exe
	SetOutPath $INSTDIR
	File "MyDll.dll"
	ExecWait '"$R0\RegAsm.exe" MyDll.dll'
 
	Return
 
err_dot_net_not_found:
	Abort "Aborted: .Net framework not found."
 
SectionEnd

Function