Replies: 5 comments 1 reply
-
var project = new ManagedProject(...
new Binary(new Id("my_ini"), @".\dir1\dir2\settings.ini"),
. . .
static void project_AfterInstall(SetupEventArgs e)
{
byte[] ini_data = e.Session.GetEmbeddedData("my_ini");
. . . |
Beta Was this translation helpful? Give feedback.
-
Thanks oleg for the response, but calling e.Session.GetEmbeddedData causes error: "Cannot access session details from a non-immediate custom action" and GetEmbeddedData returns null. I am calling in project_AfterInstall |
Beta Was this translation helpful? Give feedback.
-
Ah, of course. I forgot that you do it after the installation when the session is terminated. :o)
|
Beta Was this translation helpful? Give feedback.
-
:) I was able to get it to work using e.Data so that it would be available after session was terminated, but I like your idea of putting it as a resource in the app (much better in my opinion) I added the file as a resource and had to set it's properties to "Embedded resource", then I created a function: public static string GetFromResources(string resourceName)
{
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
//MessageBox.Show(string.Join(",", assembly.GetManifestResourceNames()));
using (Stream stream = assembly.GetManifestResourceStream("WixSharp.Resources." + resourceName))
{
using (var reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Glad you thought of it ;) |
Beta Was this translation helpful? Give feedback.
-
Is there a way to include a file in the setup msi but not install it, and then use it in a CA or AfterInstall script?
I have a virgin INI file that if an INI file does not exist in (several locations that are checked by c#) on a users system I would like to place the renamed temporary file onto the users machine.
Beta Was this translation helpful? Give feedback.
All reactions