Deployment question
-
:confused:Hello! Im trying to write a deployment project in VS.net 2005. What Im trying to do is this. Take the target installation path and write this string value to the registry. I just cant figure out how to do this. I know how to write to the registry, but somehow I need to get the target path and write this parameter to the registry. Very thankfull for any help.
-
:confused:Hello! Im trying to write a deployment project in VS.net 2005. What Im trying to do is this. Take the target installation path and write this string value to the registry. I just cant figure out how to do this. I know how to write to the registry, but somehow I need to get the target path and write this parameter to the registry. Very thankfull for any help.
The VS deployment projects aren't very flexible. You might be better off using WiX[^]. That said, you can use [TARGETDIR] for your registry value in most cases. If you're trying to write the exact location of a file you can use the notation [#filekey] but that where things get difficult, since the VS.NET deployment projects don't show you the component, file, registry, etc. key names (the deployment projects compile into .msi files, which are relational databases processed by Windows Installer).
This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]
-
The VS deployment projects aren't very flexible. You might be better off using WiX[^]. That said, you can use [TARGETDIR] for your registry value in most cases. If you're trying to write the exact location of a file you can use the notation [#filekey] but that where things get difficult, since the VS.NET deployment projects don't show you the component, file, registry, etc. key names (the deployment projects compile into .msi files, which are relational databases processed by Windows Installer).
This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]
-
Hello! Thanks for your answer! I found out [TARGETDIR] right after I posted :) What is WiX and where can I find it? Best regards!
This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Customer Product-lifecycle Experience Microsoft [My Articles] [My Blog]
-
Hello! Thanks for your answer! I found out [TARGETDIR] right after I posted :) What is WiX and where can I find it? Best regards!
-
:confused:Hello! Im trying to write a deployment project in VS.net 2005. What Im trying to do is this. Take the target installation path and write this string value to the registry. I just cant figure out how to do this. I know how to write to the registry, but somehow I need to get the target path and write this parameter to the registry. Very thankfull for any help.
If you create your own project installer (System.Configuration.Install.Installer), you can easily get the install path by just using reflection on the executing assembly. Here is some code I use to do this in my installer:
/// Since this assembly is being run from the install directory, it will return the full
/// path to this assembly. You can simple get the directory path using a FileInfo object
/// to know where it's been installed.
System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
string baseAppDir = (new System.IO.FileInfo( asm.Location )).DirectoryName;/// We're certain this exists because our setup program created it.
RegistryKey softwareKey = Microsoft.Win32.Registry.LocalMachine
.OpenSubKey( "Software", true )
.OpenSubKey( "Company Name", true )
.OpenSubKey( "Application Name", true );softwareKey.SetValue( "InstallLocation", configFilepath );
Keep in mind that I added a registry value in setup project that creates the HKLM\Software\Company Name\Application Name\InstallLocation key with some default or empty value. The setup project actually creates the keys you specified in the registry editor part of the setup project before it calls your code in the Installer class. -Matt
------------------------------------------ The 3 great virtues of a programmer: Laziness, Impatience, and Hubris. --Larry Wall