用于vcdebugsettings的microsoft.visualstudio.vcprojectengine中的错误 [英] Bug in microsoft.visualstudio.vcprojectengine for vcdebugsettings

查看:128
本文介绍了用于vcdebugsettings的microsoft.visualstudio.vcprojectengine中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用VC ++(Visual C ++)项目自动化为Visual Studio 2015解决方案设置远程调试设置的过程。

在VSIX项目中,我可以使用ENVDTE并尝试使用以下命令设置remotedebugger设置。但是在设置remoteDebugger工作目录时有一个错误。它永远不会奏效。所有其他的VCDebugSettings都有效。尝试更改工作目录只会更改Local Debugger工作目录。帮助!!!!

我正在使用的Visual Studio Dll位于C:\Program Files(x86)\ Microsoft Visual Studio 14.0 \ Common7 \IDE \ PublicAssemblies\Microsoft。 VisualStudio.VCProjectEngine.dll,适用于Visual Studio 2015中的VC ++项目。



您是否遇到过此问题?我做错了什么或有解决方法吗?



 // --------------- -------------------------------------------------- ------------- 
//< copyright file =ToolWindow1Control.xaml.cscompany =Company>
//版权所有(c)公司。版权所有。
//< / copyright>
// -------------------------------------------- ----------------------------------

名称空间VSIXProject1
{
使用System.Diagnostics.CodeAnalysis;使用System.Windows
;使用System.Windows.Controls
;
使用Microsoft.VisualStudio.Shell;
使用Microsoft.VisualStudio.VCProjectEngine;
使用EnvDTE;
使用EnvDTE80;

///< summary>
/// ToolWindow1Control的交互逻辑。
///< / summary>
公共部分类ToolWindow1Control:UserControl
{
///< summary>
///初始化< see cref =ToolWindow1Control/>的新实例类。
///< / summary>
public ToolWindow1Control()
{
this.InitializeComponent();
}

EnvDTE.DTE dte2;
///< summary>
///句柄通过显示消息框点击按钮。
///< / summary>
///< param name =sender>事件发件人。< / param>
///< param name =e>事件args。< / param>
[SuppressMessage(Microsoft.Globalization,CA1300:SpecifyMessageBoxOptions,Justification =示例代码)]
[SuppressMessage(StyleCop.CSharp.NamingRules,SA1300:ElementMustBeginWithUpperCaseLetter,Justification = 默认事件处理程序命名模式)]
private void button1_Click(object sender,RoutedEventArgs e)
{
dte2 = Package.GetGlobalService(typeof(DTE))as DTE;
SolutionBuild2 sb =(SolutionBuild2)dte2.Solution.SolutionBuild;
项目项目2 = dte2.Solution.Projects;
VCProject vcproject = null;
if(projects2.Count> 0)
{
foreach(项目2中的项目项目)//刚刚获得第一个简单项目
{
vcproject = project。对象为VCProject;
休息;
}
if(vcproject!= null)
{
//更改两种配置。
foreach(vcproject.Configurations中的VCConfiguration配置)
{
VCDebugSettings debugging = configuration.DebugSettings; //获取调试设置
debugging.DebuggerFlavor = eDebuggerTypes.eRemoteDebugger;
debugging.Remote = RemoteDebuggerType.DbgRemoteTCPIP;
debugging.DebuggerType = TypeOfDebugger.DbgAuto;
debugging.Attach = false;
debugging.RemoteMachine =10.10.10.10;
debugging.RemoteCommand = @C:\Program Files\Test.exe;
debugging.SQLDebugging = false;
debugging.WorkingDirectory = @C:\Program Files \; //虫子在这里!不行。
}
}
}
}
}
}





我尝试了什么:



尝试在线研究,但没有人报告这个。

解决方案

来自微软好人的回答如下,它的确有效!在'C:\Program Files(x86)\ MSBuild\Microsoft.Cpp \v4.0 \V140 \ 1033 \' 



  //  解决方法: 
