Visual Studio - Add file from a relative position

One of the things I encounter when working with Visual Studio solutions + plugins is that the plugin has to be either manually updated or some other hack has to be made. If you take the usual route of "Add Existing File" from the context menu in your solution and select the plugin DLL file from another project, Visual Studio copies the file over to your new project.

This can be very annoying. If you update the plugin in any way, your project still has the old copy in it's directory and the real updated version lies in another folder. There is no shortcuts for this but you can add the plugin file to your project by specifying a relative position, resulting with the new project always copying the latest plugin version to the output folder.

To do this you must open your new projet .csproj file in your favorite editor. There you should see something like this:

  <Content Include="plugins\MyPlugin.dll" />

Change it like so:

  <Content Include="..\MyPlugin\bin\Debug\MyPlugin.dll">

By manually changing the "Include" to a relative path, you can link your plugin project output directly to the main project. The Link is where you will position the file in your output folder of your project, if Link is not specified, the file will be copied to the root of your output directory. Here I specified that it should go under a subfolder called plugins. If the folder does not exist, one will be created automatically.

Show Comments