Arindam Sinha Online

December 16, 2009

Web Deployment Simplified – Microsoft’s Web Deployment Tool

As part of regular Internet Browsing, I came across about Web Deployment Tool. Microsoft has made life easier for the developers and the administrators.In this post, I will high light the features which attracted me. First and foremost, I look for the free tools which can be leveraged to organization level. Web Deployment Tool is certainly one of those.

What’s Web Deployment Tool?

Web_Deployment_ToolThe Web Deployment Tool is an IIS extension, containing essentially a set of tools and a managed framework for simplifying the deployment, management and migration of Web applications, sites and even entire servers.It is a free download and there are no plans to charge for this IIS extension in the future.

In nutshell, this tool simplifies the migration,management and deployment of IIS Web servers, Web Application and Web Sties.Administrators can use command-line scripting with the Web Deployment Tool to synchronize IIS 6.0 and IIS 7.0 servers or to migrate an IIS 6.0 server to IIS 7.0. The Web Deployment Tool also enables administrators and delegated users to use IIS Manager to deploy ASP.NET and PHP applications to an IIS 7.0 server.

Easy Migration of Web applications between IIS 6.0 and IIS 7.0

This tool simplifies the migration of web applications between IIS 6.0 to IIS 7.0. This tool determines the incompatibilities and suggests the proposed changes before the process gets started. Knowledge of potential issues in advance, will help the IT People to take corrective actions by simplifying the migration plan.

Efficient Server Farm Synchronization

I think this will be very much useful for web-farm scenarios. From my personal experience also, organizations having different environments (like DEV, QA, Integration, Staging and PROD) with multiple servers face difficulties to synchronize the boxes. When different teams work on multiple enhancements, projects the servers become out-of-sync sometimes.

The tool simplifies the synchronization process by automatically determining the configuration, content and certificates to be synchronized for a specific site. In addition to the default behavior, you still have the option to specify additional providers for the synchronization, including databases, COM objects, GAC assemblies and registry settings.

The tool can be used to synchronize a web farm, including deploying new applications or just keeping changes synchronized between the web farm servers. The tool does not currently support a central UI or configuration store for a list of servers in a farm (i.e., syncing multiple machines at once), but you can simply store this list of servers and perform sync operations against each server. These can easily be scheduled using System Center or another scheduling mechanism. Resources that can be synchronized include Web sites or applications, content folders and files, databases, registry keys, assemblies in the GAC and more. You can also build custom “providers” that understand other types of resources that are not supported in-the-box.

Package, archive and deploy Web applications more easily

The Web Deployment Tool enables you to package configuration and content of your installed Web applications, including databases, and use the packages for storage or redeployment. These packages can be deployed using IIS Manager without requiring administrative privileges. The tool integrates with Visual Studio 2010 to help developers streamline the deployment of Web applications to the Web server. The tool also integrates with the Web Platform Installer to allow you to simply and easily install community web applications.

Key Features

  • Seamless integration with IIS 7.0 Manager and Visual Studio 2010 interface for creating packages and deploying them onto a machine, both locally and remotely.
  • Seamless integration with the Web Platform Installer to install community web applications simply and easily.
  • Web application packaging:
    • Ability to package a Web application or an entire site, including the associated databases.
    • Ability to package ACLs, COM, GAC and registry settings.
    • Supports both live servers and zipped packages as a source or destination.
  • Web application deployment:
    • Administrative privileges are not required in order to deploy Web applications.
    • Ability to add powerful parameters to change text in files when they are deployed (such as prompting to replace a connection string when deploying from QA to staging environments).
    • Integration with the IIS 7.0 Web Management Service (WMSVC) for remote deployment by non-administrators.
    • Server administrators have granular control over the operations that can be performed and can delegate tasks to non-administrators.
  • Web server migration and synchronization:
    • Ability to synchronize or migrate the entire Web server, a Web site or application.
    • Synchronizes only the data that has changed.
    • Ability to detect missing dependencies during synchronization.
    • Automatically gathers content, IIS configuration, SSL certificates and ASP.NET configuration when you sync a Web site.
  • In addition to the IIS Manager and Visual Studio 10, tasks can be performed using the command-line, PowerShell cmdlets or public APIs.

References

Overview of the Web Deployment Tool

Web Deployment Tool

August 15, 2009

User Preference using Application Settings

Background

It’s very common that we need to provide custom functionalities in our applications to the users in many respect. So that the user can do some operations at runtime. Sometimes user can resize the form, user can change the color, user can change the text etc. Obviously if our application provides all such customizations then only user can do. Now the challenge comes – when user customizes the forms of our application and wants to hold that state when he restarts the application. Per industry’s terminology this is attributed as User Preferences. In this post I would cover a very basic and easy of doing that.

Original Look and FeelUser Preference - After Saving

Suppose, the original look and feel of the form of an application is shown in the above left image. This is the form developer has created with a bluish background and some text. Now the application provides an option to customize the Form’s as well as button’s properties to be modified by the user at runtime. Now user has preferred to save the reddish form and wants to load this next time onwards. I think this problem statement can site a User preference case study. In this post I would take this one as example and would solve this with source code as well.   

Approach for implementation of User Preferences

The better option would have been to store the Form’s state in a serialized format. As Forms are not serializable it would require custom serialization through out the application with some specific properties based on the requirement.

