我想在.tt扩展程序中的少数文件上保存/运行自定义工具。我不想遍历解决方案/项目中的所有文件,而是希望能够使用文件的相对(或完整)路径来执行保存/运行自定义工具。
有没有办法获取ProjectItem给定文件路径的对象($(SolutionDir)/MyProject/MyFile.tt),以便我可以在其上执行方法?
我正在使用 MEF 开发 Visual Studio 2013 扩展,同时尝试读取 Active Document 内容类型和代码。目前,它仅在编辑器中打开文档/项目项时读取。一旦打开它们,每当我们在打开的文档选项卡之间切换时,它就不会再次读取它们。
要求:我希望此扩展能够读取当前活动文档的内容类型和代码文本。
更新:
问题:我知道,使用 EnvDTE80.DTE2.ActiveWindow,我可以获得当前聚焦的文档,但我在这里很困惑如何调用此代码来读取当前活动文档/窗口的内容?假设我们有 10 个文档,则活动文档(获得当前焦点)需要由 this 扩展读取。这里,只有当我们打开一个新文档或创建文本视图之前关闭的文档时,才会调用 VsTextViewCreated 。它不会被调用已经打开的文档(即已经创建的文本视图),因此当我们将焦点移到其他已经打开的文档上时,我们将无法获得更新的 wpfTextView 对象。我很困惑如何使用 DTE2.ActiveDocument 或 DTE2.ActiveWindow 事件处理程序来调用它。
问题:
在 MEF 中这是否可能,而不使用 DTE?
VS 编辑器中是否存在处理 TextView 的接口?
这是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Text.Editor;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Utilities;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
using Microsoft.VisualStudio.OLE.Interop;
using System.Diagnostics;
namespace VSIXProject_Test
{
[Export(typeof(IVsTextViewCreationListener))]
[ContentType("code")]
[TextViewRole(PredefinedTextViewRoles.Editable)]
class VsTextViewCreationListener : IVsTextViewCreationListener
{
[Import]
IVsEditorAdaptersFactoryService AdaptersFactory = null; …Run Code Online (Sandbox Code Playgroud) 我是扩展 Visual Studio 的新手,我正在尝试寻找方法来查找当前解决方案使用的源代码管理系统。
我创建了 VsPackage 项目,并且能够IVsSolution通过IVsSolutionEvents.
在内部OnAfterSolutionOpen(或者可能是其他的,如果有其他选择)我想根据解决方案是使用 TFS 还是 Git 或其他东西来采取不同的行动。我怎样才能获得这些信息?
我计划支持尽可能多的 Visual Studio 版本,但如果不可能,我希望至少支持 VS2012 及更高版本。
在 Visual Studio 扩展中,我尝试导出 MEF 组件并稍后找到它。
我有这门课:
[Export(typeof(IBoilerplateSettings))]
public class BoilerplateSettings : IBoilerplateSettings
{
...
Run Code Online (Sandbox Code Playgroud)
此代码在 OleMenuCommand 的回调中解析。从这个拉取请求中得到了例子。
var componentModel = (IComponentModel)this.package.GetService(typeof(SComponentModel));
var settings = componentModel.DefaultExportProvider.GetExportedValue<IBoilerplateSettings>();
Run Code Online (Sandbox Code Playgroud)
但每次都会抛出这个错误:
No exports were found that match the constraint:
ContractName UnitTestBoilerplate.IBoilerplateSettings
RequiredTypeIdentity UnitTestBoilerplate.IBoilerplateSettings
Run Code Online (Sandbox Code Playgroud)
两者都在同一个程序集中。我已经尝试过[Export]这两个属性System.Composition,但System.ComponentModel.Composition都不起作用。
我正在查看VS 中 MEF 的文档,但听起来添加该属性应该可行。我也尝试过清除 ComponentModel 缓存,但这不起作用。我在这里缺少什么?
我的 GitHub 扩展无法像在 VS2017 中那样运行。我无法将我的新应用发布到 GitHub。事实上,当我通过扩展输入我的凭据登录 GitHub 时,它仍然显示离线。
我正在尝试卸载扩展程序,以便我可以重新安装它并查看它是否在我升级到 VS 2019 ver 16.3 后自行修复
卸载失败,日志文件很大,不知道从哪里开始。还有人遇到这个问题吗?
示例日志
9/25/2019 10:47:58 AM - Microsoft VSIX Installer
9/25/2019 10:47:58 AM - -------------------------------------------
9/25/2019 10:47:58 AM - vsixinstaller.exe version:
9/25/2019 10:47:58 AM - 16.3.2099
9/25/2019 10:47:58 AM - -------------------------------------------
9/25/2019 10:47:58 AM - Command line parameters:
9/25/2019 10:47:58 AM - C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service\vsixinstaller.exe,/appidinstallpath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe,/skuName:Pro,/skuVersion:16.3.29318.209,/appidname:Microsoft Visual Studio Professional 2019,/culture:en-US,/noep,/u:c3d3dc68-c977-411f-b3e8-03b0dccf7dfc,/callingprocessid:27568,/installas:3432
9/25/2019 10:47:58 AM - -------------------------------------------
9/25/2019 10:47:58 AM - Microsoft VSIX Installer …Run Code Online (Sandbox Code Playgroud) 我创建了一个与自定义项目类型相关联的自定义项目模板.该解决方案在很大程度上取决于项目的MPF - Visual Studio 2012框架.
我接下来要做的是覆盖此自定义项目类型的默认"Build"(F6)和"Start without debugging"(ctrl + F6)事件.解决方案本身将部署为VSIX包.
任何帮助表示赞赏.
c# extensibility visual-studio-sdk visual-studio-extensions visual-studio-2012
我有一个很大的解决方案,为了调试目的,我必须使用Visual Studio 2012的"设置启动项目"功能启动许多项目.但是我经常需要更改我需要启动的项目(有时是项目A,B,C,有时项目B,C,D等)
有人知道这样的扩展吗?
我不记得我在哪里安装了这个扩展程序,但它让我非常讨厌,因为它显示了声誉,而不是集中在我的收件箱和最近的活动中.
无论如何,我环顾四周试图摆脱它,无法在扩展中找到它,有谁知道它可以在哪里找到和卸载?
这是扩展,它嵌入在VS top标题栏上.

我正在手动工作VSIX扩展包的vsixmanifest,是这样的:
<?xml version="1.0" encoding="utf-8"?>
<Vsix Version="1.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2010">
<Identifier Id="c669b00e-3746-47bd-bfe7-e6f9d64458ff">
<Name>RapidDesign</Name>
<Author>ZUI INFRA sp z o. o.</Author>
<Version>2.0.1</Version>
<Description>RapidDesign allows you to use various VisualStudio designers faster.</Description>
<Locale>1033</Locale>
<MoreInfoUrl>http://www.rapiddesignaddin.com</MoreInfoUrl>
<License>EULA.txt</License>
<Icon>Speedometer.png</Icon>
<PreviewImage>RapidDesignPreview.png</PreviewImage>
<InstalledByMsi>false</InstalledByMsi>
<SupportedProducts>
<VisualStudio Version="12.0">
<Edition>Ultimate</Edition>
</VisualStudio>
</SupportedProducts>
<SupportedFrameworkRuntimeEdition MinVersion="4.0" MaxVersion="4.0" />
</Identifier>
<References>
<Reference Id="Microsoft.VisualStudio.MPF" MinVersion="10.0">
<Name>Visual Studio MPF</Name>
</Reference>
</References>
<Content>
<VsPackage>RapidDesign.pkgdef</VsPackage>
</Content>
</Vsix>
Run Code Online (Sandbox Code Playgroud)
有一种方法可以告诉VSIX安装程序自动运行CMD命令或可执行文件,就像一种安装后步骤?
例如,我想运行/安装一个注册表脚本(.reg文件),为我配置一些默认的扩展选项,但我不知道是否可以从vsixmanifest启动控制台命令或EXE进程自动完成该过程以前编程过.
列标尺默认为第80个字符,这个字符太小了.我该如何调整?(我在下面用红色圈出来)
我试图寻找扩展,但根据这篇文章,我无法安装像Productivity Power Tools这样的东西,让我可以选择调整它.
我可以编辑某个plist文件吗?
这个问题对我来说非常令人沮丧,所以非常感谢任何帮助.