Post-install operations from the MSI

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've yet to find a decently worded and exampled article outlining how one can
perform more complex operations during MSI installation.

Specifically, I'm looking to copy the source MSI to the installed directory
(in essence saving a backup of it) after the installation has completed.

I found a couple articles that use an "installhelper.cs" file w/in the main
output project, but I've implemeted this in VS.NET 2k5 / .NET 2.0 with no
success.

Please let me know if any good resources for performing operations such as
these during installation w/ an MSI. Thanks!
 
Brandon,

If you find out any good sources, let me know. The Windows Installer under
VS 2005 seems to be an area that no one touches or most developers seem to
have the luxury of parsing this task out to someone else. I'm amazed at the
lack of samples and documentation I've found on using Deployment Projects.
Even the MSDN shows very little useful sample information -- they just spew
out information with no context reference.

As for your issue, have you tried adding a ProjectInstaller component to the
project your distributing? Or you can create a DLL or EXE from .NET and
reference that via Custom Actions and be sure to set the InstallClass =
True.

Also, it seems that because of "Rollback" functionality, get anything done
PRIOR to installation is close to impossible. I'm still struggling on
removing an older version of a Windows Service (I even know the ProductCode
aka ComponentID) I wrote with a newer version that has a different product
code. I'm stuck in a recursive hell -- I can't uninstall my old service
first because of rollback issues MSI enforces, I can't install my new
service because it will conflict with the existing service so I can't get to
a point where I can uninstall the old service. This is some seriously
sadistic limitation in the MSI approach. The funny (or not so funny) is
that products like InstallShield are no better and don't resolve this issues
either -- very frustrating.

I'd be greatful if you posted a link if you get any good info.

Thanks, Rob.
 
I'll definitely do that. I, too, am amazed at the lack of documentation and
samples regarding this.

I haven't done the ProjectInstaller as this isn't a windows service, just a
standard executable I'm bundling up into an MSI with its references. I may,
however, try and get an installer into the project. I know w/ a windows
service you just right click the "blank" background in the component designer
to get the Project Installer option and then it runs when you use the
InstallUtil to install it. However, if a user downloads my MSI and runs the
installation, that's not going to utilize this functionality, or will it?

Would be nice to get an MS rep in here to get the ball rolling on some
actually useful docs regarding the setup and deployment projects. Maybe our
posts here can get that done at the very least.
 
After my previous post I found the "Installer Class" item in the project area
and threw one of these in. Using the example I found at
http://www.codeproject.com/dotnet/SetupAndDeployment.asp
I implemented a simple test of overriding the Install() method (to pop up a
message box) but it didn't work. Now, messageboxes may not be allowed which
could be my problem, but nonetheless my main constraint here is to try and
get the location of the MSI that is running so that I can copy it to the
application's installation directory for the backup. I may be getting closer
but would still appreciate some insight.
 
I put the installerClass into my program, set the install custom action to
the output from my project and that it was an InstallerClass, and put the
following code into an InstallHelper.cs class w/in my project:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;

namespace KMG.BusRunner
{
[RunInstaller(true)]
public partial class InstallHelper : Installer
{
public InstallHelper()
{
InitializeComponent();
}

public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);

System.Diagnostics.EventLog.WriteEntry("MyProgram",
System.Reflection.Assembly.GetExecutingAssembly().Location);


System.IO.File.Copy(System.Reflection.Assembly.GetExecutingAssembly().Location,

System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
}
}
}

It does not write anything to the event log, and doesn't do a copy to my
desktop either.
 
What are you using to invoke the Install? (for testing you should be able
to right click the Deployment Project and select Install).

couple of suggestions:
1. You should be able to add a ProjectInstaller component to your app?
2. Use the events from the ProjectInstaller (i.e. _BeforeInstall,
_Committing, _AfterInstall)
3. Add eventlog code to the _Committing to see if it is being triggered

My reference is VB.NET so please excuse me if I use any different terms.

Brandon @ KMG said:
I put the installerClass into my program, set the install custom action to
the output from my project and that it was an InstallerClass, and put the
following code into an InstallHelper.cs class w/in my project:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;

namespace KMG.BusRunner
{
[RunInstaller(true)]
public partial class InstallHelper : Installer
{
public InstallHelper()
{
InitializeComponent();
}

public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);

System.Diagnostics.EventLog.WriteEntry("MyProgram",
System.Reflection.Assembly.GetExecutingAssembly().Location);


System.IO.File.Copy(System.Reflection.Assembly.GetExecutingAssembly().Location,

System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
}
}
}

It does not write anything to the event log, and doesn't do a copy to my
desktop either.
--
KMG Software, Inc.
Thinking Beyond, Above, and Before
http://www.kmgsoftware.com


Brandon @ KMG said:
I've yet to find a decently worded and exampled article outlining how one
can
perform more complex operations during MSI installation.

Specifically, I'm looking to copy the source MSI to the installed
directory
(in essence saving a backup of it) after the installation has completed.

