为什么MVVM Light将系统程序集复制到应用程序文件夹? [英] Why MVVM Light copies system assemblies to application folder?

查看:93
本文介绍了为什么MVVM Light将系统程序集复制到应用程序文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

向WPF项目添加MVVM Light参考会将大量的系统程序集添加到随附的MSI Setup项目中的依赖项列表中.然后在安装应用程序时将这些程序集(数量超过50个)复制到应用程序文件夹中.为什么会这样呢?为什么它不能直接从GAC引用它?

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?

注意:对于MVVMLight.dll,复制本地选项设置为True.我显然不能将其设置为False.

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

复制非常简单.我正在使用VS2015社区.

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

  1. 创建一个新的WPF应用程序项目.
  2. 添加NuGet对MVVM Light(或Lib-only版本;无关紧要)的引用.
  3. 将MSI安装程序项目添加到解决方案中(必须具有扩展名已安装).
  4. 将WPF应用程序的主要项目输出"添加到设置项目中.
  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.

你去了. System.X.Y 的长长列表将添加到该列表中.如果生成并安装安装项目,则将在Program Files文件夹中看到所有这些DLL.

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?

如果WPF应用程序针对.NET Framework 4.0并在此之后添加NuGet引用,则不会出现该问题.但是,如果您以.NET 4.5、4.5.1或4.6为目标,则又会出现一长串依赖关系.认为MVVM Light(或NuGet)在查找正确的软件包子文件夹时遇到问题.

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.

推荐答案

过度攻击性依赖项扫描是我不使用Visual Studio部署项目的众多原因之一.相反,我使用WiX/IsWiX.都是开源的,后来都是我自己写的.

Overly agressive dependency scanning is one of the many reasons I don't use Visual Studio Deployment Projects. Instead I use WiX / IsWiX. Both open source and the later written by myself.

有关更多信息,请参见:

For more information see:

http://www.github.com/iswix-llc/iswix-tutorials

这篇关于为什么MVVM Light将系统程序集复制到应用程序文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