Get directory of installed .NET runtime: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
Line 11: Line 11:


== Usage ==
== Usage ==
 
<highlight-nsis>
Section "Install"
Section "Install"


Line 34: Line 34:


SectionEnd
SectionEnd
 
</highlight-nsis>


== Function ==
== Function ==

Revision as of 00:08, 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 installation directory
	StrCmpS "" $R0 err_dot_net_not_found
 
	; Perform our install
	SetOutPath $INSTDIR
	File "MyDll.dll"
	ExecWait '"$R0\RegAsm.exe" /tlb /codebase /nologo HabitatCaptureDll.dll'
 
	Return
 
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."
 
SectionEnd

Function