Skip to content
⌘ NSIS Forum Archive

visual Studio 2010 cmd tools

8 posts

kolorowy#

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.

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?
JasonFriday13#
Try removing the double quotes:

nsExec::ExecToStack `"$0" /k '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat" MSBuild.exe'`
Anders#
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"
kolorowy#
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."
LoRd_MuldeR#edited
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:
@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"
kolorowy#
Thank you, that is the route I took, using batch file to build my solutions and finally compile nsi script.
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...
jaromanda#
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