VSIX extension - How can I ensure a referenced dll or assembly is included in the VSIX file?

烂漫一生 提交于 2019-12-07 07:38:56

问题


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:

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.

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?

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.

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


回答1:


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. In Visual Studio, with the extension solution open,
  2. double click the .vsixmanifest file
  3. Open the "Assets" tab
  4. Click "New"
  5. Set Type to "Microsoft.VisualStudio.Assembly"
  6. Set Source to "A File on FileSystem"
  7. Click Browse to set Path to your dll, (don't worry the reference is not added as an absolute path, but added as a relative path or just a strong assembly name)
  8. You can leave "Embed in this folder" empty.
  9. Click OK
  10. Rebuild the solution, and the file should be in the VSIX file now.

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" />


来源:https://stackoverflow.com/questions/42201923/vsix-extension-how-can-i-ensure-a-referenced-dll-or-assembly-is-included-in-th

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!