Home > front end >  Create symbolic link instead of coping the content to the output directory
Create symbolic link instead of coping the content to the output directory

Time:11-01

Let's assume I've a Visual Studio solution with 50 C# projects.

Project 1 has a native DLL which gets loaded from Project 1.

All other projects depend on Project 1.

The native DLL has size of 200 MB and the Copy to Output Directory is set to Copy if newer.

When I build this solution, the content of Project 1 is copied to the bin\Debug and bin\Release folders of all projects. So I'm having 100 copies of this native DLL which has size of 200 MB. So in total 20 GB.

How can I avoid that huge size of my solution directory? It would be nice if I could avoid coping the content of Project 1 and use a symbolic link instead. But I found no way for it.

CodePudding user response:

Not sure, if that suits your needs, but you can "instruct" MSBuild (does not work when building from/inside Visual Studio) to use hard links, instead of actual file copies.

There are a number of properties that influence the respective behaviour, when set to true:

  • CreateHardLinksForCopyFilesToOutputDirectoryIfPossible
  • CreateHardLinksForCopyAdditionalFilesIfPossible
  • CreateHardLinksForCopyLocalIfPossible
  • CreateHardLinksForPublishFilesIfPossible

Basically, they set the UseHardlinksIfPossible property of the Copy-task in given situations (so you could instruct your own Copy-Task usages with this as well).

Another option would be to use a common output directory for all projects. That, however, has its own set of implications (further info by searching for "UseCommonOutputDirectory").

CodePudding user response:

I'm not familiar with symbolic link. But you can see enter image description here

The bin\debug folder will be cleaner: enter image description here

  • Related