Get directory of installed .NET runtime: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
Line 4: | Line 4: | ||
== Parameters == | == Parameters == | ||
in: version of .Net framework required (eg. "v2.0") | <b>in:</b> version of .Net framework required (eg. "v2.0")<br> | ||
out: directory in which it is installed (eg. "C:\WINNT\Microsoft.NET\Framework\v2.0.50727") | <b>out:</b> directory in which it is installed (eg. "C:\WINNT\Microsoft.NET\Framework\v2.0.50727")<br> | ||
<br> | |||
Returns "" if the specified version of the .Net framework does not appear to be installed. | Returns "" if the specified version of the .Net framework does not appear to be installed. | ||
== Usage == | == Usage == |
Revision as of 00:18, 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
; Given a .NET version number, this function returns that .NET framework's ; install directory. Returns "" if the given .NET version is not installed. ; Params: [version] (eg. "v2.0") ; Return: [dir] (eg. "C:\WINNT\Microsoft.NET\Framework\v2.0.50727") Function GetDotNetDir Exch $R0 ; Set R0 to .net version major Push $R1 Push $R2 ; set R1 to minor version number of the installed .NET runtime EnumRegValue $R1 HKLM \ "Software\Microsoft\.NetFramework\policy\$R0" 0 IfErrors getdotnetdir_err ; set R2 to .NET install dir root ReadRegStr $R2 HKLM \ "Software\Microsoft\.NetFramework" "InstallRoot" IfErrors getdotnetdir_err ; set R0 to the .NET install dir full StrCpy $R0 "$R2$R0.$R1" getdotnetdir_end: Pop $R2 Pop $R1 Exch $R0 ; return .net install dir full Return getdotnetdir_err: StrCpy $R0 "" Goto getdotnetdir_end FunctionEnd