---
description: >-
  On this page we explain how to setup debugging in Visual Studio so you can
  debug your plugins while running an Onset server.
---

# Debugging

## Prerequisites

We assume that you already have a running Onset server, Onsharp installed and a theoretically working plugin project.

### Setup Debugging

1. First of all, activate dependency export for your project, if you does not have it currently:
   1. Therefore right click your project and **Edit Projectfile** (.csproj)
   2. Search the line with the **TargetFramework**
   3.  Put the following line below the TargetFramework line:

       `<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>`
2. Go to the properties page of your project (_**Right-Click on Project** -> **Properties**_)
3. Head over to the **Debugging** page
4. Change the **Launch** dropdown to _**Executable**_
5. Select the _**OnsetServer.exe**_ of your Onset server in your server directory via the **Browse** button close to the textbox and the **Executable** label
6. Select _**your server directory**_ under **Working Directory**
7.  Now head over to the **Build Events** page and put the following commands into the text area for post-build event (Post-build event command line): _view below_

    Replace YOUR\_SERVER\_DIRECTORY with the path to your server directory. Keep in mind to change every slash (/) in the path to a backslash (\\)
8. Now your debugging can begin!

The commands for the post-build event command line:

```bash
copy /Y "$(TargetPath)" "E:\Development\Onset\_test-server\onsharp\plugins\$(TargetFileName)"

del /Q "$(TargetPath)"

del /Q "$(OutDir)\$(TargetName).deps.json"

del /Q "$(OutDir)\$(TargetName).pdb"

del /Q "$(OutDir)\Onsharp.dll"

del /Q "$(OutDir)\DotNetZip.dll"

del /Q "$(OutDir)\Goblinfactory.Konsole.dll"

del /Q "$(OutDir)\Nett.dll"

del /Q "$(OutDir)\Newtonsoft.Json.dll"

del /Q "$(OutDir)\Serilog.dll"

del /Q "$(OutDir)\Serilog.Sinks.Console.dll"

del /Q "$(OutDir)\System.Security.Permissions.dll"

xcopy /Y "$(OutDir)" "YOUR_SERVER_DIRECTORY\onsharp\libs"
```

