Building a msi Installer using MSbuild - msbuild

I have a Dotnet Windows application built using visual studio 2015.
I am trying to automate the build using MSbuild and Jenkins.
The output files are Setup.exe & MyAppSetup.msi.
I want to use MSbuild and the VS2015 solution file, without using the VS IDE.
The Visual studio solution has 6 projects and all the projects should be built together to generate the .msi installer.
The setup.exe and .msi files are being built using the setup project file(.vdproj).
How do I build the same solution using MSBuild ?

msbuild does not have support for setup projects.
To integrate with Jenkins, you will have to use devenv (VS IDE).
Note: starting VS 2013, vdproj support is provided by an add-in.
Find more information on the following blog: https://juristr.com/blog/2014/03/Jenkins-Build-Setup-Project/

Related

how to solve Jenkins Build Failed Error :MSB4041

I have build this project as .Net standard project and i am facing this error issue in jenkins when I build this project:
C:\Users\tahab.jenkins\workspace\Mondaytest\Calculator\Calculator.csproj(1,1):
error MSB4041: The default XML namespace of the pr.oject must be the
MSBuild XML namespace. If the project is authored in the MSBuild 2003
format, please add
xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the
element. If the project has been authored in the old 1.0 or
1.2 format, please convert it to MSBuild 2003 format
Make sure you use recent versions of the MSBuild task you use to build your project.
You need too use the Visual Studio 2017 (Build Tools, Full, ..) version of MSBuild - which is local to the Visual Studio installation - to build your project.
You may need to confiure the path to MSBuild, which would be - depending on the version installed on the build gent - similar to
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
This error happens if you try to build new projects with older versions of Visual Studio / MSBuild or even with the old version of MSBuild that is part of .NET Framework.

Building an installer, to install dlls to the gac, with MSBuild

I have a dll project which I need to install into the GAC, on our Production machines.
(I wish I didn't have to use the GAC but SSIS insists)
gacutil.exe is not available on the target machines and using "Enterprise.Services" from PowerShell does not work (I don't know why)
My understanding is I should created a msi installer project.
However after installing the Setup and Deploy Extension to Visual Studio (2015 soon to be 2017), I discovered those projects cannot be built by our Build Server because it uses MSBuild, and MSBuild can't build vdproj project files.
What is the correct way, using a CI build pipeline (MSBuild), to create build artifacts, which can install dlls to the GAC, of a Production Environment?
Note: there are several partial answers on SO, but I could not find any, which were up to date/answer my whole question. Please keep that in mind when answering.
You need to break this down into several user stories. You aren't finding partial answers, you are finding actual answers for specific questions. What you ask is more like an epic.
In general I would create an MSI using Windows Installer XML. WiX/MSI can install files to the GAC without using GACUTIL. If you use the WiX Visual Studio extension "Votive" you can create a .SLN / .WIXPROJ / .WXS that can be built using MSBuild. You can then put this into a source control system such as Git/TFVC/Subversion and use a build system such as VSTS V.Next Build, XAML Build, Concourse, Jenkins to automation the pipeline to build the MSI.

How to build a VS2010 configuration of a VS2015 solution using MSBuild?

I have a Visual Studio 2015 C++ project (solution) of which most build configurations use the VS2015 toolset. However, some configurations are set to use the VS2010 toolset because they link to 3rd party libraries built using VS2010.
All configurations build successfully from within the IDE, and the VS2015 configurations build successfully using MSBuild on the command line, but I am having trouble building the VS2010 configurations using MSBuild.
I invoke msbuild as follows:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
msbuild MSVC\mysln.sln /p:Configuration="myVS2010Config" /p:useenv=true
For the VS2010 configuration I get error:
error C2039: 'gets': is not a member of 'std'
which suggests that the VS2015 compiler is being invoked, not the VS2010 compiler.
Why isn't MSBuild invoking the VS2010 tools?

Problems with WiX and Visual Studio web deployment project

We want to create an .MSI package from a web deployment project in Visual Studio 2008.
Now we want to use continuous integration and we would need the .MSI package build in the nightly builds.
Till now we used standard Visual Studio Web Setup project, but this is not compatible with the MSBuild. So we decided to use WiX.
The problem is that I have not found any good tutorial/documentation about this.
Is there a way to do a WiX installer package from a web deployment project? If yes, how?
Also, I tried to use heat.exe to create the XML for the WiX project .wxs file, but it seems that heat.exe doesn't recognize the web deployment project format.
Thank you for your responses.
Regards,
V.
I wrote a blog post about this recently - http://www.chrissurfleet.co.uk/post/2011/07/01/Using-Packaged-Project-Output-in-WiX-and-Visual-Studio.aspx
In short, its fairly easy to use msbuild to package up your web app and then pass it to heat to generate your installer from.
Hope this helps.
You've probably long since found a solution for this, but to elaborate on Tom Cabanski's answer, you can invoke Visual Studio to build the msi on the command line using "devenv.com" via an external process from within your build. It's not a pretty as using msbuild, but it gets the job done. Below is an example of how to invoke Visual Studio:
"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com" your.sln /build Release
Where your.sln is the solution file for the solution you wish to build, and Release is the configuration you wish to build, ensuring that the configuration you choose actually builds the vdproj project.
Following the successful execution, you can grab the msi from the appropriate configuration's bin, and do what you want with it.
I'd appreciate your response to this with your findings/approach, as I'm trying to decide whether to adopt WiX or InstallShield as the approach to building msi's for Web Applications within TFS Build, or to continue with the approach I just described. I haven't had to opportunity to try WiX out, and my very limited exposure to InstallShield suggests that this is far to involved for my need, which is to produce a simple deployment aid for some relatively straight-forward web applications to the company intranet via TFS Build.
We used WIX on the installers for our last couple of projects and ended up regretting it. I would stick with the VS built-in projects and just invoke the VS IDE from the command line in the CI build.

Automate publish of ClickOnce using Visual Studio 2008

I have a Visual Studio solution file (.sln), with several projects (VB.NET and C#, .vbproj, and .csproj files, respectively), and I have a Windows application, and I use ClickOnce to publish it.
Now, I need automate the Publish option using MSBuild or another good solution (cmd, VBScript, or BAT scripts).
How can I do it?
Well, ClickOnce uses MSBuild to publish itself. Therefore I would recomment to use MSBuild for your build-automation. See the reference on MSDN.
The first step is easy. You just run MSBUild with 'Publish'-target from the console. The settings made in Visual Studio are applied.
However, there are some tricky bits. For example, when you run it from the command line, the version number isn't increased. In my project I've solved this by passing the version-number from the build script.
Another tricky-part is when you want to run the build script on your build-server without Visual Studio installed. There you might have to copy some to make it work.