// background:https://msdn.microsoft.com/en -us / library / dn655034.aspx
// 遗憾的是,没有办法进行枚举通过给定规则的各种属性。
// 需要查看各种.xml文件如C:\Program Files(x86)\ MSBuild\Microsoft.Cpp \v4.0 \ V140 \ 1033 \ debugb_remote_windows.xml
IVCRulePropertyStorage rule =(IVCRulePropertyStorage)vcConfig .Rules.Item( WindowsRemoteDebugger);
rule.SetPropertyValue( RemoteDebuggerWorkingDirectory C:\\ SomeWorkingDir \\);


I am trying to automate the process of setting up remote debug setting for a Visual Studio 2015 solution with only VC++ (Visual C++) projects.
In the VSIX project, I can get the solution using ENVDTE and try to set the remotedebugger settings using the following commands. There is a bug however in setting the remoteDebugger working directory. It never works. All the other VCDebugSettings work. Trying to change the working directory only changes the Local Debugger working directory. Help!!!!
The Visual Studio Dll I am using is at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.VCProjectEngine.dll which is for VC++ projects in Visual Studio 2015.

Have you faced this issue? Am i doing something wrong or is there a workaround?

//------------------------------------------------------------------------------
// <copyright file="ToolWindow1Control.xaml.cs" company="Company">
//     Copyright (c) Company.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

namespace VSIXProject1
{
    using System.Diagnostics.CodeAnalysis;
    using System.Windows;
    using System.Windows.Controls;
    using Microsoft.VisualStudio.Shell;
    using Microsoft.VisualStudio.VCProjectEngine;
    using EnvDTE;
    using EnvDTE80;

    /// <summary>
    /// Interaction logic for ToolWindow1Control.
    /// </summary>
    public partial class ToolWindow1Control : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ToolWindow1Control"/> class.
        /// </summary>
        public ToolWindow1Control()
        {
            this.InitializeComponent();
        }

        EnvDTE.DTE dte2;
        /// <summary>
        /// Handles click on the button by displaying a message box.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        [SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions", Justification = "Sample code")]
        [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Default event handler naming pattern")]
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            dte2 = Package.GetGlobalService(typeof(DTE)) as DTE;
            SolutionBuild2 sb = (SolutionBuild2)dte2.Solution.SolutionBuild;
            Projects projects2 = dte2.Solution.Projects;
            VCProject vcproject = null;
            if (projects2.Count > 0)
            {
                foreach (Project project in projects2)//just getting first project for simplicity
                {
                    vcproject = project.Object as VCProject;
                    break;
                }
                if (vcproject != null)
                {
                    //changing both configurations.         
                    foreach (VCConfiguration configuration in vcproject.Configurations)
                    {
                        VCDebugSettings debugging = configuration.DebugSettings;//getting debug settings
                        debugging.DebuggerFlavor = eDebuggerTypes.eRemoteDebugger;
                        debugging.Remote = RemoteDebuggerType.DbgRemoteTCPIP;
                        debugging.DebuggerType = TypeOfDebugger.DbgAuto;
                        debugging.Attach = false;
                        debugging.RemoteMachine = "10.10.10.10";
                        debugging.RemoteCommand = @"C:\Program Files\Test.exe";
                        debugging.SQLDebugging = false;
                        debugging.WorkingDirectory = @"C:\Program Files\";    //Bug here! Does not work.
                    }                   
                }
            }
        }
    }
}



What I have tried:

Tried researching online but nobody has reported this.

解决方案

Answer from the good folks at Microsoft is below and it works!. There are other property files like debugger_remote_windows.xml in the location ' C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\1033\'



// WORKAROUND:
 // background: https://msdn.microsoft.com/en-us/library/dn655034.aspx
 // unfortunately, there is no way to enumerage through the various properties for a given rule.
 // need to review the various .xml files like C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\1033\debugger_remote_windows.xml
 IVCRulePropertyStorage rule = (IVCRulePropertyStorage)vcConfig.Rules.Item("WindowsRemoteDebugger");
 rule.SetPropertyValue("RemoteDebuggerWorkingDirectory", "C:\\SomeWorkingDir\\");


这篇关于用于vcdebugsettings的microsoft.visualstudio.vcprojectengine中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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