Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Syed Aslam Basha here from the Information Security Tools team.
To test the tools which we develop on the team, at times I need to build a website and publish it. I use a simple way of publishing websites from the command line that saves me LOT of time so thought I would share it.
Launch notepad copy paste the below code and save it as Publish.cmd file. Run visual studio command prompt (as administrator) and run the publish.cmd.
1: @ECHO OFF
2: set WEB_ROOT=C:\inetpub\wwwroot\mytestsite
3: set PROJECT_ROOT=D:\Source\website
4:
5: echo Publishing site %PROJECT_ROOT% to %WEB_ROOT%
6:
7: del /S /Q %WEB_ROOT%\*.* || goto Error
8: rmdir /S /Q %WEB_ROOT%\ || goto Error
9: aspnet_compiler -p "%PROJECT_ROOT%" /v /commercesite /d "%WEB_ROOT%" || goto Error
10:
11: goto Success
12: :Error
13: echo Site was not published
14:
15: goto End
16:
17: :Success
18: echo Site published successfully
19:
20: :End
If there aren’t any errors the site will be published successfully as shown below
C:\Windows\system32>D:\Source\website\publish.cmd
Publishing site D:\Source\website to c:\inetpub\wwwroot\mytestsite Utility to precompile an ASP.NET application
Copyright (C) Microsoft Corporation. All rights reserved.
Site published successfully
C:\Windows\system32>
Modify the above script parameters appropriately to publish site successfully!
-Syed Aslam Basha ( syedab@microsoft.com )
Microsoft Information Security Tools (IST) Team
Test Lead
---------------------------------------------------------
Please leave a comment if the blog post has helped you.
Comments
- Anonymous
March 28, 2011
Simple and useful script. Thanks