Search code examples
referencemsbuildvisual-studio-2017copy

Prevent Visual studio 2017 from copying almost 100 unnecessary system dlls to output folder for dll project


I made a new .NET Class Library solution if TFS, and added a bunch of preexisting classes that were developed for a windows forms application. Basically just dumped the old folder in. The forms app worked fine and the folders in bin were expectedly barren, apart from the exe and the required nuget references. The dll build however copies over libraries all the way from Microsoft.Win32.Primitives.dll, to System.Xml.XPath.XDocument.dll for no apparent reason. I have removed unused references with ReSharper and commented out unnecessary using statements. No difference whatsoever. I don't think it's a problem from the deployment perspective, it's just annoying to have so many files copied over each build. Could it be that the initial presence of Forms just poisoned the new project forever? Any help whatsoever would be much appreciated.


Solution

  • Prevent Visual studio 2017 from copying almost 100 unnecessary system dlls to output folder for dll project

    Please check if your VS2017 is very old and also check if the framework version of your project targets to 4.6 or 4.7.1.

    If so, there is an known issue about this issue.

    This is a .net standard 2.0/net 4.6/4.7.1 issue which was improved in 4.7.2. You can check this similar issue.

    Suggestion

    1) you should first update your VS2017 in case some updates fix it.

    2) change the framework version of your project to net framework 4.7.2.(if you do not have net frameowork 4.7.2, you should install it in the VS Installer)