Friday, October 24, 2014

cmd.exe - How to re-save web.config using command prompt



I'm using a simple cmd batch file to deploy my Asp.net MVC web application to server network share.




The problem I'm having is that my DLLs can't be simply replaced by new files since existing ones are in use by the IIS. I'm not an admin on the server so I don't have rights to run iisreset remotely.



What I can do is I can open root web.config file and save it, hence forcing IIS to stop my web application and as a result to this I can replace my assemblies.



Question



Since I deploy my app using an automated batch file I'd like to include this web.config file re-save inside it before I start deploying DLLs. Anybody knows how can this be done in cmd? Maybe a change of the file's last modified timestamp would suffice.



Possibile solution




I suppose I could as well write a console application that would change last modified timestamp to DateTime.Now but I don't want to write the code myself. Anyone knows of such existing code on the net, since I can't find it. Or even a command prompt tool (console app without user interaction)?


Answer



Grab a copy of UnixUtils from http://unxutils.sourceforge.net/, there is a command in there called touch which you can use to update the timestamp on the file as you need. Just copy the executable up with your batch file, and add a call to touch web.config and you should get what you need.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...