Old 17th February 2014, 20:52   #1
kolorowy
Junior Member
 
Join Date: Feb 2013
Posts: 9
visual Studio 2010 cmd tools

Hello,

I have created a NSIS installer for all my C# projects and works great. Now I want to automated the process of building C# projects and include them in NSIS installer. Right now this process is manual, run build in visual studio, copy dll or exe and build NSIS installer.

I know Visual Studio has post-build where I can have command for each project. I want to stay away from this and have everything driven by NSIS scrip.

What I would like to do is have separate NSIS script that will build all my projects and once done build NSIS installer.

I wanted to used Visual Studio 2010 cmd tools but I can't figure out how to run batch file which sets up temporary environment variables for CMD session and call msbuild.exe after variable is set.

code:
ExpandEnvStrings $0 %COMSPEC%
nsExec::ExecToStack '"$0" /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat" MSBuild.exe"'



This calls the Visual Studio batch file to setup environment variable, which works but once it's done msbuild.exe command or any other command after that are not being called. At this point I have CMD window with all environment variables waiting for commands.

Any thoughts?
kolorowy is offline   Reply With Quote
Old 17th February 2014, 21:12   #2
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 907
Try removing the double quotes:

nsExec::ExecToStack `"$0" /k '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat" MSBuild.exe'`

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 18th February 2014, 05:04   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
Why are you using runtime functions?

It would make more sense to use !system. You can build a batchfile with !appendfile or just something like !system "app1&&app2"

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 18th February 2014, 22:13   #4
kolorowy
Junior Member
 
Join Date: Feb 2013
Posts: 9
This is separate script that calls msbuild to create dll and exe. Once all dlls and exes are created it will call my .nsi script to compile which will include all new dlls and exes. I know it is possible to use compile time commands but that is not a problem.

JasonFriday13 indicates correct way of doing this but it appears the batch file is execute and msbuild command fails due to the environment path is incorrectly as I get error: "The filename, directory name, or volume label syntax is incorrect."
kolorowy is offline   Reply With Quote
Old 18th February 2014, 23:51   #5
LoRd_MuldeR
Major Dude
 
LoRd_MuldeR's Avatar
 
Join Date: Sep 2005
Location: Somewhere over the Slaughterhouse
Posts: 797
Quote:
This is separate script that calls msbuild to create dll and exe.
Usually you would compile your DLL and EXE before invoking NSIS to build your installer.

If I understand you right, then you have a special NSIS script, just for controlling/driving the build process. If so: While it's certainly possible to "abuse" NSIS to write such a build script, it doesn't seem like the most obvious choice. So why not simply use a Batch file that first calls MSBuild.exe to compile your EXE/DLL file and, once that is done, calls MakeNSIS.exe to build the actual installer?

Try something like this:
code:
@echo off
set "VS_PATH=C:\Program Files (x86)\Microsoft Visual Studio 10.0"
set "NSIS_PATH=C:\Program Files (x86)\NSIS"
echo === Compile Binaries ===
call "%VS_PATH%\VC\bin\vcvars32.bat"
MSBuild.exe /target:Rebuild "%~dp0\MyApplication.sln"
echo === Build the Installer ===
"%NSIS_PATH%\MakeNSIS.exe" "%~dp0\MyInstaller.nsi"


My Plugins: StdUtils | NSISList | CPUFeatures | ExecTimeout | KillProc
My source of inspiration: http://youtu.be/lCwY4_0W1YI

Last edited by LoRd_MuldeR; 19th February 2014 at 01:07.
LoRd_MuldeR is offline   Reply With Quote
Old 19th February 2014, 21:00   #6
kolorowy
Junior Member
 
Join Date: Feb 2013
Posts: 9
Thank you, that is the route I took, using batch file to build my solutions and finally compile nsi script.
kolorowy is offline   Reply With Quote
Old 24th February 2014, 06:10   #7
T.Slappy
Major Dude
 
T.Slappy's Avatar
 
Join Date: Jan 2006
Location: Slovakia
Posts: 555
Send a message via ICQ to T.Slappy
Maybe it is easier to use (my) Visual & Installer tool for Visual Studio 2005 - 2013?

It offers more possibilities, syntax highlighting, code completion and many other features...

Cool looking installers with custom design: www.graphical-installer.com
Create Setup Pages easily: www.install-designer.com
Build installers in Visual Studio 2005-2019: www.visual-installer.com
or RAD Studio 2009, 2010, XE-10.4 Sydney: www.rad-installer.com
T.Slappy is offline   Reply With Quote
Old 25th February 2014, 04:55   #8
jaromanda
Forum King
 
Join Date: Jun 2007
Location: Under the bridge
Posts: 2,289
Quote:
Originally Posted by T.Slappy View Post
Maybe it is easier to use (my) Visual & Installer tool for Visual Studio 2005 - 2013?

It offers more possibilities, syntax highlighting, code completion and many other features...
and a bargain at only $100 per year per seat






pass

"If you don't like DNAS, write your own damn system"

So I did
jaromanda is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump