Featured Posts

Saturday, July 30, 2016

JQuery validation in MVC6(Asp.Net Core)

I am new to MVC6(Asp.Net Core) and JQuery stack. I have started my new project in MVC6 and JQuery, with out hands on work experience in MVC. One of the major problems I faced during initial phase of the development was form validation using JQuery. Here I am trying to describe the work around to add validation logic to your form using JQuery validation  and data annotations in MVC.

Step1: Add required data annotations to your model class

Step2: Refer jquery.validate.js and jquery.validate.unobtrusive.js in the view or Layout page. If you don't have these scripts in your solution, you can get it through NuGet package.
ie,  
     

Step 3: $("#myForm").valid() will do the magic for you. See the code below.

$("#submitbtn").click(function () {
            var form = $("#myForm");            
            var isValid = form.valid();

            if (isValid) { //If there is no validation error
                alert('form is valid');
            } 
            else {
                alert('form is not valid');                               
        }
    });
Please Note:
I have made this post in a hurry, if some one need any clarity, feel free to comment.


Wednesday, April 20, 2016

Could not connect to the remote computer ("") using the specified process ("Web Management Service") because the server did not respond.

The error mentioned in the title we normally come across while publishing a web application from Visual Studio using web deploy. This is a generic error message so that there are various reason behind it depends on the web deploy settings and configuration. I would like to point out two configurations I missed, when I configured it recently.

Management Service should be configured to allow remote connections


Open the Internet Information Services Manager and select the machine name node. In the Features view, scroll down to the Management section. Double click the Management Service icon, and verify that Enable Remote Connections is checked. You must stop the service to make changes, so be sure to restart it when you are done.


IIS Deployment Handler and Remote Agent Service should be installed

In the Programs and Features control panel, find Microsoft Web Deploy 3.5(version depends), right-click and choose Change. In the Wizard that comes up, click next on the first page, and then choose “Change” on the second page. Add IIS Deployment Handler and everything under it.





Sunday, December 21, 2014

MS Release Management- Web.Config tokenization for website project

Introduction

Web.config tokenization/parameterization is one of the major part of releasing web applications across different environments. But when it’s coming to website type project in Visual Studio, it’s a real head ache. I have came across such situation and spend lot of time to find a practical solution to solve this issue. Here I am explaining a tricky method to tokenize web.config, which is partially manual but practically implemented for website type project through MSBuild and MS Release management 2013.

Why Tokenization for Website Projects?

One of the recommended way of web.config parameterization is through Parameters.xml and webdeploy. But this approach is only applicable for web application project in Visual Studio, as this is happening through project file(csproj/vbproj). As you may know, Website project don’t have a project file. Because of the same reason, Config Transforms also will not work for website projects.
Here I am explaining a customized method of web.config tokenization applicable for website projects.

Tokens

Tokens are used by release management to know part of text that needs replacement with specific values. For release management to recognize a token, it needs to be prefixed by two underscores (__) and post-fix by two underscores (__), for example __WelcomeText__. Standard transformation will be applied while building on the Build server in order to have tokenized configuration files available in the drop location ready for release management to use during deployment.

Web.Token.Config

We need to add a new config file to the project, I named it as web.Token.config. This file is an exact copy of our web.config file. Only difference between web.config and web.Token.config is, web.Token.config will have tokens instead of original values. See the below screens for more clarity.
WebConfig
Picture 1
clip_image004
Picture 2
Picture 1 shows the original configuration file used for the development purpose and picture 2 is our token file with tokens instead of real values. These tokens will be replaced through RM tool, will explain in the upcoming sections.

TokenizeAndDeploy.bat

TokenizeAndDeploy.bat is batch file and this file is playing a key role in release process. There are two steps included in this file.
1. Replace web.config with web.Token.config
2. Copy build from the source location to the destination folder
clip_image006
Picture 3
You can see two lines in this batch file. First line copy and replaces the web.config file with web.Token.config. Second line will copy the published website from the build drop location to the destination folder, where destination folder is mentioned as an argument to the batch file. That is, %1% is a batch file argument and the value will be passed in the release template.

Create new component in Release Management Client

We need to create a new component in release management client and this component will make use of our batch file to release our published site. We have to specify the source location of the published site and which is under build drop location, see the screen below. Make sure that TokenizeAndDeploy.bat also kept under the website root folder, otherwise we need to mention the inner folder path in the next tab (Deployment).
RMComponentCraete
Picture 4
Deployment
Picture 5
In the Deployment tab:
Tool: No tool
Command: TokenizeAndDeploy.bat _InstallationPath__
(Value will be passed in the release template)
Timeout: Depends on the amount of files to be copied and the network speed, default will be 5 minutes
RMComponentConfigutaionVariables
Picture 6
Now our web.config contains all tokens and we need to replace the tokens with the values with respect to the target environment (ie, UAT, Production etc). Configuration Variables playing this role. We need to add variables for each tokens in our web.Token.config. Variable name should be exactly same as that of the token, ie one of our token is __DocumentPath__ so we have created variable DocumentPath. Select After Installation as the variable Replacement mode as shown in Picture 6.
Save & Close this component and we need to add this component in the release template.

Add Component to the Release template

Instead of XCopy deployer, we need to make use of the newly created component in our release template. Add Tokenize & Copy component to the tool box and drag and drop it to the server box of our deployment sequence.
clip_image014
Picture 7
clip_image016
Picture 8
Double click on the Tokenize & Copy component in Picture7 and we can see the input boxes to provide values for each configuration variables in Picture 8. Same component we can use with different Stages (UAT, Production, Client1 Client2 etc) in the release template. So from the next release onwards, our web.config will be properly updated with the Stage specific entries.
My previous articles may help you in case you have any confusions using release management client.

Conclusion

Here I have tried to explain one of my implementations of web.config tokenization which is applicable to website type project in Visual Studio. It’s hard to convert website project to web application, if the application is complex and big. This could help people those who are struggling to find a possible way to release website projects across different environments using TFS and MS Release Management for Visual Studio 2013.
Thank you.

Tuesday, September 16, 2014

Rename Website Project in Visual Studio 2013


You cannot rename a website type project in Visual Studio 2013 by simply right click and rename...!!

This issue is caused by IIS Express. You can solve it by changing the site name in applicationhost.cofig of your IIS Express. While changing the name, make sure that this name is unique.

Steps to modify applicationhost.cofig
  1. Find the applicationhost.cofig of your IIS Express, usually it should be listed in Folder C:\Users{username}\Documents\IISExpress\config
  2. Locate the corresponding site section of your project in the cofig file, shown below.
<sites>
            <site name="WebSite1" id="1" serverAutoStart="true">
                <application path="/">
                    <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation=":8080:localhost" />
                </bindings>
            </site>
      3. Rename "WebSite1" to "WebSite2" and make sure that "WebSite2" is not already in use. Save            the file.
     4. Close and Reopen your solution in VS, you'll found that the specif name for your website                    project  has been renamed.

Thank you

Thursday, September 11, 2014

MS Release Management - Database deployment using DACPAC

Introduction

This article aims at providing guide lines to automate Databases release to SQL Server using MS Release Management tool and Data-tier applications in Visual Studio. If you are not familiar with Release Management, you can make use of my article to configure the RM environment.

Background

Database integration is a main headache in continuous integration of Software Applications. Integrating Databases manually is very painful and required lot of effort to keep track of the schema changes, updating scripts etc. Release Management for Visual Studio 2013 is a very useful tool to achieve continuous integration of applications. 

Data-tier Applications

DAC is an entity, which defines all SQL Server DB object like tables, views etc. Database developer can use SQL Server Data Tools database project to design a database in Visual Studio. A successful build of this project will generate a DACPAC file with .dacpac extension. Go through the below article url for a better understanding on DAC.

Prerequisites

Few installations need to be done/verified on the target DB server before going forward with DACPAC deployment through RM Client.
  • MS Deployment agent should be installed, configured and its identity should have access to SQL Server DB instance. The user must be a member of the dbmanager role or assigned CREATE DATABASE permissions to create a database, including creating a database by deploying a DAC package. The user must be a member of the dbmanager role.
  • .Net 4.0 should be installed.
  • Microsoft SQL Server 2012 Transact-SQL Script Dom should have been installed. You can verify the installation  by looking for C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.TransactSql.ScriptDom\v4.0_11.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.TransactSql.ScriptDom.dll

DACPAC Deployment

Main activities to deploy a DACPAC file to SQL Server database instance can be categorised in to two.

  1. Create SQL Server Data Tools database project
  2. Create Component & Release Template in RM Client
  3. Trigger the Release

Create SQL Server Data Tools database project


Here you are going to create a DB project for an SQL Server DB which is already available in your development environment. Connect to the development DB instance through SQL Server Object Explorer in Visual Studio 2013. Right click on the DB and choose "Create New Project" as shown below.

Provide a name for the project, location to store and click Start.

Import database progress will be shown in the next screen as shown below. Once done, click finish

Your DB project will be created at this time and you can check it under solution explorer as shown below.
DB snap shot should be created and this action will provide a file with .dacpac extension. Right click on the project and create DB snap shot as shown below.
"Snapshots" folder will be created under the solution and i renamed it as DemoDBProject.dacpac file will be created under this folder.

