将 VsPackage 附加到 Roslyn 实例 [英] Attach VsPackage to Roslyn Instance

查看:45
本文介绍了将 VsPackage 附加到 Roslyn 实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个使用 Roslyn 语言服务的 VsPackage.在 VsPackage 的属性下,我已将命令行参数更改为:

I'm trying to create a VsPackage that makes use of the Roslyn Language Services. Under the properties of my VsPackage, I've changed the command line arguments to:

/rootsuffix Roslyn

运行项目时,启动的 Visual Studio 实例正确使用 Roslyn.(我在打开的 .cs 文件名称旁边看到 [Roslyn]).但是,我的 VsPackage 没有部署到这个 Visual Studio 实例.

When running the project, the instance of Visual Studio that starts up is correctly using Roslyn. (I see [Roslyn] next to the names of .cs files I have open). However, my VsPackage is not deployed to this instance of Visual Studio.

我打开了 Roslyn 附带的 SyntaxVisualizerExtension VsPackage 并编译/运行它.它使用 Roslyn 正确部署到 Visual Studio.我查看了项目属性和参考资料,没有发现任何遗漏.

I have opened up the SyntaxVisualizerExtension VsPackage that ships with Roslyn and compiled/run that. It correctly deploys to Visual Studio using Roslyn. I've looked through the project properties and references and nothing has stood out to me as missing.

我正在采取的步骤是:

  1. 文件 > 新建项目 > Visual Studio 包
  2. 使用工具窗口创建
  3. 打开项目属性,将/rootsuffix Exp改为/rootsuffix Roslyn
  4. 添加对 Roslyn .dll 的引用
  5. 运行项目.

理论上,我可能会剥离 SyntaxVisualizerExtension 包,但我想知道为 Roslyn 实例创建 VsPackage 的正确方法.

In theory, I could probably strip down the SyntaxVisualizerExtension Package, but I'd like to know the proper way to create a VsPackage for the Roslyn instance.

推荐答案

没有 UI 设置来控制属性是什么.在记事本中编辑您的项目文件(或在 VS 中卸载项目然后右键单击并选择编辑"),并添加以下行:

There's no UI setting to control what the property is. Edit your project file in Notepad (or unload the project in VS and then right click and choose "edit"), and add this line:

<VSSDKTargetPlatformRegRootSuffix>Roslyn</VSSDKTargetPlatformRegRootSuffix>

到适当的 PropertyGroup.查看通过任何 Roslyn 模板创建的项目作为示例.

into the appropriate PropertyGroup. Look in the projects created via any of the Roslyn templates for an example.

这篇关于将 VsPackage 附加到 Roslyn 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