问题
We have a solution for vsix projects. Until version 15.4 of visual studio packages were produced with newtonsoft.json.dll, however, since that version, newsoft were excluded from the package.
For what I have seen, this is caused because "Microsoft.VsSDK.targets" located in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK\Microsoft.VsSDK.targets" has a new exclusion rule ""
Our solution needs NewtonSoft, if I install vsix with VS >=15.5, regarding newtonsoft isn't in package, it fails requesting this assembly in %appdata%\microsoft\visualstudio\extensions.
Tests we have done: I remove this exclusion from VsSDK.targets, and it works because newtonsoft is inserted on package.
I have inserted the assembly on Assets of manifest, but assembly is not inserted, so, it fails.
We have update our dependendies, to make sure we use the same version, NewtonSoft 9.0.0.
How can we solve that, taking in consideration we don't wan't to change the SDK.targets on build machine because it will fail in developer machine.
Is it possible add relative path in Assets? if yes, how? because I have tried and newtonsoft it wasn't inserted.
https://social.msdn.microsoft.com/Forums/en-US/550ddfdc-027c-41ba-9b32-31e6391bc038/newtonsoftjsondll-not-included-in-vsix?forum=vsx
** UPDATE **
Version 15.7.4 still have this problem
Thank you
回答1:
Include the Newtonsoft.Json.dll as a linked item in the extension csproj.
<Content Include="..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll">
<Link>Newtonsoft.Json.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
The file can then be easily added through the VSIX Manifest Editor as a Microsoft.VisualStudio.Assembly
. This should result in the following Asset
defined in the .vsixmanifest file.
<Asset d:Source="File" Path="Newtonsoft.Json.dll" Type="Microsoft.VisualStudio.Assembly" AssemblyName="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" />
This is far from a perfect solution because this linked item won't follow a package upgrade and you'll have to manage that yourself. Obviously a perfect solution would be not needing to do this at all and Newtonsoft.Json.dll would be included like any other referenced assembly. However, this is the least invasive solution we found that allowed us to control the version of Newtonsoft.Json.dll included in the vsix package and also not rely on the version found in C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PrivateAssemblies
.
回答2:
The VS behavior is meant to prevent you from shipping a copy of Newtonsoft.Json. The reason for this is that VS ships a copy itself (or several at one point in time...), and includes a binding redirect to that version. Even if you were to place one in your VSIX, it should never be loaded anyways.
If you do by some means force VS to load your version of Newtonsoft.Json, you create an opportunity to break other features within VS that depend on the VS-included version.
This is long after the original question was posted, but if your %LocalAppData%\Microsoft\VisualStudio\15.0_<instanceID>\devenv.exe.config
does not contain a codebase and a binding redirect for Newtonsoft.Json, I would open a feedback ticket to follow up with the VS team.
来源:https://stackoverflow.com/questions/50003033/vsix-newtonsoft-isnt-in-package-vs15-5-suppress-package