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.
For anyone who doesnt like to add the references for missing dlls i found the following which works perfectly
https://www.cazzulino.com/include-dlls-in-vsix.html
I added the following to end of my .csproj and all missing dlls ended up in the .vsix
<PropertyGroup>
<GetVsixSourceItemsDependsOn>$(GetVsixSourceItemsDependsOn);IncludeNuGetResolvedAssets</GetVsixSourceItemsDependsOn>
</PropertyGroup>
<Target Name="IncludeNuGetResolvedAssets" DependsOnTargets="ResolveNuGetPackageAssets">
<ItemGroup>
<VSIXCopyLocalReferenceSourceItem Include="@(ReferenceCopyLocalPaths)" />
</ItemGroup>
</Target>
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.
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With