Publish a .NET console application

Carlos Gómez
devops and cross platform development
3 min readJul 12, 2016

--

After developing a .net console application the next logical step would be to publish the code usually located at /AppName/bin/Release

publish console app release folder

However as you can see in the picture there are a lot of files created after the compilation of the app including an execution file .exe, if you try to execute that file the app will work as usual but the problem arise when you add to your project a nuget package as newtonsoft, because after the compilation of the project this package creates a dll file and this file isn’t included in the .exe file. To see the error you need to copy the execution file into a different folder, then you will get:

Publish console app error

This problem could be solved by using the Visual Studio 2015 extension Microsoft Visual Studio 2015 Installer Projects for create a new “Visual Studio Installer Project”.

Let’s create the installer project

  1. Right click on the solution and click Add → New Project → Other Project Types → Visual Studio Installer → Setup Project
Publish console setup project
  1. After the creation of the project a File System menu will be left open, then right click on the Application Folder → Add → Project Output
publish console add project output
  1. Select the project and the Primary Output option
Publish console add project output group
  1. The setup project must look like
publish console setup project tree
  1. Finally is necesary to make a build in the setup project, this will create a .msi file in the Release folder of the solution. Open the project in the file explorer and you should have a /Release/PublishConsoleAppSetup.msi this file could be executed from another location and your .net console application would be installed as a normal system application
publish console system application

Source code: https://github.com/devcfgc/publish-console-app

--

--

Cloud/Software Architect and DevOps learning about #devops, #cloud, #netcore, #microservices and #newtech