Recently debugging network communication, each time a little bit of modification, the program from the development machine to copy to the test machine, it is annoying. Since we are the ape, why should be so rigid, can use code to solve the problem, do not use the hand to solve.
First of all, we have no alternative but to copy by hand. At the command prompt, the commands we use to manage files and folders are many, such as rename, DEL, copy for files, MKDIR, RMDIR, and Xcopy for directories. To view common commands at the command prompt, we can view them by entering help at a command prompt, such as:
In general, we all need to copy the entire directory, so I used the xcopy command (if you only copy a single file, you can also use copy), the common parameters of Xcopy are as follows:
Wait, aren't we replicating to the remote machine? How do these commands all operate on this machine? Don't worry, we are not able to share the remote machine's directory, just like the native disk, these commands are also applicable.
The steps for sharing are as follows (familiar can be skipped directly, taking the Win7 system as an example):
- In the folder to be shared, on the right click Properties, switch to the Share tab
- Click the Share button to add the user in the pop-up File Sharing dialog box (add user needs to click the Triangle button in the text box to select the user)
- Set permissions (because we want to copy files so choose Read/write)
In the diagram, I chose everyone, all users. For security reasons, this is not recommended.
- Enter our shared folder address in the browser and enter the username password so that you can copy it directly from the command prompt (if you turn off password-protected password sharing, you can omit this step, but the default Windows is on, and close is in Control Panel, network and Sharing Center, Change the advanced sharing settings)
Well, we now know how to copy a folder to a remote computer by command, but not every time through the command to copy it, it is not as direct as the manual copy. Of course not, our vs is not what others call the universe's strongest IDE, of course, given this, is the generation of events.
Build events include pre-build and post-build events, which are custom processing before compilation starts and after compilation is complete.
In a C + + project, the build event is set in the Project's property page
In C #, also set in the Project's property page
We can edit the build event, where it defines a number of macros (more in C + +), such as the project name, build platform, output directory, and so on. The following is a simple example of C #:
Click the edit post-build event, click the Macro button in the pop-up window, click the macro name in the macro list, insert the macro variable into the edit box, combine macro variables and common commands to achieve rich functionality, such as the copy file above to the remote computer. In addition to using commands, we can call the batch, as shown in, and precede the batch with calls. Note: The current directory of the batch is the output directory of the project (that is, the output directory set in the build, the default is Bin\Debug or Bin\release)
Everything above looks like a good job. However, sometimes I debug found a bug, run directly on the development machine, but reported that the build failed, originally generated after the event did not run successfully. Another check is that the test machine does not turn off the corresponding program. How can we solve this problem?
At this time, we can sacrifice our weapons, Taskkill.
Well, we saw it. You can connect to a remote system, you can specify a user name, specify a password, specify the image name of the process (typically the execution file name of the process, such as XX.exe). Such a good thing, do not take the whole tricky colleague simply sorry myself, I have the brain to fill a colleague's Explorer.exe was I end after a blank look, do a good thing, do not name, please call me Lei Feng.
So I can't wait to start the experiment (don't care how I know the details of the password, I was standing behind the peep)
It's not like you think. Where is the problem?
On the internet a pair, the original problem is on the fire wall, shut down the firewall (according to the network type select the appropriate firewall) on the test machine, sure enough to use.
Of course, in actual use, it is unsafe to switch off the firewall, you can do the following.
- Select Control Panel->windows Firewall--Advanced settings
- Select an inbound rule in Windows Firewall with Advanced Security
- Locate remote Scheduled Task management (RPC), the profile is private, public, and the rules are enabled.
VS automatic replication to remote machines after compilation is complete