1

I have written a NSIS script for my project, and I would like to automatically create the setup file when I build the project. How can I do this with Visual Studio? Is there a way to pass parameters to the script? I mean, I would like VS to pass the Assembly Version to the script. Right now, I have to manually edit a line in the script

VIProductVersion 1.5.0.1

and I sometime forget to update it. Is there a way to automate the process?

Pincopallino
  • 651
  • 1
  • 8
  • 21

2 Answers2

1

You can create defines and/or execute script instructions by using the /D and /X makensis parameters

NSIS can also read files with !searchparse

Anders
  • 97,548
  • 12
  • 110
  • 164
  • Thanks for the /D and /X parameters, they where exactly what I needed, but how do I make VS output the Assembly version, so that I can pass it to makensis.exe? I was trying to get the version string from the file attributes of the project executable using the Powershell, but maybe there is a simpler method – Pincopallino Feb 18 '12 at 08:44
0

There are two questions here.

Q1. Launch NSIS when building with Visual Studio?

A1. Make a Post-build event that runs makensis on the .nsi file:

"C:\Program Files (x86)\NSIS\makensis.exe" "$(ProjectDir)\NSISInstaller\Installer.nsi"

Q2. Pass the Assembly Version to the post build event?

A2. Answered here: Determine assembly version during a post-build event

Combined solution should be:

"C:\Program Files (x86)\NSIS\makensis.exe" "$(ProjectDir)\NSISInstaller\Installer.nsi" /DPRODUCT_VERSION=$(AssemblyVersion)
HackSlash
  • 4,944
  • 2
  • 18
  • 44