Build same Project as Console and DLL

Console Application is the type of your project. You can not change it.

What you can -and must- do is, carry your logic into a Class Library project and use your class library from any type of project you want.


it is generally possible to reference a .net exe assembly as it would be a class-library.

So you can just stick in creating an exe file and reference the exe (sounds strange, but works) in your other project.

This is the dialog for browsing for references. As you see you can select exe files. Browse for Reference Dialog

But as commented it really depends on what your usecase is. I don't recommend to ship an exe with an entry point to your customer hoping that the customer does not discover the exe. But what you could do about that is to conditionaly compile your entry point.

For example

class Program {
  // This is the entry point of the EXE
  public static void Main() {
#if DEBUG
  // Start Debug Application
  ...
#else
  // Shipped to client - Entry point disabled
  return;
#endif
  }
}

If there is a relevant reason to have a shipped exe and a shipped class library, I would refactor your solution like this:

  • (A) complete application (.sln)
    • (B) console-application (.csproj) which has a reference to (C)
    • (C) class library project (.csproj)

With that it is perfectly clear to others that there is an application that uses the library and the library itself.


To my knowledge there is no possibility to change the output type after compilation. That being said, if would be possible to have two projects like Console and Library in your solution, which would use the same source code files but have different output types. That way you would have different outputs without any duplication of code.