InstallShield - how to write custom action functions - c#

I am trying to create installer using InstallShield and have requirement to execute some code during the installation process. Earlier I was using VS 2015 setup extension to create MSI but due to some advance needs in MSI we are planning to migrated to InstallShield and code that we were executing in onBeforeInstall / onAfterInstall of ServiceInstall also needs to be executed and as per my understanding we need to create CustomActions and for that requirement is to create functions and put them in dll file.
I tried to look into documents of InstallShield but wasn't able to find good way or example code that i can start with to write such code. I prefer to write in C# it will be helpful if some one can guide me to write function to attach with custom actions.

Help Material: The documentation included with InstallShield should have good information to get going? Installscript Reference. Also check the Installshield installation folder under Program Files - I think there are some samples there.
Installsite.org: Setup consultant Stefan Kruger's installsite.org has a number of coding examples for custom actions.
Github.com: You can search github.com to find samples of just about anything. Sample search for MsiGetProperty (used by most Installscripts).
Custom Actions: Managed code (Dot Net) has a number of technical problems for large scale package distribution. It is recommended that you use Installshield's proprietary Installscript language or straight up C++ (minimal dependency, static linking when possible). I don't have a nice summary of managed code problems, only this half-mad answer that was written some time ago.

Related

Using RoundhousE with dll File

I've decided to use RoundhousE for my database. Now there are three ways to use this tool. With MSBuild, a DLL File or the console application. I found some documentations how to use the MSBuild variant and I know how to use the console application but I can not find anything how to use the DLL in Visual Studio and how to call/configure RoundhousE this way.
Does someone know where to find a detailled documentation or could someone explain me this?
The DLL is used in a few places, like with DropkicK - it may not be a bad idea to explore how it uses it, as there is not much documentation with this otherwise. You can also review how Roundhouse RefreshDatabase uses it as well.
DropkicK - https://github.com/chucknorris/dropkick/blob/master/product/dropkick/Tasks/RoundhousE/RoundhousEClientApi.cs
RoundhousE-EntityFramework RefreshDatabase - https://github.com/chucknorris/roundhouse-entityframework
HTH

can ironruby nuget package be installed then used in a vanilla VS2012

