VSIX 扩展 - 如何确保引用的 dll 或程序集包含在 VSIX 文件中? [英] VSIX extension - How can I ensure a referenced dll or assembly is included in the VSIX file?

查看:40
本文介绍了VSIX 扩展 - 如何确保引用的 dll 或程序集包含在 VSIX 文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户安装了我的扩展程序,但没有安装最新的 Visual Studio 更新时,扩展程序无法解析 Microsoft.CodeAnalysis.CSharp.dll,如下所示留言:

When a user installs my extension, but does not have the latest Visual Studio update installed, the extension fails to resolve Microsoft.CodeAnalysis.CSharp.dll with the followeing message:

无法加载文件或程序集Microsoft.CodeAnalysis.CSharp,版本=1.2.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35' 或它的依赖项之一.系统找不到指定的文件.

Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

我确定扩展确实引用了这个程序集,它确实引用了这个程序集,但是为什么这个程序集会从 VSIX 文件中排除?

I made sure that the extension does in fact reference this assembly, and it does, but why would this assembly be excluded from the VSIX file?

我将 VSIX 文件重命名为 ZIP 文件,查看了内容,但并未提供此程序集,即使 VSIX 文件中包含其他Microsoft.CodeAnalysis.*.dll"程序集.

I renamed the VSIX file to a ZIP, looked at the contents, but this assembly is not shipped, even though other "Microsoft.CodeAnalysis.*.dll" assemblies are included in the VSIX file.

我还确认参考中的Copy Local"属性为 True.

I also confirmed that the "Copy Local" property on the reference is True.

推荐答案

我找到了这个问题的解决方案,我可以看到现在包含在 VSIX 中的 dll 并且用户确认它适用于他.

I found a solution to this problem, and I can see the dll now included in the VSIX and a user confirmed that it works for him.

  1. 在 Visual Studio 中,打开扩展解决方案,
  2. 双击 .vsixmanifest 文件
  3. 打开资产"标签
  4. 点击新建"
  5. 将类型设置为Microsoft.VisualStudio.Assembly"
  6. 将源设置为文件系统上的文件"
  7. 单击浏览"以将 Path 设置为您的 dll,(不要担心引用不会添加为绝对路径,而是添加为相对路径或只是强程序集名称)
  8. 您可以将嵌入此文件夹"留空.
  9. 点击确定
  10. 重新构建解决方案,该文件现在应该在 VSIX 文件中.

然后将这一行添加到 vsixmanifest 文件中:

This line is then added to the vsixmanifest file:

<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="File" Path="Microsoft.CodeAnalysis.CSharp.dll" AssemblyName="Microsoft.CodeAnalysis.CSharp, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

这篇关于VSIX 扩展 - 如何确保引用的 dll 或程序集包含在 VSIX 文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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