question

GaryFuhr-5223 avatar image
0 Votes"
GaryFuhr-5223 asked cooldadtx commented

Why are non-dependent DLLs copied into the project Bin folder?

Why are the following files dumped into the Bin folder when our application does not require them?
Problem is the files are then distributed into production environment. Why distribute DLLs that are not required?
Is there a way to tell Visual Studio to not copy these files into the Bin folder?

TIA, Gary.

EnvDTE.dll
EnvDTE80.dll
Microsoft.Build.Framework.dll
Microsoft.Build.Tasks.Core.dll
Microsoft.Build.Utilities.Core.dll
Microsoft.MSXML.dll
Microsoft.VisualStudio.ComponentModelHost.dll
Microsoft.VisualStudio.Data.Core.dll
Microsoft.VisualStudio.Data.Services.dll
Microsoft.VisualStudio.Debugger.Interop.11.0.dll
Microsoft.VisualStudio.Debugger.InteropA.dll
Microsoft.VisualStudio.Designer.Interfaces.dll
Microsoft.VisualStudio.Designer.Interfaces.xml
Microsoft.VisualStudio.GraphModel.dll
Microsoft.VisualStudio.ManagedInterfaces.dll
Microsoft.VisualStudio.OLE.Interop.dll
Microsoft.VisualStudio.ProjectAggregator.dll
Microsoft.VisualStudio.Shell.Immutable.10.0.dll
Microsoft.VisualStudio.Shell.Immutable.10.0.xml
Microsoft.VisualStudio.Shell.Immutable.11.0.dll
Microsoft.VisualStudio.Shell.Immutable.11.0.xml
Microsoft.VisualStudio.Shell.Immutable.12.0.dll
Microsoft.VisualStudio.Shell.Immutable.12.0.xml
Microsoft.VisualStudio.Shell.Immutable.14.0.dll
Microsoft.VisualStudio.Shell.Immutable.14.0.xml
Microsoft.VisualStudio.Shell.Interop.10.0.dll
Microsoft.VisualStudio.Shell.Interop.11.0.dll
Microsoft.VisualStudio.Shell.Interop.8.0.dll
Microsoft.VisualStudio.Shell.Interop.9.0.dll
Microsoft.VisualStudio.Shell.Interop.dll
Microsoft.VisualStudio.TemplateWizardInterface.dll
Microsoft.VisualStudio.TemplateWizardInterface.xml
Microsoft.VisualStudio.TextManager.Interop.10.0.dll
Microsoft.VisualStudio.TextManager.Interop.8.0.dll
Microsoft.VisualStudio.TextManager.Interop.dll
Microsoft.VisualStudio.VSHelp.dll
Microsoft.VisualStudio.WCFReference.Interop.dll
Microsoft.VisualStudio.WCFReference.Interop.xml
stdole.dll
VSLangProj.dll
VSLangProj2.dll
VSLangProj80.dll

dotnet-csharpvs-general
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Based on the provided link, I could use the Post-Build event to remove the unwanted DLLs for the Release build.
I guess this is an optional if nothing else works or is available. Thanks.

0 Votes 0 ·

Collect MSBuild bin log, and then it is much easier to track the source of those files and why, https://msbuildlog.com/

0 Votes 0 ·

This looks interesting ... and complex! :( All the information is great, but I could see this taking a lot of time to sort through.

0 Votes 0 ·

Try to use text search, as it works through the entire log. It also takes you a while to get familiar with the build process (and its logging patterns), so you might first try the binlog of a very simple .NET application (like hello world).

0 Votes 0 ·
Show more comments

1 Answer

cooldadtx avatar image
0 Votes"
cooldadtx answered cooldadtx commented

The assemblies you list are all VS support assemblies. What kind of project are you building exactly? Are you targeting .NET Framework or .NET Core/5? Have you looked at the list of dependencies in your project(s) to see what references are actually being used?

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The project is an ASP.NET Webforms project targeting .NET Framework 4.7.2. None of these DLLs are listed in the references.
I do have about 30-40 references in the Reference folder. Most are definitely required. There might be a few that are not.
Is there a tool that can report which references are not required?

0 Votes 0 ·

None of those assemblies should be referenced in your code then and therefore they shouldn't be in the output directory unless you have an extension that is messing things up. I'd recommend doing the following. Create a brand new ASP.NET webforms project and build it. Do the assemblies show up there as well? If so then I'd lean toward an extension causing the problem. Disable any extensions you have and rebuild the solution. If the assemblies go away then one of your extension is incorrectly adding them.

If a new solution has no issues then the problem lies in one of your dependencies and could be caused by a third party control you're using incorrectly adding runtime references to VS assemblies.

0 Votes 0 ·

In VS Preview is a new refactoring to remove unused assembly references from your project. This will scan for references that aren't explicitly used in your code. It can be dangerous though as sometimes we add references to dependencies so we can control the dependent version instead of relying on Nuget's transient dependencies, which can be wrong.

Also note that C# already removes unused references during compilation. So this wouldn't impact the final assembly references. It just cleans up your direct dependencies.

0 Votes 0 ·