I am interested in using a ruby script (https://github.com/zmoazeni/csscss) withing an ASPNET MVC site. I have no previous experience with ruby so my question could be naive.
Is it possible to import the ironruby nuget package and execute the ruby scripts?
My goal would be to put a .net wrapper around the ruby script(s) and put the output out as HTML.
So far I have tried Googling getting started with ironruby but have not found much that I understand and could get working, (yes that sound vague, but I don't know ruby or ironruby and couldn't find any good simple guides on getting started).
I've realized a simple proof of concept at https://github.com/edymtt/csscss-from-ironruby that shows in a console application how to use IronRuby to run the source code of csscss to analyze a CSS loaded from a file. To achieve this result I've started from this SO question -- you can find the additional resources I've used in the comments of the program. I haven't tried this code in a ASP.net MVC site -- anyway this sample should be a good starting point.
This solution is a bit cumbersome to maintain, since you have to manually put the sources for the csscss and its dependent libraries in the solution. An alternative solution is to install Ruby on the machine, install csscss using gem(so it download the dependencies automatically) and to invoke the program from .NET -- I'll also show this approach in the sample. Note that this solution requires that you could install Ruby on the web server.
UPDATE 2013-09-02 18:15 UTC Following the suggestion from Zach Moazeni I've been able to semplify the approach that used IronRuby to run csscss and I've updated accordingly the proof of concept. In a nutshell:
outside the .NET program I've used bundler to download csscss and json (and dependent gems) to a local folder of the project;
in the .NET program I've written a function to discover all the paths of the libraries in the gem folder created by bundler (by finding the gems folder and then including for each subfolder the lib folder, this algoritm was inspired by this SO thread);
I've passed this list of paths to the IronRuby interpreter before launching csscss.
This approach should conjugate the ability to use only .NET to run the program with the ease of the update given by gem and bundler.
I'm the author of csscss and I built the JSON output for this reason.
csscss -j file.css
It's not a perfect solution, but instead of outputting human readable text, it will output JSON that you can parse from whatever language/runtime.

How to add some code to c# Installer

I have made an installer which contains the exe and dlls, made in using Visual studio the thing is can i add some code to it?
example when it install i just want to run 3-4 lines of code.
1- Get mac address add to database, with a unique key.
And similarly on uninstall remove the mac address from the database .
Is this possible in this current scenario using the default setup project?
You will need to use a CustomAction for your installer. With this you can run a program, script, write a registry key, or whatever. Here's a simple example using a custom installer class to show a message during the installation (in VB.NET but easily translatable):
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
MyBase.Install(stateSaver)
Dim myInput As String = Me.Context.Parameters.Item("Message")
If myInput Is Nothing Then
myInput = "There was no message specified"
End If
MsgBox(myInput)
End Sub
You would need to follow the steps in the link to fully reproduce the sample.
You could use the .NET installer classes and wire those up from the default setup project. You override some methods and then they get called at install/uninstall time. Here's a tutorial on how to do this.
That said, a lot of people hate these .NET installer classes (and the default setup projects) altogether and implement true Custom Actions using a WIX or InstallShield based project.
Depending on what exactly you want to do and when you want to do it, you also introduce a .NET dependency. For example, if you are checking for .NET being installed, you won't be able to do this from a .NET custom action if the user does not have .NET already installed.
Adding Custom Actions is a bit of a slippery slope. Once people realize you can customize the installer, you'll likely be asked to do more and more. At that point it may make sense to use a more flexible tool (WIX (open source) or InstallShield ($)).

packaging vs2005 project

Here are the steps I take to create a package shipped to the end users:
Use visual studio 2005 Build the project (which is library DLL written in C#), both in debug and release mode.
I run doxygen and create documentation
I create a folder structure where I put my dll documentation and some release notes
zip it
ship it
the directory tree structure looks like this:
--NetApi:
--Api
--vs2005
--relesae
--dll
--debug
--dll
--documentation
--htmls files generated by doxygen
--ReleaseNotes.html
--Examples
I am thinking of rolling out a script to automate that. But before I do that, I would like to find out the common practices of packaging library api type of project, particularly structure, and tools used. References and examples are highly appreciated
Thanks
I am a big believer in continuous-integration and automated builds.
We have a rule in our shop that we never, ever, ever provide deliverables to a customer that were not produced by a fully automated, zero or one step build (that means that it took no more than 1 mouse click by a human to baseline, build, package, and release the thing.) These fully automated, one-step builds work by recognizing when a change is made to your source code control system, and automatically triggering the "build script."
For C#, I can recommend both CruiseControl.NET and Hudson.
I can also recommend the Pragmatic Project Automation series of books. Variants of this title should be available for both Java and .NET.
There are lots of prewritten build servers out there that can help you automate this.
For deployment I really like Inno Setup.
It is free, flexible, and can be easily customized to your tastes.

Are there any emacs or vim editors with code completion plugins for C#?

It would be nice if it did both a list of methods to choose from and the list of potential input parameters. This was done for powershell and I was curious if there was any similar functionality implemented for emacs or vim?
Clarification:
A fellow developer I work with wants to use either vim or emacs for the low overhead without running visual studio. In essence he would like to be able to write tests, edit code in emacs or vim then just run NANT scripts to compile the code and run the tests. The only feature from Visual Studio he wants is code completion. The rest he can live without for 98-99 percent of the time.
You can use a vim editor emulator for Visual Studio.
http://www.viemu.com/
I haven't come across an emacs mode that would offer code completion suggestions based on "knowledge" of the API(s) that the user's environment is offering. To a lot of people this is an issue which prevents them from attempting to use Emacs or VIM when working with rich/large/unwieldy (delete as applicable) APIs.
However I am wondering how much of a problem this would present during day-to-day work. I've been using Emacs with C#-mode to crank out quite a lot of C# code. I also tend to run dabbrev-mode or pabbrev-mode, which tends to take care of the more common function and variable names I tend to use. To my eternal shame I have to admit that I tend to have a browser open on the MSDN website to look up the rest - those APIs that I don't use often enough to remember. Another potential helper that your colleague might want to look into is icicles, which may also be a step in the right direction. Neither of these libraries however will offer the full breadth of completion support that something the like Visual Studio IDE will offer. I'd see this as part of the trade-off when using a more efficient editor.
As an aside, if your colleague is working in a team and other members working on the same project are using Visual Studio, MSBuild might offer a better solution for building outside of VS than Nant as MSBuild reads the same solution and project files that VS uses (in fact a lot of the build work in VS2008 is handled by MSBuild). The syntax isn't too far away from Nant and with the community tasks added (which gives you NUnit integration etc) and it'll ensure that everybody is using very similar mechanisms to build the executables.
The furthest along completion I've seen for C# is at this blog, specifically at this post. (Blog link included for context and other Emacs posts.)
If you can live with dumb completion, you might be able to roll your own with tags and tag completion.
A previous stack on the same issue.
Your source code should be processed through the CEDET framework: http://cedet.sourceforge.net/
Then either use the example UIs bundled with cedet or else try any of these two:
- company-mode: http://nschum.de/src/emacs/company-mode
- completion-ui: http://www.dr-qubit.org/emacs.php
both supporting CEDET as a completion search backend.
apa!
for emacs and C# you can look at this tool : http://code.google.com/p/idebridge/
OmniSharp provides contextual intellisense for C# in vim.
Some of the suggestions in Eclipse Style Function Completions in Emacs for C, C++ and JAVA? may be relevant for emacs.
Not c# specific, but still.
I have found the http://code.google.com/p/csense this is an emacs c# intellisense/code sense. I found it from this blog post http://osdir.com/ml/emacs.sources/2007-11/msg00018.html, this may be close to the answer I was looking for.
After looking further it has not been updated since November 2007, looks stale to me.
For Vim, you can install insenvim. It support for the C# code completion.
After download the plugin you could install the installation file or install manually by following steps:
Copy the file cs_vis.vim into your $VIM\vimfiles\ftplugin directory.
Copy the file csft.dll into your $VIM_INTELLISENSE directory.
Copy CSVimHelper.dll,reg.bat to your $VIM_INTELLISENSE directory.
Run reg.bat to register the dlls. You need to set the directory gacutil.exe
in the path. You need the latest version of .NET SDK.

Categories