Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build same Project as Console and DLL

I've got an C# Project in Visual Studio, which has Console Application as Output Type.

But I also need a Class Library of this project for another solution.

Right now I have to switch the output type every time, but I wonder if it's possible to generate exe and dll at the same build-event?

Is there a post-build-event for this?

like image 858
Smartis Avatar asked Aug 17 '16 07:08

Smartis


People also ask

How do I use DLL in another project?

Solution 1Add a reference to the DLL directly to your new project: open your project in VS, expand the Project branch in the Solution explorer, then right click "References". From the context menu, select "Add Reference..." and wait for the dialog - If can take a little while to appear.

How do you compile and run a console based C# program in Visual Studio?

Open Visual Studio, and choose Create a new project in the Start window. In the Create a new project window, select All languages, and then choose C# from the dropdown list. Choose Windows from the All platforms list, and choose Console from the All project types list.

How do I create a DLL project in Visual Studio?

To create a DLL project in Visual Studio 2019On the menu bar, choose File > New > Project to open the Create a New Project dialog box. At the top of the dialog, set Language to C++, set Platform to Windows, and set Project type to Library.


1 Answers

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.

like image 200
Codor Avatar answered Oct 04 '22 09:10

Codor