views:

742

answers:

7

In order to improve the deployment / build process of my ASP.NET app, I would like to make a .bat that

  • builds the current solution in release mode
  • xcopy the files to a remote server

Creating a release build via command line is easy.

But how can I xcopy the files to the remote server?

I think I have to map the remote destination to a network drive (?). However I could not connect to the remote server, although I have enabled file sharing for the folder on the server. Maybe the firewall is blocking the request? Which port should I open? Or is there another solution?

EDIT

Thanks for all the answers so far, but I probably need a step by step guide on how to set up the folder sharing on the server. I shared the folder, I opened up port 445 so that I can connect to the server but still, I cant connect from my local machine to the server in order to map the network path to a system drive.

+3  A: 

It might be worth moving the files with XCOPY via a UNC path

\\machine\folder

That will require you to have access to folder from the originating server. Check that the folder has been shared and that the relevant read/write permissions have been granted.

AutomatedTester
Is there a step by step guide on how to setup the server for sharing? I cant seem to get it working.
Max
A: 

Have you tried unleash it?

http://www.eworldui.net/unleashit/

It can move files across networks, run pre build bat files, file masking, etc...

I used to use it before on .net 1.1 projects.

Rippo
A: 

If the server is on your local network, I'd suggest using robocopy instead of xcopy - it has many more useful options and capability to retry on errors. It handles UNC names just fine (as I believe xcopy does too). I think it's available on newer Windows clients - if it's not on your machine Google for it - it's available in various resource kit downloads (I don't know the details of if/when Microsoft started including it in the OS distribution because I've had it in my utility kit for a long, long time now).

If the server isn't local, you can script the command line FTP client to perform the transfer. If you need additional flexibility or security there are many other file transfer options, including WinSCP.

Of course in either case (local or remote server), the server's permissions and your authentication needs to be set up properly for this to have a chance to work.

Michael Burr
+1  A: 

You can use any UNC path: \\machine\sharedFolder. If you don't want to set up a shared folder, you can reference any of the drives on the machine using a $ sign: \\machine\c$\program files\etc. If your machines are in Active Directory, or if you have a local user on the target machine with the same username AND password Windows will handle the authentication seamlessly.

Grzenio
A: 

I think you want:

XCOPY c:\myproject\build\*.* \\server\\build\ /S /E
gkrogers
+1  A: 

All of the above seem to be grand answers - you could look at using an msbuild script and the msbuild community tasks to do all of this - they can zip up your build and ftp it to a remote server.

I've just set this up for one of our sites, took a couple of hours to get my head around it, but it builds the site in release, updates the config files for production, removes unnecessary files and then does the upload.

Paddy
+1  A: 

Since you are deploying a ASP.Net site, I am assuming that you are in a windows environnement (isn't smart ? :)).
SO ! Forget about .bat and go for POWERSHELL !

Anyway, this is not point of your question... To copy to a remote folder you should have the rights to do so on the Remote computer.

Check if you have the same account on your local computer and on the remote one. For instance, if you are logged on your local computer in the domain "Work" with the login "Pipo", you must give the rights to this account to write into your special folder on the remote computer.

You can achieve that with a right click on the folder, security options, and then selecting the correct identity.

Here is a step-by-step guide:

http://support.microsoft.com/kb/301281

Roubachof