RE: VS2005 setup project: execute tasks without installing files?
- From: hongyes@xxxxxxxxxxxxxxxxxxxx ("Hongye Sun [MSFT]")
- Date: Tue, 25 Nov 2008 17:26:22 GMT
Thanks for Phil's great answer.
Hi dpomt,
After going deep by the direction pointed by Phil, we have found a easier
solution for you. It is to write a C++ DLL and make it to be exclude in
your installer project which can dirrectly call managed methods. Following
is the detailed steps:
Prerequisites:
Windows Installer SDK must be installed. It can be downloaded at
http://www.microsoft.com/downloads/details.aspx?familyid=e96f8abc-62c3-4cc3-
93ad-bfc98e3ae4a3&displaylang=en.
1. Create a C++ DLL project named "CustomAction" and set it with Common
Language Runtime Support (/clr)
2. In project properties -> Linker -> Input -> Additional Dependencies ->
C:\MsiIntel.SDK\Lib\Msi.lib
3. In stdafx.h, add following includes
-----------------------------------------
#include <msi.h>
#include "msiquery.h"
-----------------------------------------
4. In CustomAction.cpp file, copy the code below:
-----------------------------------------
#include "StdAfx.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::Windows::Forms;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;
UINT __stdcall Install(MSIHANDLE hInstall)
{
WCHAR srcDirBuffer [500] = {0};
DWORD len = 500;
MsiGetPropertyW(hInstall, L"CustomActionData", srcDirBuffer, &len);
String^ s = gcnew String(srcDirBuffer);
String^ dllPath = s + "myddl1.dll";
MessageBox::Show(dllPath);
Assembly^ assembly = Assembly::LoadFrom(dllPath);
RegistrationServices^ service = gcnew RegistrationServices();
service->RegisterAssembly(assembly, AssemblyRegistrationFlags::None);
return 0;
}
-----------------------------------------
5. Add one def file with following content:
-----------------------------------------
LIBRARY "CustomAction"
EXPORTS
Install @1
-----------------------------------------
6. Compile into CustomAction.DLL
7. In Visual Studio Deployment project, add assembly and select
CustomAction.DLL.
8. In the assembly file's properties, set its property "Exclude" to true,
that will prevent it to be copied to user's machine.
9. Add it into Custom Action, in the Custom Action Editor, open its
properties, set its properties as following:
CustomActionData=[SourceDir]
EntryPoint=Install
InstallerClass=False
10. Build and run the installer.
The basic concept of this sample is that we pass the source dir into the
C++ custom action and we use it to get the dll path, then we invoke manged
code: RegistrationServices.RegisterAssembly to register the DLL. The sample
only implements one of your requirements, for the other one (add codegroup)
can be implemented as the same way.
Please follow the instruction above and let me know if you have any problem
when implementing it. In the meanwhile, please feel free to send email to
me if you want the sample project source code. I will be more than happy to
help you. My email address is hongyes@xxxxxxxxxxxxxxxxxxxx, remove
'online.'. I will be waiting for you reply or email.
Thanks again for Phil's insightful suggestion on this issue.
Have a nice day.
Regards,
Hongye Sun (hongyes@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- References:
- VS2005 setup project: execute tasks without installing files?
- From: dpomt
- RE: VS2005 setup project: execute tasks without installing files?
- From: "Hongye Sun [MSFT]"
- RE: VS2005 setup project: execute tasks without installing files?
- From: dpomt
- VS2005 setup project: execute tasks without installing files?
- Prev by Date: RE: VS 2008 AJAX smart tags are disabled
- Next by Date: Setup project for vs 2008 vb express
- Previous by thread: RE: VS2005 setup project: execute tasks without installing files?
- Next by thread: Re: VS2005 setup project: execute tasks without installing files?
- Index(es):
Relevant Pages
|