简体   繁体   English

VSIX newtonsoft不在包(VS> 15.5)压缩包中

[英]VSIX newtonsoft isn't in package (VS>15.5) suppress package

We have a solution for vsix projects. 我们有一个针对vsix项目的解决方案。 Until version 15.4 of visual studio packages were produced with newtonsoft.json.dll, however, since that version, newsoft were excluded from the package. 直到15.4版的visual studio软件包都是用newtonsoft.json.dll生成的,然而,自那个版本以来,newsoft被排除在软件包之外。

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 "" 对于我所看到的,这是因为“Microsoft.VsSDK.targets”位于“C:\\ Program Files(x86)\\ Microsoft Visual Studio \\ 2017 \\ Enterprise \\ MSBuild \\ Microsoft \\ VisualStudio \\ v15.0 \\ VSSDK \\ Microsoft” .VsSDK.targets“有一个新的排除规则”“

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. 我们的解决方案需要NewtonSoft,如果我在VS> = 15.5时安装vsix,关于newtonsoft不在包中,它在%appdata%\\ microsoft \\ visualstudio \\ extensions中请求此程序集失败。

Tests we have done: I remove this exclusion from VsSDK.targets, and it works because newtonsoft is inserted on package. 我们已经完成的测试:我从VsSDK.targets中删除了这个例外,它的工作原理是因为在软件包上插入了newtonsoft。

I have inserted the assembly on Assets of manifest, but assembly is not inserted, so, it fails. 我已经在清单的Assets上插入了程序集,但是没有插入程序集,因此它失败了。

We have update our dependendies, to make sure we use the same version, NewtonSoft 9.0.0. 我们更新了我们的dependendies,以确保我们使用相同的版本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. 我们如何解决这个问题,考虑到我们不想在构建机器上更改SDK.targets,因为它会在开发人员机器中失败。

Is it possible add relative path in Assets? 是否可以在Assets中添加相对路径? if yes, how? 如果有,怎么样? because I have tried and newtonsoft it wasn't inserted. 因为我试过并且没有插入newtonsoft。

https://social.msdn.microsoft.com/Forums/en-US/550ddfdc-027c-41ba-9b32-31e6391bc038/newtonsoftjsondll-not-included-in-vsix?forum=vsx 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 版本15.7.4仍然存在此问题

Thank you 谢谢

Include the Newtonsoft.Json.dll as a linked item in the extension csproj. 将Newtonsoft.Json.dll包含在扩展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 . 然后可以通过VSIX Manifest Editor轻松添加该文件作为Microsoft.VisualStudio.Assembly This should result in the following Asset defined in the .vsixmanifest file. 这应该导致.vsixmanifest文件中定义的以下Asset

<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. 显然,完美的解决方案根本不需要这样做,并且Newtonsoft.Json.dll将像任何其他引用的程序集一样包含在内。 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 . 但是,这是我们发现的侵入性最小的解决方案,允许我们控制vsix包中包含的Newtonsoft.Json.dll版本,也不依赖于C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\PrivateAssemblies找到的版本C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\PrivateAssemblies

The VS behavior is meant to prevent you from shipping a copy of Newtonsoft.Json. VS行为旨在防止您发送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. 这样做的原因是VS自己发送了一个副本(或者在一个时间点发送了几个副本......),并且包含到该版本的绑定重定向。 Even if you were to place one in your VSIX, it should never be loaded anyways. 即使您要在VSIX中放置一个,也不应该加载它。

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. 如果您通过某种方式强制VS加载您的Newtonsoft.Json版本,则可以创建一个机会来破坏VS中依赖于VS包含版本的其他功能。

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. 在原始问题发布后很久,但如果您的%LocalAppData%\\Microsoft\\VisualStudio\\15.0_<instanceID>\\devenv.exe.config不包含代码库和Newtonsoft.Json的绑定重定向,我会打开一个反馈票跟进VS团队。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM