Update MSI Tables with Query - c#

Iam new at this topic so please forgive me if my question is not reasonable. Iam using an installer for 3 assemblies. One of those assemlies i have to change a value of Type column. My Problem is, i can't say, which one is the one i need to change to the value of it because they are refered to an action KEY. I dont know, what is the key for the assemly i wanna update it's value. I'm using for that the program super orca. as you can see in the screeshot, i have for each assembly an install, comit, rollback and uninstall row.
Also is it possible to write a query somewhere inside VIsual studio, so i dont have to edit manuelly every time i compile a new version?

Don't have answer to the first question (Orca editor) but for the Visual studio part, you have two possibilities
possibility 1 - if possible, in visual studio set up post build actions to change properties of assembly files on the project which is producing your assemblies; if changing properties here is also reflected in installer that you build then you are done.
possibility 2 - create custom action in setup/installer project; this custom action executes when installer is executed. Custom action need to have code to change property of assembly through/during installation. This doesn't change the properties in installer but it changes properties of installed assemblies. Here is the example on how to write custom action
a hack - for orca editor - given that there are only three assemblies, you could try changing property one at a time and execute installer to see if it changed property of the right assembly.

Related

Running Custom Action before installation - Visual studio installer

I am working on a project where I need to run an action before installing a new version, this action is to check if there a product already installed and to uninstall it. I tried to add custom action in visual studio installer but I can't add a DLL file from the outside of the project so the action won't run before the installation. My application is a Microsoft office addin so that why I used visual installer because it is very simply and straightforward. Is there any another solution ?
Note : Changing product code and set DetectNewerVersion to true didn't work,
now I have two same product in Program and Features
Here you can find InstallExecuteSequence numbers. You just should put yours custom action in right place, for example you can set Sequence=750 - it will be run before CostInitialize.
Also here's video tutorial how to use orca.exe. It's amazing app to check and debug your msi. In your case you can check is your CustomAction in right place or you should change number, or even your custom action isn't working.
And about "I tried to add custom action in visual studio installer but I can't add a DLL file from the outside of the project so the action won't run before the installation". I can't get what do you mean, but seems that you can't add dll with custom actions. Here's tutorial about it.

VS2012: My Entity Framework model doesn´t get included to my project output using InstallShield

I was recently asked to create an installer for a Windows Forms application that uses Entity Framework to comunicate to a database. I modified my program to create the database if it doesn't exist on the final user's computer, so it should work without problems. Problem is, I'm using installshield for Visual Studio 2012, and after building my installer, only 2 files were generated inside the install directory:
MyProgram.exe & MyProgram.exe.config
Problem is, I believe a EntityFramework.dll file should also be included for the program to work, but apparently, Visual Studio doesn't want to include it. I tried everything. I clicked on the properties of the EF model and selected the "Copy to Output" or "Copy if Newer", and nothing. I also tried to change my .edmx file´s properties where I switched Build Action: None to Build Action: Compile...but after that, my whole program wouldn't even build! It threw the following error:
A namespace cannot directly contain members such as fields or methods
And after double clicking the error to check where it happened, it opened the EDMX file in code, and apparently wanted me to add a namespace at the start of it...but this whole thing looks like XML...so why does it ask me for a namespace?
All I want to do is add my Entity Framework Model to my Primary Output, but nothing works. Or it doesn't appear in installshield at least. I know I can manually add "EntityFramework.dll" the file from the debug or release folder in my project/bin, but that just doesn't feel right. Should I just do that, or is there a reason why my Entity model isn't being added to my project output? Or why did my EDMX file threw a namespace error when I tried to switch the compile option from None->Compile???
Please help guys...I know it's a dumb mistake, but all I want is that the files required for my entity model to work on another PC be copied (As far as I know, all I need is that EntityFramework.dll and maybe EntityFramework.xml). Help?
All I want to do is add my Entity Framework Model to my Primary
Output, but nothing works. Or it doesn't appear in installshield at
least. I know I can manually add "EntityFramework.dll" the file from
the debug or release folder in my project/bin, but that just doesn't
feel right
In your installshield project (certainly in the same solution as your project), you should indeed see the primary.output of the project it depends on. If not, right click on IS project -> Project dependencies -> and check manually.
From te IS project tree, it is available in the "2) Specify your application data" -> "Files" where zou can specify the physical organisation and content of your installation directory.
On .primary.output -> right click -> dependencies from scan at build -> You should see a list of all auto-detected dependencies, enable/disable what you want... it works this way for me. Note that a build is required previously.
If the dll is not present in the list, you could also drop it in the installation directory tree on the left and the file will be embedded too.

Is it possible to embed a script into MSI installer package?

