问题
Is there any way to remotely upload, run and debug an application on another computer?
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.
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).
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.
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.
The remote debugging exists... We have uploaded files for at least 10 years now... We have had programs run other programs before... Please tell me someone have invented this system!!!
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.
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.
回答1:
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) Change your Start action from Start Project
to Start External Program
In run_remote_process.bat
you add scripts that
a) copy your binaries to your remote/server PC
b) use remcom to start your process on the remote machine
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();
}
}
make sure you pass the debug
argument when starting your process. This will hang your process until you attach to it.
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
(press enter) Then press the letter of your process to scroll to it (Enter)
and away you go!
Not ideal but much better than many manual steps.
来源:https://stackoverflow.com/questions/11923695/visual-studio-remote-upload-and-debugging-on-other-computer