Here i am explaining build externally method of RM component to pick the input package.  You need to move this DemoDBProject.dacpac into a shared folder, which should be accessible by the MS Deployment Agent(Provide read permission for the account running MS Deployment Agent).

2. Create Component & Release Template in RM Client

You need to create a new component and release template to trigger a new release. Basic RM configurations should be done prior to this. 

 2.1. Create Component

Open RM client and go to Components under Configure Apps tab. Click on new button. Provide component name and select Build Externally option. Input folder of the dacpac file should be provided here. See the below screen for the clarity.
Select Deployment tab, choose DACPAC Database Deployer(red marked below) and click  save & Close.

2.1 Create Release Template

Create a new Release template, provide name and select release path as shown below. Since our build source is a shared location, no need to select TFS build definition here.
We need to use the component created in 2.1 in our release template. To add the component here, right click on the components in the left panel as shown below and click on Add.
From the components list, choose the newly created component for DACPAC deployment and click on Link button which is shown below.
As you may know, first we need to drop destination server in to the Release Template. You can drag and drop it from the left panel. 
Now the component should be dropped in the server box. Double click on the component box and provide the parameters, which is required.

3. Trigger the Release

Create a new Release, provide name and select newly created Release Template here. Click on Start button and trigger the release.
You can see the status of the release as shown in the below. If the release is successful, the status will be Done as shown here.
Connect to the target SQL Server DB instance and open the DB, both you have provided as parameters for the component while creating the release template. Check the DB schema and verify the release status.

Conclusion

DACPAC is a very useful utility for the DB deployment. Which avoids the headache to synchronise the  DB schema against new enhancements and fixes of a software system in different environments. MS Release Management tool help us to make use of the DACPAC  in a very effitient way to relase DB and this can be done along with application release as well.
Thank you.



Monday, September 8, 2014

TFS Build error: Type 'Rad Control Name' is not defined.

I have just started using TFS build and my build was keep on failing and showing errors like Type 'RadTextBox' is not defined,  Type 'Telerik.Web.UI.GridCommandEventArgs' is not defined, : Name 'RadGrid' is not declared. My local build was working with out any issues. I spend hours for a solution and finally I get it. This may help someone as well.

Solution:

Add Telerik.Web.UI.dll  to source control, check in and Queue New Build...!

Wednesday, July 30, 2014

Untrusted domain connectivity in Release Management for Visual Studio 2013

Overview

The scenario is to deploy your web application to a machine, where there is no domain trust between your RM (Release Management) environment and that target machine.

This post explains the steps to configure RM to work across untrusted domains using ghost/shadow accounts. Ghost accounts are local user accounts with same user name and password in two machines. Here you will install RM in one machine and Deployment Agent in another with out any domain trust.

Step 1(Create user in target server):

Create a user in the target server where you want to deploy the application. Password should be created with never expire policy.


Assign the user to the member of Administrators group.
   

Step 2(Microsoft deployment agent 2013 installation):

Install Microsoft deployment agent 2013, there are only few simple steps to install this as showing below.



If you click on the Launch button, a screen will be shown with a text box to provide RM server url and credentials to connect with RM server. We will do it later.


Step 3(Create user in the RM server machine)

Create a user with same user name and password(step 1) in the RM server machine, which we call it as ghost/shadow account.

Create the RM server shadow account as a new user in RM client and grant both “Service User” and “Release Manager” permissions. In the below screen, Release Manager should be "Yes".



IMP 
Add deployment agent's shadow account to RM client and grant “Service User” and “Release Manager” permissions. This  “Release Manager”permission can be reverted once this connection established successfully.

Ex: If deployment agent machine name is Machine2, two user should be created in RM client, ie "user name" with as describe earlier in this step and Machin2/

Step 4 (Configure Microsoft Deployment Agent)

Now login to deployment agent machine using Ghost account  and open Microsoft Deployment Agent 2013. A configuration window will be opened, there you have to provide RM server url and account to connect. You should provide ghost account and click on Apply Settings. If your configuration is successful, following window will be shown.
 





NB: Incase of any error in the above step, verify earlier steps and make sure that you have followed each instruction correctly.

Step 5

Open Servers tab under Configure Paths in RM client. Registered servers will be listed there as showing in the below screen. Click on Scan For New.

A pop up will be displayed with unregistered server details. Your newly configured server should display in that list and you can register that server by double clicking on it or click register button, as showing in the below screen.


Conclusion

RM gives the flexibility to automate and manage your release process. I hope this article will help you to configure and design your release with out the barrier of domain trust.
If you are new to RM, you can make use of my post http://www.msdevtips.com/2014/05/release-management-for-visual-studio.html to understand and configure RM.
Enjoy your releases with Release Management for Visual Studio 2013. 

Thank you for reading.
























 
Blogger Templates