Configure Basic Settings
To start with deployment for Light Switch application, first publish the application using Publish Wizard, but before
starting to pubilsh lightswitch application we need to install ‘Microsoft Web Platform Installer’ in the hosting machine. After that
we need to start the ‘Web Deployment Agent’ Services from the administrative
tools.
LightSwitch Publish Wizard
Once web
platform installer get install we get he option for publish website, click on
the publish and following wizard get open;
In the Application Type section, select ‘Complete application’ option and click Next;
In the Application Server Configuration section, select ‘IIS Server’ option and click Next;
In the Publish Settings section, enter the details for website name and
also select the path to create package for LightSwitch application and click on
Next;
In the Security Settings section select ‘No’
for not to create Application Administrator, as we are not using
AspNetMembershipProvider ‘Profiles’ and ‘Roles’ and click on Next button;
In this Data Connection section, do not mark on
‘Generate the SQL database script’ as we are not using/creating any new
database rather we are attaching existing data source, so go to next tab ‘Attached Data Source’ ;
Add the
connection string for the ‘MyData’
and click on Next button;
(#Note: Please make sure you
have selected Integrated Security = SSPI.)
Once all
setting done, click on the Publish button to ‘Publish’ the LightSwitch application.
Once the
code is published we get the following set of files in the publish folder;
Command Line Deployment for LS Application
Create new folder “DeployBatch” and place some important files in it. Following are required files;
TemplateNewAppPool.zip and TemplateNewWebSite.zip
To deploy
LS application, we need AppPool and WebSite on the IIS Server, so we can create
TemplateNewAppPool, TemplateNewWebSite and batch file with msdeploy commands in
it.
Please find
the reference to create both templates as following;
(Note:
we have skips the steps which required for https)
So we get
following files for creating template for AppPool;
TemplateAppPoolPackage.zip
AppPoolParameters.xml and
DeployNewAppPool.cmd
AppPoolParameters.xml and
DeployNewAppPool.cmd
And
following files for creating template for website
TemplateWebSitePackage.zip
WebSiteParameters.xml and
DeployNewWebSite.cmd
WebSiteParameters.xml and
DeployNewWebSite.cmd
Batch
file to run msdeploy command
Create new
batch file which will have commands to execute packages to create template for
new App pool, new Web Site and deploying our Systembolaget.Web.Admin web site.
Following
commands will be included in batch file;
echo
create new appPool
@echo
off
CALL
E:\Published\DeployBatch\DeployNewAppPool.cmd
echo
create new webSite
@echo
off
CALL
E:\Published\DeployBatch\DeployNewWebSite.cmd
echo
replace SetParameter.xml file with stage/prod SetParameter.xml file
@echo
off
COPY
E:\Published\DeployBatch\LSApplicationSample.SetParameters.xml
E:\Published\LSApplication /Y
echo
SetParameter.xml replaced!
echo
Run deployment package..
@echo
off
CALL
E:\Published\LSApplication\LSApplicationSample.deploy.cmd /Y
echo
replace authorization.xml file with stage/prod authorization.xml file
COPY
E:\Published\DeployBatch\authorization.config E:\WebSites\LSApplication /Y
echo
authorization.xml replaced!
echo LSApplication website created successfully!
Lets
name the batch file as “DeployLSAppPackage.bat”
Authorization.config
for prodtest/prod environment
Add new
config file “authorization.config” as per the environment where we are going to
deploy this package.
For example
for stage we have following groups;
<authorization>
<allow roles="my-roles\AdminGroupStage"/>
<deny
users="*"/>
</authorization>
And for
prod we have following groups;
<authorization>
<allow
roles="my-roles\AdminGroupProd"/>
<deny
users="*"/>
</authorization>
So keep the
group name as per environment given by admin team.
LSApplicationSample.SetParameter.xml
By default,
when you open ‘LSApplicationSample.SetParameters.xml’ file from Published
folder you will get following options to set values;
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter
name="DatabaseServer" value="" />
<setParameter
name="DatabaseName" value="LSApplicationSample" />
<setParameter
name="DatabaseUserName" value="" />
<setParameter name="DatabaseUserPassword"
value="" />
<setParameter
name="LSApplicationSample_IisWebApplication" value="Default
Web Site/LSApplication" />
<setParameter
name="MyData" value="" />
</parameters>
So copy above “LSApplicationSample.SetParameters.xml”
file in “DeployBatch” folder and keep only required parameters as follows;
Delete
unwanted params
As you can
see, we have different name/value pair options to set the parameter value, but
here we have attached existing database and also we are following windows
authentication, in that case we don’t required values for Database related settings.
So here we
can delete top 4 params related to database.
Set
Custom Application Pool
By default
for "LSApplicationSample_IisWebApplication"
we have value as "Default Web
Site/LSApplication", so we can change Default Web Site to ‘myAppPool’ or any app pool name which we
are going to create.
So for an
example here we can change it to
<setParameter
name="LSApplicationSample_IisWebApplication" value="myAppPool/LSApplication" />
Set
Connection String
So finally
we can set different connection string for different environment, add the value
for MyData param as
follows;
<setParameter
name="MyData" value="new
connection string for stage/prod environment" />
Run DeployWebAdminPackage.bat file
We have
created all the required files which we need for deployment for light switch
application, the folder structure for DeployBatch is as follows;
Next step
is to open with command prompt in administrative rights and run the DeployLSAppPackage.bat
file. You will get the desire output as follows;
Once you
run the batch file we can check the output in the output directory, if error
files doesn’t contain any error then our application is deployed succefully on
the IIS Server.
Note: Remember to enable directory browsing in IIS server.



No comments:
Post a Comment