I found a couple articles that use an "installhelper.cs" file w/in the
main
output project, but I've implemeted this in VS.NET 2k5 / .NET 2.0 with no
success.

Please let me know if any good resources for performing operations such
as
these during installation w/ an MSI. Thanks!
 
Yeah I'm right-clicking the deployment project and choosing 'Install'.

Could you tell me what namespace the ProjectInstaller is in? I can't find it
anywhere in the C# side of things. The only thing I saw was the "Installer
Class" item that I could choose when I did "Add new Item..." on the project.
Which is what I did, and what was showcased in the "tutorial" that I pasted
earlier, but it's not working.


--
He who dies with the most toys wins.


Rob R. Ainscough said:
What are you using to invoke the Install? (for testing you should be able
to right click the Deployment Project and select Install).

couple of suggestions:
1. You should be able to add a ProjectInstaller component to your app?
2. Use the events from the ProjectInstaller (i.e. _BeforeInstall,
_Committing, _AfterInstall)
3. Add eventlog code to the _Committing to see if it is being triggered

My reference is VB.NET so please excuse me if I use any different terms.

Brandon @ KMG said:
I put the installerClass into my program, set the install custom action to
the output from my project and that it was an InstallerClass, and put the
following code into an InstallHelper.cs class w/in my project:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;

namespace KMG.BusRunner
{
[RunInstaller(true)]
public partial class InstallHelper : Installer
{
public InstallHelper()
{
InitializeComponent();
}

public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);

System.Diagnostics.EventLog.WriteEntry("MyProgram",
System.Reflection.Assembly.GetExecutingAssembly().Location);


System.IO.File.Copy(System.Reflection.Assembly.GetExecutingAssembly().Location,

System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
}
}
}

It does not write anything to the event log, and doesn't do a copy to my
desktop either.
--
KMG Software, Inc.
Thinking Beyond, Above, and Before
http://www.kmgsoftware.com


Brandon @ KMG said:
I've yet to find a decently worded and exampled article outlining how one
can
perform more complex operations during MSI installation.

Specifically, I'm looking to copy the source MSI to the installed
directory
(in essence saving a backup of it) after the installation has completed.

I found a couple articles that use an "installhelper.cs" file w/in the
main
output project, but I've implemeted this in VS.NET 2k5 / .NET 2.0 with no
success.

Please let me know if any good resources for performing operations such
as
these during installation w/ an MSI. Thanks!
 
Oops, sorry -- you do have the Installer class -- Inherits
System.Configuration.Install.Installer -- I think the C# translation got me
as your events are named different.

Brandon said:
Yeah I'm right-clicking the deployment project and choosing 'Install'.

Could you tell me what namespace the ProjectInstaller is in? I can't find
it
anywhere in the C# side of things. The only thing I saw was the "Installer
Class" item that I could choose when I did "Add new Item..." on the
project.
Which is what I did, and what was showcased in the "tutorial" that I
pasted
earlier, but it's not working.


--
He who dies with the most toys wins.


Rob R. Ainscough said:
What are you using to invoke the Install? (for testing you should be
able
to right click the Deployment Project and select Install).

couple of suggestions:
1. You should be able to add a ProjectInstaller component to your app?
2. Use the events from the ProjectInstaller (i.e. _BeforeInstall,
_Committing, _AfterInstall)
3. Add eventlog code to the _Committing to see if it is being triggered

My reference is VB.NET so please excuse me if I use any different terms.

Brandon @ KMG said:
I put the installerClass into my program, set the install custom action
to
the output from my project and that it was an InstallerClass, and put
the
following code into an InstallHelper.cs class w/in my project:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;

namespace KMG.BusRunner
{
[RunInstaller(true)]
public partial class InstallHelper : Installer
{
public InstallHelper()
{
InitializeComponent();
}

public override void Install(System.Collections.IDictionary
stateSaver)
{
base.Install(stateSaver);

System.Diagnostics.EventLog.WriteEntry("MyProgram",
System.Reflection.Assembly.GetExecutingAssembly().Location);


System.IO.File.Copy(System.Reflection.Assembly.GetExecutingAssembly().Location,

System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
}
}
}

It does not write anything to the event log, and doesn't do a copy to
my
desktop either.
--
KMG Software, Inc.
Thinking Beyond, Above, and Before
http://www.kmgsoftware.com


:

I've yet to find a decently worded and exampled article outlining how
one
can
perform more complex operations during MSI installation.

Specifically, I'm looking to copy the source MSI to the installed
directory
(in essence saving a backup of it) after the installation has
completed.

I found a couple articles that use an "installhelper.cs" file w/in the
main
output project, but I've implemeted this in VS.NET 2k5 / .NET 2.0 with
no
success.

Please let me know if any good resources for performing operations
such
as
these during installation w/ an MSI. Thanks!
 
Still another buggy situation with the S&D projects is that when you set a
custom action to execute, it "halts" the installer until that action is
completed. Thereby I can't find a way to automatically run my program after
the installation is completed. Has anybody successfully done this??
 
Back
Top