Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have recently developed an application in C# .NET and now I have to create the corresponding setup. I need to implement a specific logic during the setup phase and for this reason I chose to use NSIS. In particular I need to write some information in the .config file of my application. I have tried to use a macro based on nsisXML.dll that I found here: http://nsis.sourceforge.net/Talk:NsisXML_plug-in_%28by_Wizou%29[^], but it doesn't work!

The compiler doesn't give any error, but when I launch the setup I obtain a Windows message: "Setup.exe has stopped working - Windows is checking for a solution to the proble..."

So I don't know what may cause the error!!

If someone has a different solution to write in a .config file with NSIS, I will be pleased to read it. Thanks!!
Posted

You would find it easier and more maintainable if you create your "config" program in a .net language instead of writing scripts in NSIS.

You can start this config program after the copy process at the end of installation script using ExecWait
 
Share this answer
 
Eventually I have decided to follow the advice to write C# code to manage the config file.
So I wrote a .dll in C# and then I used it as ReserveFile in my NSIS script, using CLR NSIS (http://nsis.sourceforge.net/Call_.NET_DLL_methods_plug-in[^]) plug-in which allows to call methods in a managed .NET DLL.
So I wrote a function in the NSIS script with the subsequent code:
CSS
Function WriteConfig
InitPluginsDir
  SetOutPath "${NSISDIR}\Plugins\"
  File "${NSISDIR}\Plugins\MyNETdll.dll"
CLR::Call /NOUNLOAD "MyNETdll.dll" "Namespace.Class" "Method-To-Write_in-Config" 3 "Config path" "Key" "Value"
CLR::Destroy
FunctionEnd

where "3" is the number of parameters that the method accepts and the subsequent strings are the parameters themselves.

In this way, whatever method written in C# can be called from the NSIS script!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900