To have some generic approach with a small piece of custom coding we can achieve the same with Application Settings.

What are Application Settings?

Application settings allow a Windows Forms or ASP.NET application to store and retrieve application-scoped and user-scoped settings. A "setting", in this context, is any piece of information that may be specific to the application or specific to the current user – anything from a database connection string to the user’s preferred default window size. Application settings works by persisting data as XML to configuration (.config) files. In most cases, the application-scoped settings are read-only; because they are program information. By contrast, user-scoped settings can be read and written safely at run time.

If you use Visual Studio, you can define settings within the Windows Forms Designer using the (ApplicationSettings) property in the Properties window. Once the applications settings are created the wrapper class with all those setting are created automatically by Visual Studio.We will discuss later in detail how applications settings are added/deleted/accessed. Now if you want to create your own custom wrapper class to have more control over the settings then this can be achived by writing class inheriting from ApplicationSettingsBase class. Custom controls can also save their own settings by implementing the IPersistComponentSettings interface, which exposes the SaveSettings method.

Implement User Preferences

So far we have come to know what’s application scope and user scope. Now we will concentrate on user scope settings with the example shown in above screenshots.

In this example I have created one form on which a button is placed to save the User Preferences. In the form I kept one Tab control with two tab pages each has PropertyGrid to change the properties of Form and Button. First tab page is to change the properties of form whereas second one is for the button.

Create Application Settings

Now we will create some application settings with user-scope.

To create new Application Settings using Visual Studio –
  • Select the form or control whose properties you want to bind to the new application setting.
  • In the Property Editor, expand the (Application Settings) item, and then click the ellipsis next to the (PropertyBindings) item underneath it.

  • In the Application Settings dialog box, click the drop-down menu for the property you want to bind and select the New command.

  • In the New Application Setting dialog box, configure the setting by giving it a name (e.g. FormForeColor) and a default value (e.g. ControlText) and setting its scope (e.g. User).

For the form I have created some application settings as shown in the red marked section in the Property Grid. Also, for the button I have created few application settings like ButtonBackColor, SaveButtonText.

To Access Application Settings

Once this is done, a wrapper class Settings is created under the Properties folder. Any of these settings can be accessed by Settings class. Now for this example the the FormForeColor can be accessed as shown below.

UserPreferenceSample.Settings defaultSettings= new Settings();
defaultSettings.FormForeColor = this.ForeColor;
Save User Preferences

Till now we have the knowledge of the creation of application settings and accessing those. So it’s only the way you want to have your User Preferences to be implemented. In this example user can change the properties of Form and Button using the PropertyGrid. Also, I provided textboxes where user can provide his/her preferred texts for Form and the Button. Once user has modified all these and clicked the save button, Application Settings have been updated with the user’s selected ones.

//UserPreferenceSample.Settings defaultSettings= new Settings(); 
//- already instantiated
//Save button's settings

 defaultSettings.ButtonBackColor = btnSave.BackColor;

 defaultSettings.SaveButtonText = btnSave.Text; 
//Save the Form's Settings
 defaultSettings.FirstFormHeader = this.Text;

 defaultSettings.FormBackColor = this.BackColor;

 defaultSettings.FormForeColor = this.ForeColor;

 defaultSettings.FormOpacity = this.Opacity;

 defaultSettings.FormWindowState = this.WindowState; 

 defaultSettings.Save();

Now onwards, whenever user starts the application he/she can see preferred view.

Sample config File

Find the sample config file entries as shown below.

<configuration>
  <configSections>
    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      <section name="UserPreferencesExample.Properties.Settings"   type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   allowExeDefinition="MachineToLocalUser"   requirePermission="false" />
    </sectionGroup>
  </configSections>
  <userSettings>
    <UserPreferencesExample.Properties.Settings>
      <setting name="FirstFormHeader" serializeAs="String">
        <value>My First Form</value>
      </setting>
      <setting name="SaveButtonText" serializeAs="String">
        <value>&Save</value>
      </setting>
      <setting name="FormWindowState" serializeAs="String">
        <value>Normal</value>
      </setting>
      <setting name="FormForeColor" serializeAs="String">
        <value>ControlText</value>
      </setting>
      <setting name="FormOpacity" serializeAs="String">
        <value>1</value>
      </setting>
      <setting name="FormBackColor" serializeAs="String">
        <value>Control</value>
      </setting>
      <setting name="ButtonBackColor" serializeAs="String">
        <value>Control</value>
      </setting>
    </UserPreferencesExample.Properties.Settings>
  </userSettings>
</configuration>

Limitation of Application Settings

You cannot use application settings in an unmanaged application that hosts the .NET Framework. Settings will not work in such environments as Visual Studio add-ins, C++ for Microsoft Office, control hosting in Internet Explorer, or Microsoft Outlook add-ins and projects.

You currently cannot bind to some properties in Windows Forms. The most notable example is the ClientSize property.

Application settings has no built-in facility for encrypting information automatically. You should never store security-related information, such as database passwords, in clear text.

References

You can get the source code of the example here.

I always suggest and prefer to read MSDN. You can refer the followings articles which helped me a lot to understand this.

http://msdn.microsoft.com/en-us/library/wabtadw6.aspx

http://msdn.microsoft.com/en-us/library/fwc80dzb.aspx

http://msdn.microsoft.com/en-us/library/8eyb2ct1.aspx

Next Page »

Blog at WordPress.com.