其他电脑上的Visual Studio远程上传和调试 [英] Visual Studio remote upload and debugging on other computer

查看:45
本文介绍了其他电脑上的Visual Studio远程上传和调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法远程上传、运行和调试另一台计算机上的应用程序?

Is there any way to remotely upload, run and debug an application on another computer?

我知道您可以将 Visual Studio 远程调试器附加到在远程计算机上运行的应用程序,但我正在寻找一种完全自动化的方法.

I know you can attach the Visual Studio Remote Debugger to an application running on a remote computer, but I'm looking for a completely automated way of doing it.

我正在构建一个家庭自动化系统,如果我能在 Visual Studio 中获得某种插件,让我在 VS 中按 F5,然后应用程序就可以正常构建并发送到我的服务器 PC 并在那里运行(附带远程调试).

I'm building a home automation system, and it would be AWESOME if I could get some kind of plugin to visual studio which would let me hit F5 in VS and then the application would just build as normal and be sent to my server PC and run there (with remote debugging attached).

问题是我的笔记本电脑没有我的服务器 PC 拥有的所有硬件.我可以手动将它连接到我的笔记本电脑,但老实说,这样做 2-3 次后会变得很无聊......此外,两台计算机之间的串行端口名称和一些其他硬件相关的东西是不同的.所以这意味着我对每个系统都有不同的配置.

The problem is that my laptop don't have all the hardware that my server PC has. I can connect it manually to my laptop but the be honest, that is gonna get boring after doing it 2 - 3 times... Also, the Serial port names and some of the other hardware related stuff is different between the two computers. So that means I have different configurations, for each system.

最后但并非最不重要的一点,我几乎称之为最重要的事情哈哈:我不想躺在床上写代码,或者坐在客厅吃披萨,同时调试我的家庭自动化.现在我被 3 条 USB 线、一条音频线和一条连接电视的 HDMI 线绑在我的桌子上......这有点乱.

Last but not least, I would almost call it the most important thing haha: I wan't to be able to lay down in my bed and code, or sit in the living room eating pizza, while debugging my home automation. Right now I'm tied to my desk by 3 USB cables, an audio cable and a HDMI cable going to my TV... That's kinda messed up.

远程调试存在...我们已经上传文件至少10年了...我们之前有程序运行其他程序...请告诉我有人发明了这个系统!!!

顺便说一句.我可以通过 Teamviewer 与应用程序交互.我只是不想经历F5 -> Teamviewer -> 在本地电脑上做事 -> 在远程电脑上做事 -> 测试软件 -> 查找错误 -> 重复"过程.

Btw. I'm fine with interacting with the application over Teamviewer. I just don't want to have to go through the "F5 -> Teamviewer -> Do stuff on local pc -> Do stuff on remote pc -> Test software -> Find bugs -> Repeat" process.

如果我能登录并且程序已经启动并运行就好了.此外,如果我可以让 STOP 按钮停止远程 PC 上的软件,那就太棒了,我什至可能会考虑向让这一切成为可能的人发送六瓶装啤酒哈哈.

It would be nice if I could just log in and the program was already up and running. Also If I could make the STOP button stop the software on the remote PC it would be fantastic, and I might even consider sending a six-pack full of beer to the guy who made it possible haha.

推荐答案

我不知道存在这样的产品但是你可以做很多事情来使平凡的任务变得更容易.

I'm not aware such a product exists however there are a number of things you can do to make the mundane tasks much easier.

1) 将您的启动操作从 Start Project 更改为 Start External Program

1) Change your Start action from Start Project to Start External Program

run_remote_process.bat 中添加脚本

a) 将二进制文件复制到远程/服务器 PC
b) 使用 remcom 在远程机器上启动您的进程

a) copy your binaries to your remote/server PC
b) use remcom to start your process on the remote machine

现在是编码位:将其添加到您的 Main 入口方法中:

Now for the coding bit: add this to your Main entry method:

public static void Main(string[] args)
{
    if(args.Any(arg=>arg=="debug"))
    {
        while (!Debugger.IsAttached)
        {
            Thread.Sleep(100);
        }
        Debugger.Break(); 
    }
}

确保在启动流程时传递 debug 参数.这将挂起您的进程,直到您附加到它为止.

make sure you pass the debug argument when starting your process. This will hang your process until you attach to it.

所以现在您要做的就是使用 Visual Studio 附加到进程.您可以使用键盘快捷键快速执行此操作:

So now all you are left to do is Attach to Process using Visual Studio. You can use keyboard shortcuts to do this quickly:

Alt-D, P(按回车)然后按你的进程的字母滚动到它(回车)

Alt-D, P (press enter) Then press the letter of your process to scroll to it (Enter)

你走吧!

不理想,但比许多手动步骤要好得多.

Not ideal but much better than many manual steps.

这篇关于其他电脑上的Visual Studio远程上传和调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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