3

尝试更新我的 resharper 扩展以适用于 9.0,在我只是将 dll 移动到插件目录之前,但现在我需要弄清楚如何让 nuget 工作......我已经能够打包文件,dll 得到包含在 nupkg 中,但我认为我有一些命名空间\id 有问题(对.net 不太熟悉),而且当我导入 nuget 包时,resharper 甚至没有读取我的 actions.xml。未添加菜单项。Anwyays 如果有人可以就如何调试 nuget 包或可能出现的问题给我任何建议,我将非常感激,因为我已经坚持了几天了。

动作.xml

<?xml version="1.0" encoding="utf-8" ?>
<actions>
  <action id="yuval" text="L10N"></action>
  <insert group-id="ReSharper" position="last">
    <action-ref id="yuval" text="About Localization Helper"/>
  </insert>
</actions>

关于Action.cs

namespace JetBrains.Resharper.L10N
{
    [Action(Id)]
    public class AboutAction : IExecutableAction
    {
        public const string Id = "yuval";

    public bool Update(IDataContext context, ActionPresentation presentation, DelegateUpdate nextUpdate)
        {    
            return true;
        }

        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            MessageBox.ShowMessageBox(
              "Localization Helper\nYuval\n\nHelps Localize",
              "About Localization Helper",
              MbButton.MB_OK,
              MbIcon.MB_ICONASTERISK);
        }

    }
}

nuget规范

<?xml version="1.0"?>
<package >
  <metadata>
    <id>JetBrains.Resharper.L10N</id>
    <version>1.0.0.7</version>
    <title>L10N</title>
    <authors>Yuval</authors>
    <owners>UW</owners>
    <licenseUrl>https://myurl.com</licenseUrl>
    <projectUrl>https://myurl.com</projectUrl>
    <iconUrl>https://myurl.com/logo.png</iconUrl>
    <requireLicenseAcceptance>true</requireLicenseAcceptance>
    <description>Tool to help localize</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2015</copyright>
    <tags></tags>
    <dependencies>
      <dependency id="Wave" version="[1.0]" />
    </dependencies>
  </metadata>
<files>
    <file src="..\bin\Debug\JetBrains.Resharper.L10N.dll"
          target="dotFiles\"/>
  </files>
</package>
4

1 回答 1

2

ReSharper 9 中注册操作的方式已更改。不再使用actions.xml,而是使用操作类上的接口。例如,要将操作添加到 ReSharper → 工具菜单,您可以执行以下操作:

[Action(ActionId, Id = 1)]
public class AboutAction : IExecutableAction, IInsertLast<ToolsMenu>
{
  public const string ActionId = "yuval";
  // …
}

您还需要为Id. 从 9.1 开始,这需要在您自己的扩展中是唯一的(9.0 要求它在整个安装中是唯一的,包括 ReSharper 本身和任何其他扩展)。

每当您更改动作的属性或接口时,都需要通过 nupkg 重新安装扩展(动作在 Visual Studio 中静态注册,与标准 VS 扩展相同),但如果只是实现发生了变化,您可以手动或通过对 .csproj 的小改动将dll 复制到安装文件夹。

你还需要确保你已经定义了一个ZoneMarker类。这声明您的操作属于一个区域,该区域用于根据已安装的功能和当前主机启用/禁用功能(例如,Visual Studio 特定的扩展只在 VS 中工作并且不会加载到 dotPeek 等)。您可以在开发指南中找到有关区域的更多信息,此页面提供了用于定义区域标记的有用信息。

该线程也应该有所帮助。

此外,最好将 dll 和 nupkg 命名为其他名称JetBrains.ReSharper.(Whatever),以免与官方 dll 发生任何潜在冲突,并防止混淆 dll 的来源。名称的第一部分应该是您公司的名称(或个人名称)。

于 2015-01-30T23:41:32.880 回答