ScottGu's Blog
Scott Guthrie lives in Seattle and builds a few products for Microsoft
-
VS 2008 Multi-Targeting Support
Earlier this month at TechEd we announced the official name of Visual Studio "Orcas" - which will be called Visual Studio 2008. We also said that the official name for the .NET Framework "Orcas" release will be called .NET Framework 3.5 (it includes the new LINQ support, integrated ASP.NET AJAX support, new ASP.NET data controls, and more).
-
Building Silverlight Applications using .NET
I'm just about to hop on the flight back to Seattle after finishing up a 10 day business trip to Europe where I spoke at conferences and user group events in Budapest, Amsterdam and Zurich. Although trips like these are a little exhausting, I find them really valuable as a way to connect with developers from around the world, as well as provide me the opportunity to create and deliver new presentations and samples.
-
Tip/Trick: Creating Packaged ASP.NET Setup Programs with VS 2005
You have built an ASP.NET Web Application using Visual Studio 2005, and want to enable customers to automatically install and deploy it on servers via an easy setup program.
Specifically, you want to create a standard Windows setup program that will create and configure the application on IIS, copy all of the application’s files to the appropriate location on the server, and ensure that ASP.NET 2.0 is correctly mapped to run the application. You also want the setup program to prompt the customer for the database location that the new application should use, and have the setup program automatically update the web.config file with the database connectionstring settings the customer provided.
One solution to consider using is the built-in "Web Setup Project" support that is built-in to Visual Studio 2005. Web Setup Projects can be used to pipe the compilation outputs from VS 2005 Web Application Projects as well as Web Site Projects (when used with VS 2005 Web Deployment Projects), to create encapsulated Windows setup programs. The below walkthrough demonstrates step-by-step how to create and use one.
1) Create a VS 2005 Web Application Project
To begin with, we’ll start with an empty instance of Visual Studio and create a new VS 2005 Web Application project (select File->New Project->ASP.NET Web Application). For the purposes of this simple sample we’ll have two pages in the project:
We’ll add a label to the Default.aspx page and a Page_Load event handler in the code-behind to output the current timestamp on each request. When I press F5 to build and run the application, the project will compile and run as I’d expect (and by default use the built-in VS Web Server):
2) Add a VS 2005 Web Setup Project to the Solution
Now that we have a simple ASP.NET application built, we’ll want to add a VS 2005 Web Setup Project to the solution. Choose the File->Add->New Project menu item to add one into your solution:
Note that the “Web Setup Project” type shows up under the “Other Project Types->Setup and Deployment” node in the New Project dialog above. Name it whatever you want and hit ok. It will then show up in your solution explorer as a separate project.
Our next step will be to configure the web setup project to take the compiled assemblies (\bin directory contents) + content markup (.aspx, .config, etc files) from our Web Application Project and use them as inputs within our setup project. To-do this, right-click on the web setup project node in the solution explorer and choose the “Add->Project Output” context menu item:
A dialog will then appear allowing us to select which project in the solution, and which of its project contents, we want to add to the setup package:
For ASP.NET Web Application Projects it is really important that we select both the “Primary Output” (which are the compiled assemblies for the \bin directory) as well as the “Content Files” (which are the .aspx markup files) within this dialog.
By default, the web setup project will copy both of these items into the root of the target Web Application Folder that the setup project will create. You can see that it is configured this way by opening up the “File System” view within the web setup project (right click on the web setup project root and choose View->File System):
This actually isn’t what we want to have happen though – since we really want the assemblies (indicated by the Primary Output node) to be copied into the application’s \bin directory instead (otherwise ASP.NET won’t be able to find them at runtime). To fix this, drag/drop the “Primary Output from MyApplication” node into the \bin directory. Once this is done you should be able to click on the “Web Application Folder” node on the left-hand side and see this:
And then click on the “bin” folder sub-node and see this:
We now have a basic web setup project created and configured for our ASP.NET Web Application. Next step is to build and run it.
3) Build and Run the VS 2005 Web Setup Project to the Solution
To build the web-setup project we can right-click on the web setup project node within the solution explorer and choose the “Build” option:
If you open the output window within VS (View->Output menu item), you will see the results of this build operation:
Our “MyApplicationSetup” project created a new MyApplicationSetup.msi Windows installer file and compressed and packaged the contents of our ASP.NET Web Application (note: in the web setup project properties dialog you can choose whether the compression algorithm used is optimized for size or speed).
Very Important: Because setup projects take awhile to build, they are by default marked not to build as part of the solution. What this means is that you need to right-click on them and explicitly do a build in order for them to be recompiled. Be careful to-do this when you make and test changes - otherwise you'll be running the previously compiled version and not the one with your latest code!
-
Details on My Speaking Events in Zurich, Mountain View, and Phoenix
I'm now half-way through my speaking tour for the month. In my last post on this I didn't have all of the time/location details on the final events. Here are some updated details below:
-
New ASP.NET AJAX Control Toolkit Release
Yesterday the ASP.NET AJAX Control Toolkit team released an updated version. You can download it from the http://ajax.asp.net web-site, and run samples built with it on the online samples page here.
-
My "Lap Around Silverlight" Talk at TechEd
On Monday I gave an overview talk called "A Lap Around Silverlight" at TechEd in Orlando. You can download the slides of my talk here (warning: due to images the download is 12Mb). You can also learn more about Silverlight from my Silverlight blog post here.
-
May 31st Links: ASP.NET, ASP.NET AJAX, Visual Studio and .NET
Below is this week's list of useful .NET links for my weekly link-listing series.
-
Microsoft Surface and WPF
Microsoft earlier today announced a new product called "Microsoft Surface". If you haven't checked out the online videos of it yet, I highly recommend watching them here. It is one of those products that looks and feels like it comes from a science fiction movie - but it is actually real.
-
LINQ to SQL (Part 2 - Defining our Data Model Classes)
In Part 1 of my LINQ to SQL blog post series I discussed "What is LINQ to SQL" and provided a basic overview of some of the data scenarios it enables.
-
My Upcoming Presentations in Orlando, Budapest, Amsterdam, Zurich, Mountain View and Phoenix
June is going to be a really busy travel month for me. I'll be presenting at the following events if you are interested in attending and stopping by to say hi: