Deploying Remotely to .NET Box
For years, I've been able to do a build using a continuous build system like Jenkins and then remotely deploying my apps to various Unix servers. I can use the ssh
and scp
commands to do my bidding.
Now, I have a .NET build I'm doing. I've done the build using Jenkins and would now like to deploy to a remote .NET server. I need to shutdown the application, copy the files over, and then restart the application. I need to be able to do this remotely and via command line tools (no GUI tools). I am on a series of machines that are locked down, and cannot deploy stuff willy-nilly -- especially to the production machines.
Is there a mechanism t开发者_如何学Chat will allow me to remotely shutdown the server, deploy a new set of files, and restart the application?
BONUS QUESTION
I understand that a *.cab
file is somewhat similar to a Java *.jar
file. That is, you can deploy a single *.cab
file to a server, and the server will treat it as if it's a bunch of files in a directory.
- Is this correct? If so, I'd like to deploy things using the cab file.
- There is a
webapp.config
file that's part of my build that's different for each and every server. I'd prefer to create a cab file that does not contain thewebapp.config
file, that way, the cab file I have can be deployed to every machine without changing it (only the webapp.config file has to be changed).
Thanks
Addendum
I just can't win...
I have a build on machine02 and I need to deploy to machine06. Machine06 is in a DMZ, so I can't add a domain user on it. I can only create local accounts.
With sc
, I can access remote systems, but the account I'm running sc
from also needs to exist on the remote system. Since I can't create a domain account on machine06, and I can't add a computer local account to another Windows system (i.e., make machine06\user an administrator on machine02 too)., I can't use sc
.
I tried the lp commands from Sysinternals. These allow me to specify a user name and password (which I assume is for the other system. However, I get the following error:
C:\Windows\system32>pslist \\machine02 -user remuser02 -password Swordfish
pslist v1.29 - Sysinternals PsList
Copyright (C) 2000-2009 Mark Russinovich
Sysinternals
Cannot connect to remote registry on MACHINE02:
Access is denied.
Failed to take process snapshot on MACHINE02.
Make sure that the Remote Registry service is running on the remote system,
that you havefirewall ports allow RPC access, and your account has read
access the following key on the remote system:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Perflib
C:\Windows\system32>
Since that user is an admin on machine02, I am sure that user has read access to the Windows registry key, and I verified that Remote Registry Access is on. I suspect that the router is blocking RPC calls.
So, sc
is out since I can't specify an account to use. The Sysinternals PS tools are out. I can't add the sshd
on the server.
When deploying web applications before I've used vbscript and powershell plus good old fashioned xcopy (though I'd agree robocopy is probably a better copy replacement).
So going through the requirements - I think this is the sort of thing you want to do (this should be done form a PowerShell command prompt):
get-service iisadmin -ComputerName TARGETMACHINE | Stop-Service -force
xcopy source dest
get-service iisadmin -ComputerName TARGETMACHINE | Start-Service
I wouldn't use *.cab unless you wanted compression for transferring the files then I'd use a *.zip file. I don't believe their is any real difference between the two but in general *.cab files are used in msi deployments.
Personally, unless you have someone how understands MSI versioning well, I don't think MSI should be used to deploy files to a web server. And even if someone did understand it I still like it's only useful for tracking what's installed where which can be achieved many ways whilst avoiding autoupdate etc...
As it's IIS you may what to remove the temporary asp.net files whilst the web site is down.
I've made the assumption (from the tags) that this is a web application, hence iisadmin in the code. This would equally work with any service.
HTH, Matt
You could use netsvc.exe to stop and start the IIS service on the remote machine
SYNTAX: NETSVC servicename \\computername /start (or /stop)
I see you have already accepted an answer, but I thought I would add this, because maybe it is useful to someone else:
You could also use PsTools. It allows you to remotely execute commands, stop and start services, copy files etc. (No installation needed on the target host).
Perhaps you want to try a Windows version of an SSH server? For example http://mobassh.mobatek.net/. As usual, the free version has fewer features, but if you are able to execute commands remotely, you might be able to do carry your deployment tasks.
精彩评论