问题
I have created a Visual Studio Extension (VSIX) that makes changes to our Application's code using Roslyn.
The VSIX solution includes the NUGET package Microsoft.CodeAnalysis.Analyzers. As an aside, it is described as version 1.3.2, but the underlying DLLs (e.g. "Microsoft.CodeAnalysis.CSharp.dll") all report to be 1.3.2.
Anyhow, I put this on our local private Gallery. From there, I can add it to Visual Studio (VS2015 Update 3) and it executes as expected.
However, after my colleagues add it to their Visual Studio (VS2015 Update 3) and attempt to execute it, they receive the following message:
Microsoft Visual Studio
Could not load file or assembly 'Microsoft.VisualStudio.LanguageServices, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
OK
When I look in the VSIX archive, I do see many DLLs, but these are "my DLL" and all those with the prefix "System.". I'm not seeing any with the prefix "Microsoft.". I did try manually copying every DLL that I have in my BIN folder to the VSIX to see if it would make any difference, but with no success.
All DLL referenced appear to have "copy local" on them, so they're in my BIN, but they're just not accessible on the end users' machines.
I see the manifest can include both "Assets" and "Dependencies", but it's not immediately clear if these can be used for NUGET packages.
What am I missing?
回答1:
Eventually found the answer:
VSIX with Project Templates and NuGet Packages
- See the answer from Min (Aug 28 '13) regarding his YouTube video
- And take note of KyleMit's comment regarding where in the rather lengthy video this appears.
The fix is rather lengthy, so best presented in his video.
回答2:
I received the same exception using roslyn for a custom command and as described above the Microsoft.CodeAnalysis DLLs were not included while other referenced DLLs or NuGet packages were added. However, once I downgraded the Dependencies in NuGet to the version used by Visual Studio which can usually be found in C:\Program Files (x86)\Microsoft Visual Studio [Version Number, e.g. '14.0']\Common7\IDE\PrivateAssemblies the exception did no longer occur, as it just used the available dlls.
来源:https://stackoverflow.com/questions/40532807/how-to-include-a-nuget-package-in-a-visual-studio-extension-vsix