Why MVVM Light copies system assemblies to applica

2019-06-16 08:44发布

问题:

Adding MVVM Light reference to a WPF projects adds a large number of system assemblies to the list of dependencies in the accompanying MSI Setup project. These assemblies (50+ in number) are then copied to the application folder when the app is installed. Why is it so? Why can't it reference it from GAC directly?

Note: Copy Local option is set to True for MVVMLight.dll. I obviously can't set it to False.

Reproducing it is extremely simple. I'm using VS2015 Community.

  1. Create a new WPF Application project.
  2. Add NuGet reference to MVVM Light (or the Lib-only version; doesn't matter).
  3. Add an MSI Setup project to the solution (must have the extension installed).
  4. Add Primary Project Output of WPF application to the setup project.

There you go. A long list of System.X.Y will be added to the list. If you build and install the setup project, you'll see all these DLLs in Program Files folder.

Why? And how to fix it?

Update

The problem does not appear if WPF application targets .NET Framework 4.0 and you add NuGet reference AFTER that. But if you target .NET 4.5, 4.5.1 or 4.6, the long list of dependencies appears again. Think MVVM Light (or NuGet) is having trouble finding the correct package sub-folder.

回答1:

I don't know why it happens but I can offer a workaround. Just open the project's Detected Dependencies folder, select all of the System dlls, right-click and select Exclude.