title: How to publish a Console Application that uses 3rd party references?
body: <p>My problem might seem specific, but in fact it is probably very general: How to publish a Console Application that uses 3rd party references?</p>
  
  <p>I am using Visual Studio 2015 to make a Console Application called Gdx2PostgreSql programmed in Visual Basic. The application is reading data in a Gdx-file (output from a GAMS program, www.gams.com) and writing the data to a PostgreSql database. The interface to PostgreSql is handled by NpgSql, www.npgsql.org. NpgSql is referenced as </p>
  
  <pre><code>\\dtu-storage\hela\Documents\Visual Studio 2015\Projects\GDX to PostgreSQL 2\packages\Npgsql.3.1.7\lib\net451\Npgsql.dll
  </code></pre>
  
  <p>The program functions correctly when it is executed in Debug mode inside Visual Studio.</p>
  
  <p>I have to be able to run the program from the command prompt in a CMD window. Moreover, I have to be able to run the program by spawning from a GAMS program using the GAMS syntax </p>
  
  <pre><code>Execute 'Gdx2PostgreSql "FileName.gdx" "CaseName"';
  </code></pre>
  
  <p>I have published the program and run the setup file installing the program. But when I run it in a CMD window I get the error:</p>
  
  <pre><code>'Gdx2PostgreSql' is not recognized as an internal or external command, operable program or batch file.
  </code></pre>
  
  <p>I get the same error message when spawning from my GAMS program.</p>
  
  <p>Being rather desperate I have tried renaming the file setup.exe in the Publish-folder to Gdx2PostgreSql.exe. When I use this file I get:</p>
  
  <pre><code>Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Npgsql, Version=3.1.7.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' or one of its dependencies. The system cannot find the file specified.
  </code></pre>
  
  <p>That is, NpgSql is not known to the program.</p>
  
  <p>As I see it, I need to have one EXE-file that holds all what is needed - especially because my program should be able to run on other PCs, too.</p>
  
  <p>Can anyone help me make my program Gdx2PostgreSql function?</p>
  
  <p>Finally, I should mention that I have made other programs reading Gdx-files and using NggSql to write to PostgreSql. These programs function correctly, but they are Windows Forms Applications – and not Console Applications.</p>