在我的VS扩展中,我需要为我的新项目类型添加菜单项.但我希望它只显示我的自定义类型.所以我将此代码添加到.vcst文件中:
<Button guid="_Interactive_WindowCmdSet" id="cmdidLoadUI" priority="0x0100" type="Button">
<Parent guid="_Interactive_WindowCmdSet" id="ProjectItemMenuGroup" />
<Icon guid="guidImages" id="bmpPic1" />
<CommandFlag>DynamicVisibility</CommandFlag>
<Strings>
<ButtonText>Load</ButtonText>
</Strings>
</Button>
<Group guid="_Interactive_WindowCmdSet" id="ProjectItemMenuGroup" priority="0x0600">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE"/>
</Group>
Run Code Online (Sandbox Code Playgroud)
并将此代码添加到包初始化:
// Create the command for the menu item.
CommandID projectMenuCommandID = new CommandID(GuidList.Interactive_WindowCmdSet, (int)PkgCmdIDList.cmdidLoadUI);
OleMenuCommand projectmenuItem = new OleMenuCommand(LoadUIMenuItemCallback, projectMenuCommandID);
projectmenuItem.BeforeQueryStatus += projectmenuItem_BeforeQueryStatus;
mcs.AddCommand(projectmenuItem);
Run Code Online (Sandbox Code Playgroud)
查询状态处理程序是:
private void projectmenuItem_BeforeQueryStatus(object sender, EventArgs e)
{
OleMenuCommand menuCommand = sender as OleMenuCommand;
if (menuCommand != null)
menuCommand.Visible = IsProjectOfRightType(GetSelected<Project>());
}
Run Code Online (Sandbox Code Playgroud)
问题是 - 这个状态处理程序永远不会被调用.所以我为所有项目类型显示了此菜单项.
我也试过IOleCommandTarget
在我的包上实现接口,比如: …
我们使用Microsoft.VisualStudio.XmlEditor命名空间(https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.xmleditor.aspx)中的类来修改Visual Studio扩展中的xml文档.
由于某种原因,在调用XmlEditingScope.Complete()方法后发生死锁.在Visual Studio的状态栏中,我们看到消息"等待解析完成..."
这是死锁UI线程的堆栈跟踪:
WindowsBase.dll!System.Windows.Threading.DispatcherSynchronizationContext.Wait(System.IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout)
mscorlib.dll!System.Threading.SynchronizationContext.InvokeWaitMethodHelper(System.Threading.SynchronizationContext syncContext, System.IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout)
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext)
mscorlib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext)
Microsoft.VisualStudio.Package.LanguageService.14.0.dll!Microsoft.VisualStudio.Package.LanguageService.ParseWaitHandle.WaitOne(int millisecondsTimeout, bool exitContext)
Microsoft.XmlEditor.dll!Microsoft.XmlEditor.XmlLanguageService.WaitForParse(System.IAsyncResult result, Microsoft.XmlEditor.StatusBarIndicator indicator)
Microsoft.XmlEditor.dll!Microsoft.XmlEditor.XmlLanguageService.WaitForParse()
Microsoft.XmlEditor.dll!Microsoft.XmlEditor.XmlParserLock.XmlParserLock(Microsoft.XmlEditor.XmlLanguageService service)
Microsoft.XmlEditor.dll!Microsoft.XmlEditor.Transaction.PushToEditorTreeAndBuffer()
Microsoft.XmlEditor.dll!Microsoft.XmlEditor.Transaction.Complete()
XmlEditingScope.Complete() Line 64
Run Code Online (Sandbox Code Playgroud)
并且Visual Studio解析线程:
mscorlib.dll!System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext) + 0x21 bytes
mscorlib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext) + 0x28 bytes
Microsoft.XmlEditor.dll!Microsoft.XmlEditor.LockManager.Lock(object …
Run Code Online (Sandbox Code Playgroud) 我有一个Visual Studio扩展,显示红色错误波形.我也想提供其他颜色的曲线,例如黄色警告.
创建红色波浪线可以通过扩展ITagger类来完成:
internal sealed class MySquigglesTagger : ITagger<IErrorTag> {
public IEnumerable<ITagSpan<IErrorTag>> GetTags(NormalizedSnapshotSpanCollection spans) {
foreach (IMappingTagSpan<MyTokenTag> myTokenTag in this._aggregator.GetTags(spans))
SnapshotSpan tagSpan = myTokenTag.Span.GetSpans(this._sourceBuffer)[0];
yield return new TagSpan<IErrorTag>(tagSpan, new ErrorTag("Error", "some info about the error"));
}
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试过的:
问题:如何制作绿色(或蓝色或黄色)花边装饰品?可悲的是,即使是神秘或复杂的解决方案也值得赞赏......
我的目标是VS2015和VS2017.
编辑:在输入此问题时,MSDN论坛上有人回复说无法使用当前的API完成.在Visual Studio中制作黄色波浪线真的不可能吗?!
我正在尝试开发我的第一个visual studio扩展项目,我已经安装了VS10 SDK并且能够创建一个新项目并且可以很好地构建它,但是当我尝试调试符号时没有加载.我知道我可以调试到VSIX项目,因为我已经在网上下载了一个示例项目并且它已经加载了符号并且断点正好受到影响http://weshackett.com/2009/11/configure-vsix-project-to-enable -debugging /).所以必须特别关注我创建VSIX项目的方式(也许!).我注意到的一件事是,dll和文件没有被复制到本地"应用程序数据"区域,只复制清单,而对于示例项目,所有文件都被复制,包括dll.我比较了两者之间的项目设置,它们都是相同的.我希望这是有道理的,如果我能提供更多细节,请告诉我......
c# debugging visual-studio-2010 visual-studio-debugging vsix
如果我这样做,使用VSIX项目
<VSTemplate Include="ProjectTemplate1.vstemplate">
<OutputSubPath>Sample Test Project</OutputSubPath>
</VSTemplate>
Run Code Online (Sandbox Code Playgroud)
位置是 \ bin\Debug\ProjectTemplates\CSharp\Sample Test Project\1033\ProjectTemplate1.zip
这将在VS Installed Templates中的Visual C#Template中创建项目模板.但是,我不希望将Visual C#作为我的项目类型节点.它应该在Visual C#项目类型节点之外.
我怎样才能做到这一点?我需要做出哪些改变以及如何改变?请帮忙
我正在开发视觉工作室的扩展.
我有一个选项页面:
public class GeneralOptionsPage : DialogPage
{
[Category("General")]
[DisplayName("Foos")]
[Description("Bla Foo Bla")]
public string[] Foos { get; set; }
[Category("General")]
[DisplayName("Bar")]
[Description("Bar Foo Bar")]
public string Bar { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
该Bar
物业完美运作并坚持下去.
该Foos
属性也可以工作(它甚至在选项页面中为您提供了一个很好的弹出窗口,您可以在每行输入一个字符串),这意味着我可以设置它并在我的扩展中使用它,但它不会写入注册表/存储.当我关闭VS并再次打开它时,它总是空着的.
从MSDN引用:
DialogPage的默认实现支持具有适当转换器的属性,或者是可以扩展为具有适当转换器的属性的结构或数组的属性.有关转换器列表,请参阅System.ComponentModel命名空间.Visual Studio Extensibility Samples管理int,string和System.Drawing.Size属性.
据我所知,我正在使用System.ComponentModel
命名空间中的有效组件.
那么我做错了什么?我是否必须以不同的方式处理数组?
我有一个标准的VSIX项目,它在同一个解决方案中依赖于类库项目.在将类库转换为新的VS2017RC简化版csproj之前,一切正常.类库构建正常(我的dotnet SDK是1.0.0-preview4-004233),但在尝试构建VSIX时我得到:
error MSB4057: The target "BuiltProjectOutputGroupDependencies" does not exist in the project.
Run Code Online (Sandbox Code Playgroud)
这显然与传统的VSIX csproj不兼容,期望新csproj无法提供的依赖项目.
有没有人碰到这个或有任何关于解决它的建议?我将研究删除项目引用并手动引用输出DLL.
作为一个相关的注释,目前还不清楚VSIX会从类库中选择哪个输出DLL,因为新的csproj支持多个目标框架.
我有一个Visual Studio 2017项目模板扩展,目前正在使用ASP.NET项目.它有以下.vstemplate:
<VSTemplate Version="3.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" xmlns:sdk="http://schemas.microsoft.com/developer/vstemplate-sdkextension/2010">
<TemplateData>
<Name>Angular Component</Name>
<Description>Files for an Angular component</Description>
<RequiredFrameworkVersion>4.5</RequiredFrameworkVersion>
<Icon>AngularComponentTemplate.ico</Icon>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>Web</ProjectSubType>
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
</TemplateData>
<TemplateContent>
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.component.html">base.component.html</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.component.ts">base.component.ts</ProjectItem>
</TemplateContent>
</VSTemplate>
Run Code Online (Sandbox Code Playgroud)
另外,引用它的VSIX文件具有
的ItemTemplate\CSHARP\WEB
设置为项目的"VSIX子路径"属性.
但是,我不能让这个模板出现在ASP.NET Core项目中.我尝试在vstemplate中使用它:
<ProjectType>DNX</ProjectType>
<TemplateGroupID>SharedDotNetAndDotNetWeb</TemplateGroupID>
Run Code Online (Sandbox Code Playgroud)
(来自/sf/answers/2698074431/)但它没有用.在Visual Stuido 2017的发布版本中,如何让项目模板出现在.NET核心项目中?
我可以通过Visual Studio中的Extensions and Updates管理器禁用特定扩展的自动扩展更新.但是,当我想在无人值守模式下在我的团队的所有计算机上禁用扩展FOO的自动更新时,我该怎么办?
我想要一个选项来使用AD GPO或修改Windows注册表以使特定的Visual Studio扩展停止接收自动更新.这现在有可能吗?
visual-studio vsix visual-studio-extensions visual-studio-2017
我正在开发当前使用 .NET Framework (4.8) 的 VS 2019 扩展。我想将其升级到 .NET 5.0,但 VSIX 项目不支持它或任何 .NET Core 版本。如果可能的话,我想避免使用 .NET Standard。我找不到有关下一个 Visual Studio 版本(2021?)以及是否支持 .NET 5.0 VSIX 项目的信息。我认为微软会致力于此,但另一方面 VS 仍然是一个 32 位应用程序。:-) 抱歉,如果这不是正确的地点,但这是我的第一个问题。