I am trying to create an MSI installer/uninstaller for my Windows project, consisting of a service, a couple of user-mode exes/dlls and some data files. I was able to use Visual Studio 2010 to compile an MSI package using its Setup Project. It works fine for installation, but uninstallation requires some additional steps before files are actually removed along with the registry settings.
So I was wondering, is there any way I can run a script (C#, or WSH JScript) before removing files/registry settings?
Yes, you can add as well scripts (VBS or JScript) to an MSI as C# or C++ custom actions in compiled MSI enabled Dlls, you can call .exe files, etc. There is a table called CustomAction and the Custom actions can be sequenced with the sequence tables, the most important are InstallExecuteSequence and InstallUISequence.
Working with custom actions is not so an easy task I think. If it is possible for you to ask experts, I would consider it.
Most times, when you want to add a custom action for uninstalling resources, there is maybe something wrong with your MSI.
4 of 5 custom actions one wants to add, are not necessary but can be replaced with correct MSI table entries.
Generally, I don't recommend using Visual Studio installer, because it gives you not very much control, and it is easy to make things wrong, especially for upgrading and more complicated task.
But if you still want to add a custom action here is some basic idea:
For example for starting a VB script you can add a custom action of type 38. Choose a name in the "Action" column, let the "Source" columns empty, and type the VB script code in the "Target" column:
E.g. with something like that you have an VB "interface" to the MSI properties like the newly invented "MYDIR_EXISTS" here.
on Error Resume Next
set filobj = Createobject( "Scripting.FileSystemObject" )
If filobj.FolderExists("C:\MyDir") Then Session.Property("MYDIR_EXISTS") = "True"
...
If you work with Visual Studio Installer you could consider adding the custom actions with a transform afterwards. Again this needs some MSI knowledge.
Me, personally, I would not work with script files for distributed setups, only if the setup is an infrastructural one for the same company. But it is a starting point.
Calling an compiled .exe with Custom Action type 34 or 50 would be an alternative.

Can I somehow get values entered in the User Interface into my custom actions installer class code?

This seems like it should be pretty simple.
I have a Windows installer project. Inside the UI, I added a dialog with 2 radio buttons.
The installer has a custom action on 'Install' which uses an install class from the primary output of one of my projects. Is it possible to get the value of the selected radio button from within the Install method in the installer class?
To get/set a property you need an MSI handle which, from what I know, you cannot obtain from a .NET Installer class custom action.
What you could do is to configure the custom action to accept new parameters, and assign the value of your property to those parameters, when configuring the custom action.
If this is a Visual Studio installer project, and it seems to be, the properties window of the added RadioButtons dialog tells you that the property name is BUTTON2 so that's what you pass into your custom action installer class with the standard /mybutton=[BUTTON2] type of syntax so you get the value using the key mybutton from Context.Parameters collection in the installer class.
The dialog behavior is described here:
https://msdn.microsoft.com/en-us/library/vstudio/9x23561f(v=vs.100).aspx
and you'd end up with a value of 1 or 2 in your code, depending on which was selected. With installer classes Visual Studio provides that infrastructure around the call, including CustomActionData handling
Like this:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/279e0aea-077c-4150-89ae-55d8494def1b/installer-class-passing-parameters
http://blog.billsdon.com/2011/05/passing-parameters-collected-dialog-custom-action-msi-c/
If you use WiX Deployment Tools Foundation (DTF) to develop your custom action, you are able to access the properties:
for immediate execution via session[property name] (admittedly, I'm not too familiar with this method, so you might need to experiment a bit) See this stackoverflow question for more details
for deferred execution via CustomActionData
you can populate CustomActionData with the values of your properties elsewhere in your installer and read as session.CustomActionData[property name]
One trick with the CustomActionData is your property name must match the name of your custom action and you provide the values as a semicolon-delimited list of name=value pairs, e.g. Name1=value1;Name2=value2 etc.
You will also need to run your assembly through MakeSfxCA.exe to make your action available to the installer. You can do that as a post-build event in Visual Studio.
DTF-based .Net custom actions can be used in WiX or InstallShield installers (likely any tool that produces MSI installers).

Cannot see changes I make when I run my application in Visual Studio

I make changes in .cs files and also some changes with the designer. After this I compile and run the project.
The problem is that it shows the my old form, and it does not show the new changes I made in the form.
In other words, I don't see the changes I made when I run my application.
Try to Rebuild or Clean/Rebuild project, of course first be sure that you Build it after change.
When you have compilation errors and stuff like that Visual Studio will pop up a windows asking if you want to run the last successful build. It has a checkbox that says "Do not show this dialog again". If you have previously checked that box it can produce something like what you are talking about.
This may not be your problem but at the very least you should check it out, just in case.
The window looks like this:
To fix it go to your Tools->Options then:
I don't think it is a problem, you may not building the application.
I would check your Configuration Manager for your solution. It's possible that your active solution (e.g. the solution type specified by your Configuration / Platform combination) is not set to actually build the project.
The Configuration Manager has a Build column with checkboxes. Ensure that all the projects you want to build for a configuration are set to build.

Categories