4

I am going to create a .dll and an .exe using this .dll with C# and .NET.

How to create a .dll subproject in Visual Studio Code editor?

I develop on Debian Linux.

MinnuKaAnae
  • 1,646
  • 3
  • 23
  • 35
porton
  • 5,214
  • 11
  • 47
  • 95
  • Just add class library in a project and write your logic there and build that you will get a dll in your project bin/debug folder – M.Y.Mnu Dec 07 '17 at 12:58
  • @M.Y.Mnu I am a novice with C#. I don't quite understand you. Could you elaborate? – porton Dec 07 '17 at 12:59
  • @M.Y.Mnu How to "add class library in a project"? – porton Dec 07 '17 at 13:01
  • right click on your project and add project and choose class library from tamplate – M.Y.Mnu Dec 07 '17 at 13:04
  • @M.Y.Mnu Where to right click? I clicked in various parts of the editor window and see no "reference option" – porton Dec 07 '17 at 13:06
  • you have to right click to on project solution and add a project and choose class library option – M.Y.Mnu Dec 07 '17 at 13:08
  • Follow this [link](http://www.c-sharpcorner.com/UploadFile/rohatash/creating-dll-using-class-library-in-net-framework/) – M.Y.Mnu Dec 07 '17 at 13:10
  • @M.Y.Mnu The link you gave is about Visual Studio but I have (what I assume is it's stripped down version) Visual Studio Code. And I have no "File" -> "New" -> "Project..." in the menu which is recommended to click there – porton Dec 07 '17 at 13:12
  • I created a class library by `dotnet new classlib -n xyz` command, I can access it from the main program, but I have one `.dll` file while I want two assemblies: for the main program and for the xyz library. – porton Dec 07 '17 at 13:31

1 Answers1

1

Create folders for both the main .exe project and for the .dll subproject. .dll subproject folder should not be inside the main project folder.

Then in the main project folder run

dotnet add . reference ../xyz/xyz.csproj

where xyz is the name of the .dll subproject.

After this building the main project automatically builds the subproject too. Exactly what I need.

porton
  • 5,214
  • 11
  • 47
  • 95