Archive: Integrating NSIS with Visual Studio/MSBuild


Integrating NSIS with Visual Studio/MSBuild
Hi Guys,

Ive seen a few people asking about building NSIS installers with Visual Studio (MSBuild), so i whipped up a custom MSBuild task that should let you accomplish this.

Full source and an example is included in the attachment below, as well as a template for adding this to your own solution. just open template.vbproj, and edit as needed

NOTE: This took me about an hour to do. It hasnt been tested very thoroughly. It probably meets most definitions of the term "Dirty Hack". YMMV.

i will be happy to answer any questions/problems/feature requests/feedback etc

Thanks,

->InsertJokeHere<-


Hi
Your idea looks great but I got a lot of errors when I tried to compile your project.

I am using Visual Studio 2008 and your project is for VS 2010, so I downgraded .sln and related stuff.
Then I got lot of error for Microsoft.Build.Utilities.v4.0 which you are using, because I use Microsoft.Build.Utilities.v3.5.
Quote:


All this errors are related to .net Framewrok - in your version [4.0] everything is present, but not in 3.5 which I use.
So is there possibility for you to create a lower version? I mean target framework should be 3.5.

Error 1 'GeneratedCodeAttribute' is ambiguous in the namespace 'System.CodeDom.Compiler'.
Error 2 'EditorBrowsableAttribute' is ambiguous in the namespace 'System.ComponentModel'.
Error 3 'EditorBrowsableAttribute' is ambiguous in the namespace 'System.ComponentModel'.
Error 4 'GeneratedCodeAttribute' is ambiguous in the namespace 'System.CodeDom.Compiler'.
Error 5 'EditorBrowsableAttribute' is ambiguous in the namespace 'System.ComponentModel'.
Error 6 'ApplicationSettingsBase' is ambiguous in the namespace 'System.Configuration'.
Error 7 'ApplicationSettingsBase' is ambiguous in the namespace 'System.Configuration'.
Error 8 'HelpKeywordAttribute' is ambiguous in the namespace 'System.ComponentModel.Design'.
Error 9 Name 'NSISEngine' is not declared.
Error 10 Name 'NSISEngine' is not declared.
Error 11 'Process' is ambiguous in the namespace 'System.Diagnostics'.
Error 12 Property without a 'ReadOnly' or 'WriteOnly' specifier must provide both a 'Get' and a 'Set'.
Error 13 Statement cannot appear within a property body. End of property assumed.
Error 14 Property missing 'End Property'.

Couldnt figure out how to edit my original post, so i will just make another one.

Attached is a zip containing both visual studio 2010 and visual studio 2008 version (.net 4 and .net 3.5 respectively). they should behave exactly the same. The visual studio 2008 version may give you a security warning about custom tasks (because it contains custom tasks), but this can be safely ignored


It is much better, Thanks!


hey, i don't know if you still follow this, but i am interested in making this work, but i am kind of noob when it comes to these extra features of visual studio.

how do i make my existing project into an NSIS installer package using this?

i have NSIS installed and i downloaded the VS2010 zip file you attached, but i don't know where to fit the pieces :|


1. Grab the zip in my second post, and extract it somewhere
2. Pick the appropriate folder for the visual studio version you are using
3. move the NSISCTask folder into the folder for your visual studio solution
4. add the project for that folder as a project in your solution inside visual studio
5. edit template/template.vbproj with a text editor
6. set the <Compile Include="..." /> line to have the name of your .nsi file
7. if you have any .nsh files, add them as <Header> entries, otherwiser remove that whole ItemGroup
8. set NSISEngine to point to your makensis.exe (either in C:\Program Files\.... or C:\Program Files (x86)\...)
9. add template.vbproj as a project in your solution

you should now be able to build a .nsi from within visual studio by right clicking on this project and selecting build, or if you use some kind of continuous integration by invoking msbuild


Hey AC_Sherway

I appreciate insertjokehere's tool but it is a really "hardcore solution".

It is a long time since this tool was published: it was great in those times but there were some problems and lack of functionality so I decided to develop my own solution called "Visual & Installer".
It is an extension for developing NSIS project directly in Visual Studio and it is really easy to use it.
Check my signature if you are interested in it, you can download it for free (Trial).

Sorry for self promotion :cool: