Here is an example of end to end scenario of the last blog VS2010 Beta1 Web Application Project Database package and SMO options. Here, we’re going to package a web application and its database with “Delete existing objects before creating” flag, so that we can test the deploy multiple times without the need to drop the database each time after deployment. This feature should be useful for the daily QA testing.
1. Create a Web Application Project
2. Go to its property page, Deploy SQL property page, click Add to add an connection name. Select it, check “Pull data from an existing databases”. Input a connection string for the source database. Input a connection string for the destination connection string.
3. Saving the project.
4. Looking for the supported SMO options from msdeploy IIS7 module. Start IIS7, and choose “Export Application”.
5. Click “Add Components …” button. Add a new provider, choose dbFullSql.
6. Click “…” in the new provider’s “Provider Settings” column, we’ll see all the available SMO options.
7. Set ScriptDropsFirst=”True” inside the project file (e.g. appName.vbproj/csproj file), and reload it in VS.
<PublishDatabaseSettings>
<Objects>
<ObjectGroup Name="NewConnection1" Order="1">
<Destination Path="Data Source=1p18-fwg35%3bInitial Catalog=SimpleDB1_test1%3bIntegrated Security=True" />
<Object Type="dbFullSql">
<PreSource Path="Data Source=1p18-fwg35%3bInitial Catalog=SimpleDB1%3bIntegrated Security=True" ScriptSchema="True" ScriptData="False" SchemaQualify="True" ScriptDropsFirst="True" />
<Source Path="obj\Debug\AutoScripts\NewConnection1_SchemaOnly.sql" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
8. Package the project from command line: %projectDir%>msbuild WebApplication2.vbproj /target:package
9. Read sample deploy command line batch file and set the environment: %projectDir%\obj\debug\package> WebApplication2.deploy.cmd
set Path=%Path%;"C:\Program Files\IIS\Microsoft Web Deploy"
10. Test the package deploy locally from command line: %projectDir%\obj\debug\package> WebApplication2.deploy.cmd /y
If you check the script created inside the package %projectDir%\obj\debug\package\%projectName%.zip file , you can see the sqlScript file inside with format like following:
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Products_Categories]') AND parent_object_id = OBJECT_ID(N'[dbo].[Products]'))
ALTER TABLE [dbo].[Products] DROP CONSTRAINT [FK_Products_Categories]
GO
IF EXISTS (SELECT * FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_Products_UnitPrice]') AND parent_object_id = OBJECT_ID(N'[dbo].[Products]'))
ALTER TABLE [dbo].[Products] DROP CONSTRAINT [CK_Products_UnitPrice]
GO
IF EXISTS (SELECT * FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_Products_UnitsInStock]') AND parent_object_id = OBJECT_ID(N'[dbo].[Products]'))
ALTER TABLE [dbo].[Products] DROP CONSTRAINT [CK_Products_UnitsInStock]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TotalProductsCost]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[TotalProductsCost]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ShowCategories]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[ShowCategories]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ShowProducts]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[ShowProducts]
GO
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[ProductsPerCat]'))
DROP VIEW [dbo].[ProductsPerCat]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Products]') AND type in (N'U'))
DROP TABLE [dbo].[Products]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Categories]') AND type in (N'U'))
DROP TABLE [dbo].[Categories]
GO
IF EXISTS (SELECT * FROM sys.types st JOIN sys.schemas ss ON st.schema_id = ss.schema_id WHERE st.name = N'ExpireDate' AND ss.name = N'dbo')
DROP TYPE [dbo].[ExpireDate]
GO
CREATE TYPE [dbo].[ExpireDate] FROM [datetime] NULL
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Categories](
[CategoryID] [int] IDENTITY(1,1) NOT NULL,
[CategoryName] [nvarchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Description] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_Categories] PRIMARY KEY CLUSTERED
(
[CategoryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
…
You can see, choose a right SMO option is not trivial. There are many SMO options, combining of which may have different effects. We do need some trial and errors to apply the right SMO option for advanced usage.
Xinyang Qiu
SDETII
Visual Studio Web Tools
In Visual Studio 2010 Beta1 release, SQL server database schema and data can be packaged for deployment along with the website. It utilizes Msdeploy SQL Database provider functionality in IIS team’s msdeploy release.
In Visual studio 2010 Beta1, user can set the database package options in web application project’s Deploy-SQL property page as following.

User can add a package connection by clicking “Add” button and make sure it’s checked. To select the source database for package, one can check “Pull data from an existing database” check box, and select or enter the database connection string. In Beta1, only three packaging choices are provided for the database, “Schema only”, “Complete database” and “Exclude objects with no schema information from the generated script” (SMO option SchemaQualify).
User can also include their own SQL script file in the Database source Scripts list view as well.
Msdeploy SQL Database provider command line provides functionality to use many SMO options to package a database. In order to integrate this functionality to VS2010 Beta1, one can edit the project file directly. The following sample shows the project settings for the default schema only database. Note, the corresponding SMO options are set in PreSource tag of the corresponding connection list item. Advanced user can specify additional SMO option in the project file to script their databases. The additional SMO options will be preserved automatically even during property page operations.
<PublishDatabaseSettings>
<Objects>
<ObjectGroup Name="NewConnection1" Order="1">
<Destination Path="Data Source=myServerName%3bInitial Catalog=myDeployDBName%3bIntegrated Security=True" />
<Object Type="dbFullSql">
<PreSource Path="Data Source=myServerName%3bInitial Catalog=myDBName%3bIntegated Security=True"
ScriptSchema="True" ScriptData="False" SchemaQualify="True" />
<Source Path="obj\Debug\AutoScripts\NewConnection1_SchemaOnly.sql" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
In VS2010 Beta1, there are some known problems regarding the database packaging, including the following:
1. transacted=false SMO option does not function as expected. (For certain database objects, such as full text catalog, full text index, user roles, transacted=false SMO option is required in order to be able to deploy successfully.)
2. triggers using certain objects maybe scripted before the objects is defined. This is resolved with the April 2009’s SQL server 2008 feature pack’s management objects download.
3. SMO options supported is limited by Msdeploy SQL Database provider‘s capacity. Currently, it only support SMO option’s Boolean values.
In addition, we are still modifying the feature based on user’s feedback. Please contact us with your advices. Thanks.
Xinyang Qiu
SDETII
Visual Studio Web Tools
The VWD team is always looking for ways to improve our product for our customers. To help us better achieve this goal we have created a survey that we hope you will take a few moments to fill out.
Click Here to take survey
This survey centers around the VWD designer which provides a WYSIWYG editor for creating and editing Web pages.
All feedback will be carefully considered in our planning.
Thank you for your time,
Mike Snow
SDET Lead
Visual Studio Web Tools
ASP.Net MVC for Visual Studio 2010 is available for download here: http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28527.
There is no new functionality but you should be able to upgrade your applications to target the 4.0 framework (or leave them as is) if you would like to play with ASP.Net MVC on Dev10. Please read the release notes for a couple of gotchas. If you never read release notes, please note the following:
If you are working with Visual Studio Team System 2010 and the Historical Debugger is enabled, Visual Studio might occasionally crash. If you experience this problem, disable the Historical Debugger.
You can disable the Historical Debugger in Tools->Options. Note that this will be fixed in Beta 2.
Hope this helps you develop ASP.Net MVC apps on Dev10
Joe Cartano | Visual Web Developer
With VS2010, we introduced “web deployment tool” as the new publish method; at the same time, FTP publish is still available and supported in VS2010. In web application project system, because we centralized main deployment workflow, so some new features usually introducd at the same time with “web deployment tool” is also available to FTP publish. This includes a most important one “web.config transformation”. You can refer Vishal’s post for more detail of how to author transformation files. In this post I will use a simple case to just show how the transformation is wired even you still use publish methods like FTP or plain file system copy.
1. Create a new web application project
2. Expand the “web.config” node (If you create a Visual Basic project, enable “show all files” in the solution explorer), you will see two extra transformation files, “Web.Debug.Config” and “Web.Release.Config”. Note, if you would like to use your existing web application project, you can open it and right click the web.config node in the solution explorer and invoke the menu of “Add Config Transform”. That will create transformation files for each build configuration.)
3. As the “Web.Release.Config” template has the transformation action defined already to remove the “Debug” attribute for the compilation tag in the web.config file, let us switch the solution build configuration to “Release” (through menu of “Build”->”Configuration Manager…”) and use it.
4. Invoke the “Publish” to get the publish dialog opened. Create a profile and select method of “FTP” (you can use publish method of “File System” if you don’t have a FTP site to publish to, and want to try out with a disk path). Fill in the target location path, click “Publish” and wait for it is done. You can open destination site and check out the web.config, and you will see the “Debug” attribute is removed.
Hope it helps. Also as revealed in the project property tab of “Package/Publish”, there is a new setting of “Exclude Generated Debug Symbols” you can configure as well
Yugang Wang | Software Design Engineer | Visual Studio Web Developer
This blog explains some modification we made to the publish dialog in the web application project system, mainly to accommodate new web deployment tools from IIS team (aka “MsDeploy”). Changes are summarized as following:
1. Persist your publish settings through creating and managing publish profiles
2. Provide a “publish method” combo box for you to choose how to deploy your web
3. Dialog is automatically resized in height to only show configurations applicable to the selected publish method
4. Settings in the “copy” sections in old dialog are moved to project property tab of “Package/Publish”
In VS 2005 & VS 2008, the publish dialog caches some configurations you made in the most recent publishing. Coming into VS 2010, it might not be able to meet users’ requirement as more web applications could have different publishing settings per different build configuration and different publish destinations; also, publishing configurations are requiring more inputs from users especially with “MsDeploy’; therefore, we introduced publish profiles in the new dialog. Before you input any specific publishing settings, give a profile name at the profile textbox and the publish settings will then be persisted across VS sessions.
Next time, you just select the profile in the list and invoking publishing.
The combo box of “Publish Methods” has 4 options.
Vishal has some introduction available on how to use “MsDeploy’ at Web Deployment with VS2010 and IIS (refer the section of “1-Click Publish”). The rest options of “FTP”, “FPSE”, “File System” are essentially no difference with VS 2008, using to publish to destination sites through protocol of FTP, FrontPage server extension, or just plain file xcopy. In the “target location” textbox, you can fill in destination paths, like an ftp or http url or a plain disk path, and invoke publish.
The “copy” section in VS 2008 publish dialog has been moved from the publish dialog to the “Package/Publish” property tab. The rationale behind is that this setting is not a publish only setting, and creating deployment package also uses it (Please also refer Web Deployment with VS2010 and IIS, at section of “Web Packaging”)
Please let us know if you have any questions or feedback.
Yugang Wang | Software Design Engineer | Visual Studio Web Developer
The multi-targeting feature of Visual Studio 2010 allows web developers to develop web applications targeting ASP.NET 2.0, 3.0, 3.5 and 4.0. The key benefit of multi-targeting is that you can use Visual Studio 2010 to create and develop new projects that target earlier versions of the .NET Framework (such as 2.0, 3.0 and 3.5). Multi-targeting in VS 2010 also lets you continue to develop projects that were created using earlier versions of Visual Studio such as Visual Studio 2005 and Visual Studio 2008.
What's different about Multi-targeting in Visual Studio 2010?
We supported multi-targeting of web applications in Visual Studio 2008 as well. But the capabilities we had for multi-targeting in VS 2008 were really a pseudo form of multi-targeting, i.e. even though VS 2008 allowed us to target different versions of the ASP.NET framework 2.0, 3.0 and 3.5, the underlying Common Language Runtime (CLR) for all these frameworks is the same (= the .NET CLR 2.0). With the release of the new ASP.NET 4.0 Beta1 framework (that runs on top of the .NET CLR 4.0 that installs side-by-side with earlier versions of the .NET CLR) along with Visual Studio 2010 Beta1, we now have the ability in Visual Studio to target ASP.NET framework versions spanning multiple versions of the CLR (CLR 2.0 and CLR 4.0).
VS 2010 can detect when your web project is targeting ASP.NET 2.0, 3.0 or 3.5 (that runs on top of CLR 2.0) versus targeting ASP.NET 4.0 (that runs on top of CLR 4.0).
Accordingly:
- VS 2010 allows you to choose ASP.NET 2.0, 3.0, 3.5 or 4.0 as the target framework when you create a new Website or Web Application Project (WAP)
Figure 1
- You can convert and migrate your web applications built using earlier versions of Visual Studio to Visual Studio 2010. Like you could do with VS 2008, you can continue to have your web project target lower framework versions like ASP.NET 2.0 after conversion. See "Converting web projects from earlier versions of Visual Studio" section below for details.
- Visual Studio automatically filters controls in toolbox, and types in intellisense and properties window based on the ASP.NET framework version being targeted
- Compilation and building of the web project works correctly based on the target framework, ie. VS 2010 will show errors when you try to use 4.0 controls or properties in a web project targeting 2.0 or 3.5.
- You can change targets from one ASP.NET framework to the other via the property pages (as you could in VS 2008). Note: In VS 2010, we prompt you to reload the project when you change the target framework of a website project (VS 2008 used to do this for WAP projects). This is to ensure that the references are updated correctly when you change the target.
New capabilities in VS 2010:
We already had the above multi-targeting capabilities in VS 2008. VS 2010 extends these capabilities to handle ASP.NET 4.0 (and the new CLR 4.0). Additionally, in VS 2010,
- When using IIS as the web server, VS will automatically update the application pool for the web project in an IIS server on localhost
- When using the built-in web server, there are now two versions of the built-in ASP.NET Development server in VS 2010, one for each CLR version. VS 2010 will correctly choose the web server version to run based on the framework that the web project is targeting. (You can see which version is in use by right-clicking on the icon for ASP.NET Development Server in your System Tray and choosing 'Show Details' – as shown in Figure 2 and Figure 3 below).
Figure 2 – ASP.NET Development Server icon in System Tray
Figure 3
IIS 7 and application pools
When using web projects with IIS 7, you can only specify one CLR version per application pool in IIS. Therefore, a web project targeting ASP.NET 4.0 (and CLR 4.0) cannot be in the same application pool as a web project targeting ASP.NET 3.5 or lower (CLR 2.0) in IIS 7.
When creating new or re-targeting existing localhost IIS WAPs and IIS websites (HTTP websites) using VS 2010 (example, as in Figure 4), it will automatically set the application pool in IIS for you based on the .NET framework that the web project is targeting. (Remember that you need to run VS as admin if you are using IIS as your development server rather than the built-in ASP.NET Development Server). If an application pool for the current runtime version does not already exist in IIS, VS 2010 will create one for you and then assign the web project to this newly created application pool. You can verify this by selecting the application in IIS and viewing the Basic Settings (as shown in Figure 5). VS 2010 does not automatically update the application pool on a remote server, however.
Figure 4
Figure 5
Converting web projects from earlier versions of Visual Studio to Visual Studio 2010
Conversion of projects creating using VS 2005 and VS 2008 to VS 2010
VS 2010 supports conversion of a web project created using VS 2005 or VS 2008 to the latest version of Visual Studio so that you can take advantage of the new features that are available. The feature works similar to the conversion behavior in VS 2008 - you will be presented with the Visual Studio Conversion Wizard that will walk you through the steps to convert your project to VS 2010 (see figure 6). Like in VS 2008, during conversion of your project, a prompt will appear (see figure 7) allowing you to continue targeting the lower .NET framework version such as ASP.NET 2.0, 3.0 or 3.5, or optionally, upgrade the project to target the latest .NET framework version ASP.NET 4.0.
Figure 6
Figure 7
Conversion of projects creating using VS 2003
VS 2010 also supports limited conversion of a web project created using VS 2003. As above, you will get the conversion wizard but there will not be a prompt allowing you to remain in the lower ASP.NET 1.1 framework. This is because VS 2010 only supports targeting of frameworks 2.0 and above. Rather, the ASP.NET 1.1 web project will get upgraded to a ASP.NET 4.0 Web Application Project.
Note: It is always a good practice to take a backup of your web project before converting it to a newer version of Visual Studio.
Bala Chirtsabesan | SDET | Visual Studio Web Developer
In this blog post I will explain how to get and install the Microsoft Web Deployment Tool, so you can share created packages with others and how to setup a Windows 2008 Server to allow packages to be deployed from Visual Studio 2010 Beta 1. Visual Studio 2010 Beta 1 ships with and installs Microsoft’s Web Deployment Tool as part of the Visual Web Developer. In order to set up a server for publishing or allowing machines to deploy packages created in VS 2010 you will need to download and install the Web Deployment Tool RC1 from the IIS Download Center. Note that newer versions of the Web Deployment Tool may not be compatible with VS 2010 Beta 1. If needed, VS 2010 Beta 1 has the Web Deployment Tool MSIs located in the WCU\MSDeploy directory of the DVD.
Setup for Package Installation:
To consume packages created by Visual Studio Beta 1 or the Web Deployment Tool, you will need to install Microsoft’s Web Deployment Tool. Below are two different options for installing the Web Deployment Tool:
- Microsoft Web Platform Installer
- Download Microsoft Web Platform Installer 2.0 Beta from link above.
- Under the “Web Platform” tab choose “Customize” Web Server and check “Web Deployment Tool 1.0 RC”
- Select “Install”
- The “Install” screen will appear with any needed dependencies. Click the “Accept” button.
- Install from MSI
- Launch the x86 or x64 Web Deployment Tool’s MSI (information for MSI located above.)
- Read and accept EULA. Click Next.
- Select Typical.
- Select Install.
Microsoft Web Deployment should now be installed and useable by the command file generated from VS 2010 for deploying.
Setting up the Web Deployment Tool’s Web Management Service (WMSvc) for administrator publishing on Windows 2008 Server:
Installing the Web Management Service allows users to publish Web Applications from Visual Studio 2010 Beta 1 directly to the server, cutting down on time and steps required to publish applications. Some of the features the Web Deployment Tool helps with are creating applications during deployment and performing incremental publishing. With administrator publishing on IIS 7, users can publish IIS Setting, change the web application’s physical path, and transport Application Pool configurations.
- Make sure the Web Server (IIS) role is added to the Server.
- In the Role Service section, make sure that the Security node and under Management Tools the Management Service is installed.
- Launch the x86 or x64 Web Deployment Tool’s MSI.
- Read and accept EULA. Click Next.
- Select the “Custom” option on the “Choose Setup Type” dialog.
- You should now be presented with following options:
- Select the “Web Management Service” to install the WMSvc handler used by One-Click Publishing.
- “Packaging User Interface” will allow you to install packages created in VS 2010 through Internet Information Services Manager (inetmgr.exe).
- “PowerShell Snapin” adds Power Shell functionality.
- “Web Management Service” is used by One-Click Publish.
- “Remote agent service” is another option for publishing, but is not used by One-Click Publish.
- Finish Web Deployment Tool setup.
- Go back to the Server Manager window and expand the “Configuration” section.
- Under the “Services” node. If present make sure the “Web Deployment Agent Service” and “Web Management Service” are Started and have a Startup type of “Automatic”.
- Run inetmgr.exe.
- Under the root IIS node select the Management Service.
- Stop the service.
- Select “Enable remote connections”
- Select “Apply” and “Start”.
The above steps will allow administrator accounts to publish to this server. If you are testing .NET 4.0 Beta 1 Web Applications you will need to install the framework on the machine you are publishing to or un-packaging on.
Ben Byrd | SDET | Visual Studio Web Developer
With VS10 beta1 environment, you can also install Silverlight 3 beta to combine the power of both.
When a Silverlight 3 beta project is compiled, it generates xap file. The web application or website should take the xap as content for Build Action. The following shows what the default Siliverlight project has:
Having this information, one can use Dev10 Beta1’s deployment features to deploy the Silverilght application to IIS, or simply ftp the xap and related files to the server.
In order to view the silverlight application correctly, one need to setup configure IIS correctly. For Dev10 beta1, make sure the corresponding IIS virtual application is using targeted ASP.NET framework. For example, if the application target is ASP.NET v4.0, please choose an application pool which runs v4.0 beta in IIS7, or mark the virtual application as framework 4.0 in IIS5/6 and make sure it is with an application pool which all the applications run the same framework.
IIS6 may also need to configure the MIME type for the Silverlight .xap extension, by following:
- Open Internet Information Services (IIS) Configuration Manager and select the server to manage (usually the top-level item on the left side)
- Double-click MIME Types on the right side
- Add an entry to map the .xap extension to the application/x-silverlight-app MIME type

For PHP developers, here’s a reference which you can build and deploy Silverlight application in PHP. http://blogs.msdn.com/webdevtools/archive/2009/03/19/creating-silverlight-3-applications-for-php.aspx
Xinyang Qiu | Visual Web Devloper
Today we are announcing the availability of FREE HOSTING accounts for web developers to try out the new feature sets of Visual Studio 2010 Beta1, ASP.NET 4 Beta1 and Microsoft Web Deployment Tool (MsDeploy) RC1…
VS 2010 has great set of features on deploying web applications seamlessly… One of the key features is the ability to publish your web application from VS 2010 to a remote hosted web server along with its dependencies like SQL Server database using “Web 1-Click Publish”… VS 2010 integrates Microsoft Web Deployment Tool (MsDeploy.exe) to provide fast, reliable and cohesive way of deploying web application… Learn more about Visual Studio 2010 Web Deployment Features…
Apart from the web deployment feature set there are various other interesting features in ASP.NET 4 and Visual Studio 2010 including enhancements in ASP.NET Core Services, AJAX, Web Forms, Dynamic Data, VS Web Designer and Editor… To learn more about them check out ASP.NET 4 and Visual Studio 2010 white paper… VS 2010 and ASP 4 Beta1 release does not come with ASP.NET MVC yet, but we plan to include it in the near future…
To allow you to try out all these cool features and deploy the ASP.NET Web Application using Web 1-Click Publish OrcsWeb and DiscountASP are providing free trial accounts (as long as they last :-))…
Before I share the links to get the free trial account there are few important points to note:
- Visual Studio 2010 Beta1 (which comes with ASP.NET 4 Beta1 , Microsoft Web Deployment Tool (MsDeploy) RC1 and SQL Server 2008 Express Edition) is available to download for FREE from http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx
- Read the Step by Step Walkthrough on Web 1-Click Publish with VS 2010 this will help you get started easily…
- These free trial accounts are provisioned with IIS 7 Web Site plus SQL Server 2008 database (and yes the database hosting is also FREE :-))
- ASP.NET 4 Beta1 DOES NOT come with “Go Live” license… These accounts are sandboxed environments for you to try new technologies, please do not host production applications on these accounts…
- The free trial accounts are slotted to expire by October 31st 2009 so you have reasonable amount to try out the new technologies…
So without any further delay let me share the links which will tell you how to grab one of these free accounts… Click on the images below and get one for yourself before they run out:
OR 
We want to hear from you about your feedback, thoughts, ideas on the new feature set; please feel free to use any of the below mechanisms to share your feedback…
- Visit Visual Studio 2010 Beta1 and ASP.NET 4 Beta1 Forum
- Write comments here, other announce or my blog…
- Follow on Twitter with #1ClickPublish…
I hope you will use this offer and try out the new fascinating technologies coming down the pipeline… Enjoy!!
Vishal R. Joshi | Visual Web Developer | http://vishaljoshi.blogspot.com
In this post we will talk about the effects of a particular security enhancement in CLR 4.0 Beta 1 and how it affects working with AJAX Control Toolkit in Visual Studio 10 Beta 1 and possibly other 3-rd party assemblies.
The security enhancement in question is the way CLR 4.0 treats assemblies that came from a remote source (e.g., downloaded from the Internet or copied from a file share of another computer). Prior to CLR 4.0, if such assembly was copied to a local drive on your computer, CLR would treat it as a trusted assembly coming from My Computer zone. This is different from how Windows was treating such assemblies. Downloaded assemblies are marked with a special “Internet” bit and should not be trusted unless a user explicitly grants trust to them. This behavior was implemented in CLR 4.0 Beta 1. Unfortunately, it causes a somewhat obscure error message when working with such assemblies in Visual Studio 10 Beta 1. In particular, this error message happens when you attempt to add controls from such assembly to Visual Studio Toolbar. We will certainly improve the error message or may bypass this security check in this particular scenario in Visual Studio 10 Beta 2, but for now the users should understand what that error message means and the action required from them to give trust to downloaded assemblies that they wish to use in Visual Studio.
Please note that this issue should affect only assemblies downloaded as a plain DLL assembly file, or as a part of a ZIP archive. Third-party assemblies installed by a downloaded executable installer should not be affected by this issue.
As mentioned above, the issue manifests when attempting to add controls from a downloaded assembly to Visual Studio 10 Beta1 Toolbox. In particular, the issue affects AJAX Control Toolkit since it is currently made available for download as a ZIP archive. If the user right-clicks on the toolbox and selects “Choose Items” from the context menu
and browses to the AJAX Control Toolkit assembly
they will get the following error message when adding the items
Could not load file or assembly 'file:///E:\Download\AJAX 1.0\Toolkit\AjaxControlToolkit-NoSource\SampleWebSite\Bin\AjaxControlToolkit.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
In order to be able to add controls from the assembly to the toolbox, the user should grant the needed permissions to the assembly. It should be done by going to the assembly file properties in Windows Explorer
and clicking the “Unblock” button
After that, you should be able to add AJAX Control Toolkit to the toolbox and use it as you did in previous version of Visual Studio.
The public release of Visual Studio 2010 Beta 1 is now available and can be downloaded here.
This is one of the most compelling updates to Visual Studio we’ve seen in years. The entire IDE has been refreshed with a new look and all the code editors including the HTML and ASPX editors have replaced with a new extensible editor based on WPF.
One of the reoccurring themes throughout Visual Studio 2010 is developer productivity. For example integrated into the new code editors is a consume first workflow where you can start calling methods on classes even before they exists. Then you can have VS generate the new code extending the class as you type.
Community is another theme in Visual Studio. Integrated into the new project and new item dialogs is the Visual Studio Gallery containing templates from the community. There is also an Extension Manager that makes it easy to add community developed extensions to Visual Studio.
A good overview of the breath of new features in Visual Studio 2010 can be found on Jason Zander’s Blog.
New for the Web
- Dynamic IntelliSense for JavaScript with vastly superior performance and completeness relative to VS08
- A new editor for web developers with code-focused productivity through HTML/ASP.Net snippets
- Seamless packaging and publishing of web applications to hosted and enterprise IIS servers
- Config transformations for packaging and deployment scenarios
- Standards based CSS 2.1 rendering in Design View
- Silverlight 3 support with interactive XAML designer
- Multi-targeting support to build applications for ASP.NET 2.0, 3.5 and 4.0
Dynamic IntelliSense for JavaScript
This is one of the coolest features in Visual Studio 2010. IntelliSense for dynamic languages like JavaScript has always be problematic. Types and even functions can be added to classes dynamically at runtime. Now in Visual Studio you’ll have IntelliSense on these dynamically created types. Shown below is an example where jQuery was dynamically extended with a new detonate effect and the IntelliSense that follows.
Snippets for HTML and JavaScript
HTML, ASPX and JavaScript files now have full support for Visual Studio’s snippets. No more having to type runat="server" on every control. There are hundreds of new snippets included in Visual Studio 2010.
For example field validation can now be added in just a few key strokes. After the snippet is inserted you’ll only need to fill-in the unique pieces of information highlighted below.
For a glimpse of the productivity gains possible with HTML snippets check out Jeff King’s PDC demo. Skip forward about 13 minutes into the video to go immediately to the snippets demo.
Packaging and Deployment
Visual Studio 2010 now has the ability to completely package and deploy a web application including all it’s IIS settings, Databases and Application logic.
 | There is a new 1-click publishing experience that simplifies publishing and updating your sites. In addition to 1-click publishing there are extensive packaging options to control what specific IIS settings you want included with your package. You can even include custom database scripts to run when your package is installed. As part of the packaging process you can also run custom transforms on web.config that allow you update any section of web.config with custom settings unique to the deployment. For example you can replace database connection strings and web service end points. Vishal Joshi has an excellent post on covering the new deployment features here. Vishal also has posted a general Visual Studio 2010 overview here.
