Pincopallino
Pincopallino

Reputation: 651

Launch NSIS when building with Visual Studio

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?

Upvotes: 1

Views: 970

Answers (2)

HackSlash
HackSlash

Reputation: 5813

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)

Upvotes: 0

Anders
Anders

Reputation: 101756

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

NSIS can also read files with !searchparse

Upvotes: 1

Related Questions