ReSharper 9添加菜单项操作无效

时间:2015-01-30 21:02:47

标签: c# nuget resharper nuget-package resharper-9.0

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

Actions.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>

AboutAction.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 spec

<?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>

1 个答案:

答案 0 :(得分: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扩展相同),但是如果只是实现已更改,您可以手动或通过a small change to the .csproj将dll复制到安装文件夹。

您还需要确保已定义ZoneMarker课程。这声明您的操作属于某个区域,该区域用于根据已安装的功能和当前主机启用/禁用功能(例如,因此Visual Studio特定扩展仅适用于VS而不会加载到dotPeek等。 )。您可以找到有关Zones in the devguide的更多信息,此页面提供defining a zone marker的有用信息。

This thread也应该有所帮助。

此外,为{x}}命名你的dll和nupkg可能是一个好主意,以防止与官方dll发生任何潜在冲突,并防止混淆dll来自何处。名称的第一部分应该是您公司的名称(或个人名称)。

相关问题