|
CSS 2.1 Layout Rendering in Design View
The HTLM and ASPX designer has been updated with support for CSS 2.1 layout rendering including attribute selectors. The designer will now faithfully render your CSS 2.1 standards compliant markup.
Getting Started
Get started now by downloading Visual Studio 2010 Professional Beta 1
As with any software development process, getting customer feedback in a timely manner helps us make better products. We are looking forward to hearing your feedback on this Beta.
Please visit the Visual Studio 2010 and .NET Framework 4 Beta 1 site to learn more and to download the Beta, submit product feedback, link to forums or find additional information about the Beta.
There is an extensive whitepaper describing all the new ASP.Net 4.0 features here.
Scott Hanselman has a great ASP.Net 4.0 Whirlwind Tour here.
An update for ASP.Net MVC compatible with Visual Studio 2010 Beta 1 will be coming in June.
To find out about ASP.Net MVC for Visual Studio 2010 Beta 1 check out Phil Haack’s blog here.
To ask questions about the new web specific features in Beta 1 check out these forums:
Visual Studio 2010 Beta 1 (on ASP.Net Forums)
Visual Studio 2010 & .NET Framework 4 Beta 1 Web Development Forum
We have earlier discussed about Web Deployment and Web Packaging quite a bit, today I wanted to dive into web.config transformation. If you would like to check out the other topics please read through the earlier blog posts below:
Usually web applications go through a chain of server deployments before being finally being deployed to production environment. Some of these environments can be Developer box (Debug), QA Server, Staging/Pre-Production, Production (Release). While transitioning between these environments various settings of the web application residing in web.config file change, some of these settings can be items like application settings, connection strings, debug flags, web services end points etc.
VS10’s new web.config transformation model allows you to modify your web.config file in an automated fashion during deployment of your applications to various server environments. To help command line based deployments, Web.Config transformation is implemented as an MSBuild task behind the scene hence you can simply call it even outside of deployment realm.
I will try to go through below steps to explain web.config transformation in detail
- Creating a “Staging” Configuration on your developer box
- Adding a “Staging” Web.Config Transform file to your project
- Writing simple transforms to change developer box connection string settings into “Staging” environment settings
- Generating a new transformed web.config file for “Staging” environment from command line
- Generating a new transformed web.config file for “Staging” environment from VS UI
- Understanding various available web.config Transforms and Locators
- Using Web.config transformation toolset for config files in sub-folders within the project
Step 1: Creating a “Staging” Configuration on your developer box
Debug and Release build configurations are available by default within Visual Studio but if you would like to add more build configurations (for various server environments like “Dev”, “QA”, “Staging”, “Production” etc then you can do so by going to the Project menu Build --> Configuration Manager… Learn more about creating build configurations.
Step 2: Adding a “Staging” Web.Config Transform file to your project
One of the goals while designing web.config transformation was to make sure that the original runtime web.config file does not need to be modified to ensure that there would be no performance impacts and also to make sure that the design time syntax is not mixed with runtime syntax. To support this goal the concept of Configuration specific web.config files was introduced.
These web.config files follow a naming convention of web.configuration.config. For example the web.config files for various Visual Studio + Custom configurations will look as below:
Any new Web Application Project (WAP) created in VS10 will by default have Web.Debug.config and Web.Release.config files added to the project. If you add new configurations (e.g. “Staging”) or if you upgrade pre-VS10 projects to VS10 then you will have to issue a command to VS to generate the Configuration specific Transform files as needed.
To add configuration specific transform file (e.g. Web.Staging.Config) you can right click the original web.config file and click the context menu command “Add Config Transforms” as shown below:
On clicking the “Add Config Transform” command VS10 will detect the configurations that do not have a transform associated with them and will automatically create the missing transform files. It will not overwrite an existing transform file. If you do not want a particular configuration transform file then you can feel free to delete it off.
Note: In case of VB Web Application Projects the web.configuration.config transform files will not be visible till you enable the hidden file views as shown below:
The transform files are design time files only and will not be deployed or packaged by VS10. If you are going to xCopy deploy your web application it is advised that you should explicitly leave out these files from deployment just like you do with project (.csproj/.vbproj) or user (.user) files…
Note: These transform files should not be harmful even if deployed as runtime does not use them in any fashion and additionally ASP.NET makes sure that .config files are not browsable in any way.
Step 3: Writing simple transforms to change developer box connection string settings into “Staging” environment settings
Web.Config Transformation Engine is a simple XML Transformation Engine which takes a source file (your project’s original web.config file) and a transform file (e.g. web.staging.config) and produces an output file (web.config ready for staging environment).
The Transform file (e.g. web.staging.config ) needs to have XML Document Transform namespace registered at the root node as shown below:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
</configuration>
Note: The transform web.config file needs to be a well formed XML.
Inside the XML-Document-Transform namespace two new attributes are defined. These attributes are important to understand as they drive the XML Transformation Engine.
Transform – This attribute inside the Web.Staging.config informs the Transformation engine the way to modify web.config file for specific configuration (i.e. staging). Some examples of what Transforms can do are:
- Replacing a node
- Inserting a node
- Delete a node
- Removing Attributes
- Setting Attributes
Locator – This attribute inside the web.staging.config helps the Transformation engine to exactly pin-point the web.config node that the transform from web.staging.config should be applied to. Some examples of what Locators can do are:
- Match on value of a node’s attribute
- Exact XPath of where to find a node
- A condition match to find a node
Based on the above basic understanding let us try to transform connection string from original web.config file to match Staging environment’s connection string
Let us examine the original web.config file and identify the items to replace... Let’s assume that the original Web Config file’s connection string section looks as below:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<connectionStrings>
<add name="personalDB"
connectionString="Server=DevBox; Database=personal; User Id=admin; password=P@ssw0rd" providerName="System.Data.SqlClient" />
<add name="professionalDB"
connectionString="Server=DevBox; Database=professional; User Id=admin; password=P@ssw0rd" providerName="System.Data.SqlClient" />
</connectionStrings>
....
....
</configuration>
NOTE: It is not advisable to keep connection string unencrypted in the web.config file, my example is just for demonstration purposes.
Let us assume that we would like to make following changes to web.config file when moving to staging environment
- For “personalDB” we would like to change the connectionString to reflect Server=StagingBox, UserId=admin, passoword=StagingPersonalPassword”
- For “professionalDB” we would like to change the connectionString to reflect Server=StagingBox, UserId=professional, passoword=StagingProfessionalPassword”
To make the above change happen we will have to open web.Staging.Config file and write the below piece of code
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="personalDB"
connectionString="Server=StagingBox; Database=personal; User Id=admin; password=StagingPersonalPassword"
providerName="System.Data.SqlClient" xdt:Transform="Replace" xdt:Locator="Match(name)" />
<add name="professionalDB"
connectionString="Server=StagingBox; Database=professional; User Id=professional; password=StagingProfessionalPassword"
providerName="System.Data.SqlClient" xdt:Transform="Replace" xdt:Locator="Match(name)"/>
</connectionStrings>
</configuration>
The above syntax in web.staging.config has Transform and Locator attributes from the xdt namespace. If we analyze the connection string node syntax we can notice that the Transform used here is “Replace” which is instructing the Transformation Engine to Replace the entire node
Further if we notice the Locator used here is “Match” which is informing Transformation engine that among all the “configuration/connectionStrings/add” nodes that are found, pick up the node whose name attribute matches with the name attribute of <add> node in web.Staging.config.
Also if you notice web.Staging.config does not contain anything else but the connectionStrings section (i.e. it does not have <system.web> and various other sections that web.config file usually has, this is because of the fact that the Transformation Engine does not require a complete web.config file in web.staging.config. It does the merging for you thus saving you duplication of all the rest of the sections in web.config file.
Simplest Approach: If you do not mind replicating the entire web.config file in web.staging.config then you can certainly do so by copying the entire web.config content into web.staging.config and change the relevant nodes inside web.staging.config. In such a situation you will just have to put xdt:Transform="Replace" attribute on the topmost node (i.e. configuration) of web.staging.config. You will not need xdt:Locator attribute at all as you are replacing your entire web.config file with web.staging.config without Matching anything.
So far we have seen one Transform (i.e. Replace) and one Locator (i.e. Match), we will see various other Transforms and Locators further in the post but first let us understand how we can produce the Transformed web.config file for the Staging environment after using original web.config and web.staging.config.
Step 4: Generating a new transformed web.config file for “Staging” environment from command line
Open Visual Studio Command prompt by going to Start --> Program Files –> Visual Studio v10.0 –> Visual Studio tools –> Visual Studio 10.0 Command Prompt
Type “MSBuild “Path to Application project file (.csproj/.vbproj) ” /t:TransformWebConfig /p:Configuration=Staging" and hit enter as shown below:
Once the transformation is successful the web.config for the “Staging” configuration will be stored under obj -->Staging folder under your project root (In solution explorer you can access this folder by first un-hiding the hidden files) :
- In the solution explorer click the button to show hidden files
- Open the Obj folder
- Navigate to your Active configuration (in our current case it is “Staging”)
- You can find the transformed web.config there
You can now verify that the new staging web.config file generated has the changed connection string section.
Step 5: Generating a new transformed web.config file for “Staging” environment from VS UI
Right Click on your project and click Package –> Create Package
The Create Package step already does web.config transformation as one of its intermediate steps before creating a package and hence you should be able to find the transformed web.config file in the same place as described in Step 4
Step 6: Understanding various available web.config Transforms and Locators
xdt:Locators
The inbuilt xdt:Locators are discussed below.
- Match - In the provided syntax sample below the Replace transform will occur only when the name Northwind matches in the list of connection strings in the source web.config.Do note that Match Locator can take multiple attributeNames as parameters e.g. Match(name, providerName) ]
<connectionStrings>
<add name="Northwind" connectionString="connectionString goes here" providerName="System.Data.SqlClient" xdt:Transform="Replace" xdt:Locator="Match(name)" />
</connectionStrings>
· Condition - Condition Locator will create an XPath predicate which will be appended to current element’s XPath. The resultant XPath generated in the below example is “/configuration/connectionStrings/add[@name='Northwind or @providerName=’ System.Data.SqlClient’ ]”
This XPath is then used to search for the correct node in the source web.config file
<connectionStrings>
<add name="Northwind" connectionString="connectionString goes here" providerName="System.Data.SqlClient" xdt:Transform="Replace" xdt:Locator="Condition(@name=’Northwind or @providerName=’System.Data.SqlClient’)" />
</connectionStrings>
· XPath- This Locator will support complicated XPath expressions to identify the source web.config nodes. In the syntax example we can see that the XPath provided will allow user to replace system.web section no matter where it is located inside the web.config (i.e. all the system.web sections under any location tag will be removed.)
<location path="c:\MySite\Admin" >
<system.web xdt:Transform="RemoveAll" xdt:Locator="XPath(//system.web)">
...
</system.web>
</location>
xdt:Transform
- Replace - Completely replaces the first matching element along with all of its children from the destination web.config (e.g. staging environment’s web.config file). Do note that transforms do not modify your source web.config file.
<assemblies xdt:Transform="Replace">
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
· Remove - Removes the first matching element along with all of its children
<assemblies xdt:Transform="Remove"></assemblies>
· RemoveAll - Removes all the matching elements from the destination’s web.config (e.g. staging environment’s web.config file).
<connectionStrings>
<add xdt:Transform="RemoveAll"/>
</connectionStrings>
· Insert - Inserts the element defined in web.staging.config at the bottom of the list of all the siblings in the destination web.config (e.g. staging environment’s web.config file).
<authorization>
<deny users="*" xdt:Transform="Insert"/>
</authorization>
· SetAttributes - Takes the value of the specified attributes from the web.staging.config and sets the attributes of the matching element in the destination web.config. This Transform takes a comma separated list of attributes which need to be set. If no attributes are given to SetAttributes transform then it assumes that you would like to Set all the attributes present on the corresponding node in web.staging.config
<compilation batch="false"xdt:Transform="SetAttributes(batch)">
…
</compilation>
· RemoveAttributes - Removes the specified attributes from the destination web.config (i.e. staging environment’s web.config file). The syntax example shows how multiple attributes can be removed.
<compilation xdt:Transform="RemoveAttributes(debug,batch)">
</compilation>
- InsertAfter (XPath) - Inserts the element defined in the web.staging.config exactly after the element defined by the specified XPath passed to “InsertAfter()” transform. In the syntax example the element <deny users="Vishal" />will be exactly inserted after the element <allow roles="Admins" /> in the destinationXML.
<authorization>
<deny users="Vishal" xdt:Transform="InsertAfter(/configuration/system.web/authorization/allow[@roles='Admins'])” />
</authorization>
- InsertBefore (XPath) - Inserts the element defined in the web.staging.config exactly before the element defined by the specified XPath passed to “InsertBefore()” transform. In the syntax example the element <allow roles="Admins" />will be exactly inserted before the element <deny users="*" />in the destinationXML.
<authorization>
<allow roles=" Admins" xdt:Transform="InsertBefore(/configuration/system.web/authorization/ deny[@users='*'])" />
</authorization>
Some advanced points to note:
- If the Transformation Engine does not find a xdt:Transform attribute specified on a node in web.staging.config file then that node is ignored for Transformation and the Tranformation engine moves ahead traversing the rest of the web.staging.config.
- A xdt:Transform attribute on a parent can very easily impact child elements even if there is no Transform specified for child e.g. If xdt:Transform=”Replace” is put on <system.web> then everything underneath <system.web> node will be replaced with the content from web.staging.config
- It is completely valid to place xdt:Locators attributes on arbitrary nodes inside web.staging.config just for filtering purposes. xdt:Locator does not need to be accompanied with xdt:Transform attribute. (great example here is <location> tag which might just be used for filtering… The example code here would be:
<location path="c:\MySite\Admin" xdt:Locator="Match(path)">>
<system.web>
... Bunch of transforms written under here will
.... only apply if location path = C:\MySite\Admin
</system.web>
</location>
Step 7: Using Web.config transformation toolset for config files in sub-folders within the project
All of the above discussion directly applies to any web.config file present in sub folders of your project (e.g. if you have a separate web.config file for say “Admin” folder then VS 10 will support transforms for them too). You can add transform files within sub-folders and use the same packaging functionality mentioned in all of the above steps to create transformed web.config files for web.config files specific to the sub folders within your project.
I think this has become a rather long post; but I hope it helps!!
Vishal R. Joshi | Program Manager | Visual Studio Web Developer
ASP.Net MVC 1.0 RTM has been out for a while and I noticed that people are still downloading an NUnit sample project I created for ASP.Net MVC Preview 3. Since then an AccountController class and a corresponding set of unit tests have been added to the MVC Application project. I created an updated set of NUnit templates with tests for the Home and Account controllers. To install the templates, just extract the zip file from the link below and run installNUnit.cmd. VWD Express is supported along with VSTS as well as support for x86 and x64 bit OS's. If you are installing on Vista or higher, run the cmd file as an admin.
NUnit Test Templates
Below is a screenshot of the NUnit AccountControllerTest class for Visual Basic. If you build a new MVC project with NUnit selected as the test framework and run the test project dll in NUnit, you will see all the tests pass.

Hope this helps you unit test your MVC Apps!
Joe Cartano | Visual Web Developer