这是一个有效的 C#6 测试代码。它在 VS2015 上编译
namespace testcode
{
class Program
{
static void Main(string[] args)
{
string x = null ;
string y = x?.Substring(0, 2);
return;
}
}
}
Run Code Online (Sandbox Code Playgroud)
该cproj有toolsversion14.0
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Run Code Online (Sandbox Code Playgroud)
这就是我试图通过Visual Studio SDK用MSBUILD编译它的方式
//References Microsoft.Build and Microsoft.Build.Framework
namespace MSBuildTest
{
class Program
{
static void Main(string[] args)
{
var pc = new Microsoft.Build.Evaluation.ProjectCollection(Microsoft.Build.Evaluation.ToolsetDefinitionLocations.Registry);
pc.DefaultToolsVersion = "14.0";
pc.RegisterLogger(new Microsoft.Build.Logging.ConsoleLogger(Microsoft.Build.Framework.LoggerVerbosity.Detailed));
var pr = pc.LoadProject(@"C:\path\to\testcode.cproj");
pr.Build();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是错误信息
Run Code Online (Sandbox Code Playgroud)Program.cs(8,26): …
msbuild microsoft.build visual-studio-sdk c#-6.0 visual-studio-2015
我正在开发 Visual Studio 2017 的扩展,其中包含自定义“工具窗口”。此“工具窗口”包含WPF control订阅view model的Workspace.WorkspaceChanged和EnvDTE.DTE.Events.WindowEvents.WindowActivated事件。
我知道,当用户关闭“工具窗口”时,它实际上并没有被破坏,而是“隐藏”了。然而,它仍然对我的事件做出反应。
所以,我想知道两个问题的答案:
编辑:创建工具窗口的代码:
protected virtual TWindow OpenToolWindow()
{
ThreadHelper.ThrowIfNotOnUIThread();
// Get the instance number 0 of this tool window. This window is single instance so this instance
// is actually the only one.
// The last flag is set to true so that if the tool window does not exists it will be created.
ToolWindowPane window = Package.FindToolWindow(typeof(TWindow), id: 0, create: true);
if …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个VSPackage项目(使用Visual Studio 2010 SP1 SDK),当我不添加自定义编辑器时,它可以很好地工作.但是,当我这样做时,它仍然停留在"创建项目VSPackageX ......"并且Visual Studio基本上没有响应.
事件日志中没有任何内容,我不知道Visual Studio的日志文件位于何处.
关于如何解决这个问题的任何想法?
projects-and-solutions visual-studio-2010 vspackage visual-studio-sdk visual-studio-2010-sp1
我试图从命令行构建一个Visual Studio包并遇到问题.
该项目在Visual Studio环境中完美构建,包括发布和调试.我只是想通过命令行来构建项目.其他项目,而不是Visual Studio Package项目,构建正常.问题是引入了VSSDK.
错误:
12:33:41.147 2>C:\Program Files (x86)\MSBuild\Microsoft VisualStudio\v12.0\VSSDK\Microsoft.VsSDK.Common.targets(107,5): error VSSDK1000: Failed to load 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK\VisualStudioIntegration\Tools\bin\VSCT.exe' Assembly. Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK\VisualStudioIntegration\Tools\bin\VSCT.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format. [C:\VsProjects\MyProject\MyProject.csproj]
Done executing task "VSCTCompiler" -- FAILED. (TaskId:24)
12:33:41.147 2>Done building target "VSCTCompile" in project "MyProject.csproj" -- FAILED.: (TargetId:42)
12:33:41.147 2>Target "_CheckForCompileOutputs: (TargetId:43)" in file "C:\Program Files …Run Code Online (Sandbox Code Playgroud) 是否可以在 Visual Studio 2017 sdk 中拦截项目保存事件?
更新
我目前正在开发 Visual Studio 2017 的扩展,我需要知道何时保留任何更改。
例如:当我在项目中添加新引用时(我知道添加/更改/删除引用但不满足我的需要时会发生事件),该项目被标记为待保存。我需要在保存时拦截它(如果在保存之前拦截就更好了)。
我尝试了该Dte.Events.DocumentEvents.DocumentSaved事件,但在保存项目中没有触发;DTE.Events.SolutionEvents和DTE.Events.SolutionItemEvents没有我需要的类型的事件。
有可能的?
visual-studio-sdk visual-studio-extensions visual-studio-2017
给出了两个VSX项目的演示解决方案:1.添加新项目 - >可扩展性 - >项目模板 - "ItemTemplate1"2.添加新项目 - >可扩展性 - > VSIX项目 - "VSIXProject1"
我没有对"ItemTemplate1"进行任何更改,因此它构成了默认项模板(ItemTemplate1.vstemplate):
<VSTemplate Version="3.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>ItemTemplate1</Name>
<Description><No description available></Description>
<Icon>ItemTemplate1.ico</Icon>
<TemplateID>e298765c-97b8-4f4c-9b7b-a6b368f914df</TemplateID>
<ProjectType>CSharp</ProjectType>
<RequiredFrameworkVersion>2.0</RequiredFrameworkVersion>
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
<DefaultName>Class.cs</DefaultName>
</TemplateData>
<TemplateContent>
<References>
<Reference>
<Assembly>System</Assembly>
</Reference>
</References>
<ProjectItem ReplaceParameters="true">Class.cs</ProjectItem>
</TemplateContent>
</VSTemplate>
Run Code Online (Sandbox Code Playgroud)
在VSIXProject1中,我只编辑了source.extension.vsixmanifest,添加了对ItemTemplates1项目的引用.在此之后,vsixmanifest只包含一个内容描述:
<Content>
<ItemTemplate>ItemTemplates</ItemTemplate>
</Content>
Run Code Online (Sandbox Code Playgroud)
然后建造它.在bin/debug中我得到了VSIXProject1.vsix,在其中我可以在ItemTemplates\CSharp\1033\ItemTemplate1.zip文件中看到我的项目模板.
一切看起来都很棒!
除了它不起作用的事实.我运行VSIXProject1.vsix,安装了vsix(我可以在扩展管理器中看到它),但没有任何模板被复制到"C:\ Users\{UserName}\Documents\Visual Studio 2010\Templates\ItemTemplates"!
我正在运行某种分析并将结果显示在工具窗口内的列表中。结果如下所示:
#sourcefile::lineNum , ratio
c:/.../file1.cpp::45 , 81%
c:/.../file2.cpp::12 , 49%
Run Code Online (Sandbox Code Playgroud)
我想要做的是,单击,在资源管理器窗口中打开源文件并跳转到特定行。
任何想法如何做到这一点?谢谢。