Click here to Skip to main content
15,886,019 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
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.
Posted
Updated 14-Mar-18 16:00pm
v5
Comments
Richard MacCutchan 31-Jan-18 12:15pm    
You should report this to Microsoft.
nitrous_007 31-Jan-18 15:21pm    
Will report to Microsoft

1 solution

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\'


C#
// 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\\");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900