Archive

Archive for the ‘Visual Studio’ Category

Microsoft Development Platform Training Resources

July 14, 2010 Leave a comment

This is a link post with links to tutorials, samples and training courses covering the recent releases of Microsoft’s development platform tools and technologies.


Visual Studio 2010 and .NET Framework 4 Training Kit (June 2010)

Covers:

  • C# 4
  • Visual Basic 10
  • F#
  • Parallel Extensions
  • Windows Communication Foundation
  • Windows Workflow
  • Windows Presentation Foundation
  • ASP.NET 4
  • Windows 7
  • Entity Framework
  • ADO.NET Data Services
  • Managed Extensibility Framework
  • Visual Studio Team System

Download Page


Identity Developer Training Kit (June 2010)

Covers:

  • Windows Identity Foundation

Download Page


Windows Azure Training Kit (June 2010)

Covers:

  • Windows Azure
  • SQL Azure
  • Windows Azure AppFabric Service Bus
  • Windows Azure AppFabric Access Control Service
  • Dallas
  • Access and Identity in the Cloud
  • Windows Azure Storage
  • Windows Azure Deployment

Download Page


Windows Server AppFabric Samples (June 2010)

Covers:

  • Windows Server AppFabric Cache
  • Windows Server AppFabric Hosting

Download Page


Silverlight 4 Training (April 2010)

Covers:

  • Silverlight 4
  • WCF RIA Services

Download Page


Visual Studio 2010 RTM Virtual Machine Now Available

June 28, 2010 Leave a comment

The RTM version of Visual Studio 2010 and Team Foundation Server 2010 is now available for download as a virtual machine. The VM image also include a sample application and sample data to support the accompanying hands on labs. This image does not include the Visual Studio Lab Management 2010 but the team are working on it.

VS2010Logo
The virtual machine image comes in multiple flavours to support these virtualization technologies: Hyper-V, Windows Virtual PC (for Windows 7) and Virtual PC 2007 SP1. All of these images will expire on 15 Dec 2010.

Refer to Brian Keller’s post for additional details.

Providing a Reason for Stopping Project Collections in TFS 2010

June 15, 2010 Leave a comment

When you stop a project collection in TFS 2010, it asks you to enter a reason why you are stopping that collection:

image

This text will be displayed to the users when they try to use an artifact in any of the projects in that project collection:

image

Note that this only affects those artifacts that are managed by TFS (work items, builds and source control items). Users can continue accessing the reports (handled by SSRS and SSAS) and documents (handled by SharePoint).

This is a minor feature but can be very useful when you need to service the project collection. It is still a good idea to make the users aware of the servicing plans in advance though!

Categories: TFS, Visual Studio 2010

Windows Server AppFabric is RTW

June 7, 2010 Leave a comment

Windows Server AppFabric simplifies the process of creating, scaling and managing web and composite applications that run on IIS and includes the following components:

  • AppFabric Caching Services (code-named “Velocity”)
    • Caching services
    • Cache client
    • Cache administration
  • AppFabric Hosting Services (code-named “Dublin”)
    • Hosting services
    • Hosting administration

You can get the RTW bits using the Web Platform Installer or downloading it directly from here.

The supported operating systems are both 32-bit and 64-bit editions of:

  • Windows 7
  • Windows Server 2008 R2
  • Windows Vista SP2
  • Windows Server 2008 SP2

You will also need a version of .NET Framework, depending on the features you want to use (more info):

  • Hosting administration: .NET 4
  • Hosting services: .NET 4
  • Cache administration: .NET 4
  • Caching service: .NET 4 and optionally .NET 3.5 (.NET 3.5 adds new capabilities)
  • Cache client: .NET 4 and .NET 3.5 (depending on client application)

There are a number of additional resources linked from the landing page, including the Windows Server AppFabric wiki.

Deployment and Testing Automation

June 6, 2010 Leave a comment

In Application Lifecycle Management (ALM) consulting engagements with customers, we usually cover the automation of various activities in the development process. Most of the development teams I work with have some sort of automated build system in place. The automated build usually goes as far as compiling the solution(s) and then running some unit tests to verify the build. Build automation adds a lot of value but the true value of the development process automation can only be realised when we take that final step and automate the deployment and testing process too. This is because the automated build (without deployment) cannot tell if all of the system components are going to work together to meet the requirements. It is also very hard (if not impossible) to run any integration tests in such environment because there is no deployment so the tests we can run will be limited to those that are related to individual units or those that rely on mocking frameworks.

When I ask development teams why they don’t take that final step, this is what I usually hear back:

  • Our environment and deployment process is very complex so we can’t automate it.
  • We have a shared database server we use for development and it is constantly changing so we don’t have a reliable baseline to test against.
  • We don’t store our configuration files in the source control because it contains sensitive information.
  • We have different environments we use for development and testing and every one of those has its own settings so which one should we keep in the source control?
  • We need some data to be available in the database for testing and since the database is changing, the base data set is changing too.
  • If we want to include the deployment and testing in the process, it is going to take n (n>5) hours.

There are various solutions to any of these issues and to be honest, none of these are a good excuse for not automating the deployment and testing. Points similar to the ones listed above highlight fundamental problems somewhere else in the development process so even if we don’t want to automate the deployment and testing, we are still going to be affected by those inefficiencies and problems.

For example, if our argument is that the database schema is constantly being changed (by a different team and probably on a different release cycle), this means when we decide to have a release, we have no idea if the latest version of the code is in sync with the database schema and scripts at that point. We may be lucky and manage to release in few hours but next time we may end up spending a day or two sorting out inconsistencies. The typical solution to this is to make sure the database artifacts are always in sync with the source code and are stored together with the code in the source control. Historically, maintaining the database scripts (especially the DDL change scripts) in source control has been a huge problem but today, we have great support from development tools in the market for managing the database artifacts (and their changes). Many of the teams I talk to are simply unaware of the developments we have made in these areas.

The point about having a dependency on the base test data is interesting too. If we don’t have a reliable set of test data for the code we are working with, we will end up copying a database from a previous release and then start making changes to that database to bring it in line with the latest version of the database schema. And guess what? Every developer needs to go through this error-prone process. As the testing team and other developers start testing, they will discover new sets of data that allows them to test new scenarios but since all of the developers have spent a considerable time on creating their “precious” test data, they will hang on to what they have. I am sure this is one of those experiences we have all had and we can spend a lot of time on maintaining our test data instead of implementing features for our product. The easiest solution to this challenge is to maintain a set of base test data and store it together with the source code in the source control. Yes somebody needs to maintain this but we are in a better position as less people need to be worried with maintenance of that data and other developers will get the latest test data when they get latest from the source control. This base test data can also be used by the automated processes for testing purposes.

Implementing an automated deployment and testing process is not trivial but is certainly achievable and there are things you can do to make it simpler. If you ask me to come up with #1 guideline in this area, I will say put all of the artifacts required for deployment in the source control but even more importantly, make sure they are in the right location! Nobody questions why we need to put the source code under source control but people usually miss other artifacts such as database artifacts and build and deployment scripts. The interesting point is that many teams actually put these artifacts somewhere under source control but they put it in the wrong location, which makes them less effective and those artifacts will be unusable when we want to automate deployment and testing. So what is the right location for the artifacts?

The basic idea is that all of the artifacts required for deployment should follow our branching hierarchy.

image

For example, if we have three branches (DEV, MAIN and REL), each branch needs its own copy of the artifacts. Why? Because we want to be able to deploy and test any of those branches independently. As you can see this is a fairly obvious (and simple) solution but many teams don’t do this for various reasons and that makes the automated deployment and testing very hard (or impossible).

image

As I said earlier, even if we are not going to automate deployment and testing, we will still benefit from following this structure and making sure all of the artifacts under each branch are consistent and in sync with one another. Once this structure is in place, the next step is to make sure we have the capability of creating and managing the target environments as we will be deploying and testing over and over again. [I am writing the next few sentences with my “good corporate citizen” hat on…] This is where tools such as Visual Studio Lab Management can help. Many developers and testers I talk to still haven’t heard of this great product or don’t know what it does so if you fall in that category, you may want to have a look at the resources (product team blog, videos) to find out more about it. Please note that at the time of writing this post, Visual Studio Lab Management is still in pre-release status so make sure you read the pre-release license terms (rtf) before installing it.

You will be amazed when you see how easy it is to automate the process of managing the target environments (which usually consists of one or more virtual machines) as part of the build process in TFS 2010.

image

The above diagram shows the list of activities provided out of the box and you can use the workflow editor for the build to customise the end-to-end process.

Categories: ALM, TFS, Visual Studio

Unshelving a Shelveset to a Different Branch in TFS

July 7, 2009 Leave a comment

[Note: In this post, I am assuming that you are familiar with the TFS Branching Guidance. If you haven't read the guide, I strongly recommend that you do so! I will be referring to the branch names suggested for the basic branch plan.]

Scenario:
After an application is released to the production environment, a defect has been raised by the users. The production support team decides to fix this defect before the next version is released so they start by modifying the appropriate files in the REL branch to fix the defect. When the developer working on the defect finishes his job, he shelves those changes and asks the support team lead to review those changes before they are checked in. The support team lead analyses the changes and because of the risks involved, she talks to the users and they agree to wait until the release of the next version to get the fix. 

Challenge:
When you create a shelveset, the server path of each shelved file is stored with the shelveset so when you try to unshelve that shelveset, the files in the same branch are modified. You cannot unshelve the shelveset to a different branch such as DEV so you will need to do this manually by unshelving to the original branch and then manually copying the modified files across, which is time consuming and error prone. 

Solution:
TFS 2008 Power Tools includes a command line tool (TFPT.exe), which allows you to perform advanced operations in TFS. One of these operations is the unshelve command, which allows you to change the server path of the files in a shelveset during the unshelve operation. This means you can use this command to unshelve any shelveset to a different branch. In our scenario, the shelveset was originally created in the REL branch so the development team can use the TFPT tool to unshelve the shelveset to the DEV branch. 
So let’s assume that the support team have changed the source files in the REL branch and we want to unshelve this shelveset to the DEV branch. In order to do this, we need to: 
- Make sure the TFPT command line tool is installed!
- Go to the command prompt and change the folder to a location that is mapped in the desired workspace.
- Run the following command:

    TFPT.exe unshelve ReleaseHotFix1 /migrate /source:$/MyProject/REL /target:$/MyProject/DEV
          

Where ReleaseHotFix1 is the original shelveset name and $/MyProject/REL and $/MyProject/DEV are the server paths to the REL and DEV branches respectively. 

When you run the unshelve command with the migrate option, the tool will prompt you to choose which version of the file (in origin or target) you want to keep. It will also allow you to perform a file merge if needed, which will be done in the merge tool.

The following diagram shows the sequence of events that need to happen across multiple branches in our scenario: 

  
Events: 

  • S1: Production support team shelve their changes in the REL branch.
  • U1: Development team unshelve the shelveset to the DEV branch by running the TFPT tool and using the shelveset migrate option.
  • C1: After resolving any potential conflicts in the DEV branch, the modified files are checked in.
  • RI1: At some point, the checked-in changeset will be reverse integrated (merged) back into the MAIN branch.

VSTS 2010 Beta 1 Available for Download

May 18, 2009 1 comment

As planned, VSTS 2010 Team Suite Beta 1, .NET Framework 4 Beta 1, TFS 2010 Beta 1 and VSTS 2010 Test Load Agent and Controller Beta 1 are now available for download from MSDN Subscribers area.


We now have 32-bit and 64-bit support for TFS and the TFS client OM. All of the client tools such as Visual Studio will continue to run in 32-bit environment though. For more information on the supported environments for TFS and the improvements in setup, administration and operations refer to Brian Harry’s post.

VSTS Web Test Recorder Bar Missing in Windows Vista/7 64-bit

February 19, 2009 Leave a comment

Primarily for my own reference in the future but you may find this useful too. If you are running Windows Vista/7 64-bit and want to use the VSTS 2008 Web Test Recorder plug-in, the web test recorder bar may be unavailable due to the way Windows caches the list of available explorer bars. In order to resolve this, you can apply some tweaks to the registry. Michael Taute has a useful post which explains the problem and solution in more detail and covers some other issues too.

Project and File References Revisited

February 10, 2009 6 comments

Most .NET developers and architects are familiar with various approaches to Visual Studio solution design: 

  • Single Solution
  • Partitioned Solution
  • Multiple Solutions 
  • Multiple Partitioned Solutions 

    Just in case the last item in the list is unfamiliar, yes, I just made it up. You might be using it already actually but it is a good idea to give it a name.

  • Most of the development projects contain more than one Visual Studio project. As soon as a second project is added to the solution, as a developer/architect, you start thinking about how the dependencies should look like. 

    Meet “Camp P”
    Members of camp P believe file references are evil as they cause all sorts of versioning and build issues when the dependencies go out-of-date. The members of this camp try to put everything in the same solution and life is great as long as you can count the number of projects with your fingers. There has been a debate out there as to whether Visual Studio should become quicker when it comes to handling large solutions. This issue was partly addressed by release of Visual Studio 2005 SP1 where we introduced some performance improvements in the IDE. These improvements are also rolled forward to Visual Studio 2008. However, you need to take into account all the work the IDE and the compiler need to do while you are typing in the IDE to provide you with Intellisense and compiler warnings/errors. So at some point, you will hit a practical limit on the number of projects you can have open in Visual Studio.

    Meet “Camp F”
    This is where the members of “Camp F” are coming from. They want to avoid the project references in order to speed up the IDE but they usually end up spending the time they saved on resolving the versioning issues. 

    Now Meet Both!
    None of these solutions are perfect but as long as the development team is consistent in following one of these approaches, then the team can live with it. This becomes a major problem when you have members from both camps in the same development team. This has been the case in most of the development teams I have worked with and I bet most of you have had similar experiences. So what is a typical day on such project? Somebody from “Camp F” is not happy with performance of the IDE while he is working on the “Order Processing” feature of the application. As a result, he decides to replace all of the references to the “UI Framework” projects with file references. But guess that? The dependency type is defined in the project file, so this change results in modification of the project file and the changes are checked back into the source control at some point. Few hours later, somebody from “Camp P” who is working on one of those “UI Framework” projects is trying to perform an integration test to validate a change she made to the UI Framework and finds out that the dependencies are out of date. She checks the source control as it was working fine until that morning and notices the change. She then reverts all of those changes as file references will make her job harder. And the team will soon end up in changing the references types back and forth between project and file references and and this changes cause further problems in the build process. Add to this all of the discussions/arguments as to which approach is better and you will see how much time is wasted as developers and build engineers keep changing the dependencies to suit their needs. 

    What is the solution then? I am going to start with re-iterating what you probably know already but bear with me – I’ll try to keep it short! 

    The Team Development with Visual Studio Team Foundation Server guide does a pretty good job at providing high level guidelines for choosing the right approach. It provides three options for managing the solutions: Single Solution, Partitioned Solution and Multiple Solutions. I am going to skip over the Single Solution. If you can manage everything in the same solution, then you are not worried much about the solution design, right? 

    Partitioned Solution
    If you work on a large system, consider using multiple solutions, each representing a sub-system in your application. These solutions can be used by developers in order to work on smaller parts of the system without having to load all code across all projects. Design your solution structure so any projects that have dependencies are grouped together. This enables you to use project references rather than file references. Also consider creating a master solution file that contains all of the projects. You can use this to build your entire application.
     

    Multiple Solutions
    If you work on a very large solution requiring many dozens of projects, you may encounter solution scalability limits. In this scenario, break your application into multiple solutions but do not create a master solution for the entire application because all references inside each solution are project references. References to projects outside of each solution (for example to third-party libraries or projects in another sub-solution) are file references. This means that there can be no “master” solution.

    Instead, you must use a script that understands the order in which the solutions need to be built. One of the maintenance tasks associated with a multiple-solution structure is ensuring that developers do not inadvertently create circular references between solutions. This structure requires complex build scripts and explicit mapping of dependency relationships. In this structure it is not possible to build the application in its entirety within Visual Studio. Instead, you can use TFS Team Build or MSBuild directly. 

     

    The Partitioned Solution approach doesn’t scale well for very large solutions since it will make the IDE very slow and this sends you down the Multiple Solutions approach. So you group related projects and create a solution for each group. You use project references for dependencies inside the solution and file references for those dependencies that cross the solution boundaries. This is where the problems start: 

    1- You cannot create a master solution that contains all of the projects. This is because you have created file references for cross-solution dependencies, which will cause problems when you try to build the master solution. 

    2- Depending on which area of the system you are working on, you may want to have a different slice of the system in your solution. For example, if you are a member of a team working on a specific feature such as Order Processing, you want to have a vertical slice that goes across application layers (presentation, business and data). But if you are working on the UI Framework for the application, you want to have a horizontal slice that includes the presentation layer from all functional areas as well as the UI Framework. 

     

    So even if all of the team members agree on the concept of Multiple Solutions, there are decision to be made on how the projects are going to be grouped into multiple solutions and as you can see in the above diagram, these categorisations don’t necessarily play well with each other. 

    You always need to consider various factors such as the solution size and simplicity of the build process and choose one of these approaches (none of which are perfect): 

    • Single Solution
    • Partitioned Solution
    • Multiple Solutions 

    Multiple Partitioned Solutions 
    Some of you may know about this already but there is another approach too. One can argue that it is the same as Partitioned Solution but in order to avoid confusion(!), I usually call it “Multiple Partitioned Solutions” or “MPS” (as you know we love TLAs). So what is it and how does it work? 

    MSBuild is a great build engine. One of its features is the ability to follow and find the project references in a project even if those referenced projects are not inside the solution you are trying to build. This means you no longer need to have all of the project references inside the solution. Believe it or not, but you can successfully build the solution and the projects inside it even if the referenced projects are not in the solution. This will work both from the IDE and the command line as they both rely on the underlying MSBuild functionality. The only condition here is that the referenced projects need to have been built already. MSBuild is able to follow and find those referenced projects but it won’t build them for you. Is this a major problem? Probably not because when you get the latest version from the source control, you usually do a full build and then start working on your specific area. 

     

    Let’s see how the system will be structured then. The dependencies between the projects are created as project references wherever possible. Depending on your requirements, you can create a solution that contains only a subset of projects you need to work on. Because the dependencies are project references, you can now have cross-cutting solutions that go across functional areas and architectural layers. You can also have a master solution because the dependencies are project references. Clearly, you don’t want to open the master solution in the IDE often as it will take a long time to load, it will be slow and you don’t usually work on all projects at the same time. The master solution will primarily be used for build purposes. 

    Note 1: I haven’t tried this but as far as I know, you won’t be able to build a solution on the build server if a project reference is missing. So on your build server, make sure you always build the master solution and not the partitioned solutions. You always want to build everything on the build server anyway. 
    Note 2: I am not saying that you should never use file references. There are cases where you don’t want the dependencies to be built in the same build step so you can use file references if needed. The advantage of the Multiple Partitioned Solutions is that it gives you maximum flexibility. 

    Why do I call it “Multiple Partitioned Solutions”? Because the master solution is partitioned multiple times based on various perspectives. For example, the master solution can be partitioned into three solutions, one for each logical layer (such as presentation, business and data). At the same time, it can also be partitioned into another three solutions, one for each functional area (such as Order Processing, User Management and Call Centre). 

    Like the other approaches, The MPS approach is not perfect and it has its own challenges. I personally prefer this approach though. It addresses the concerns around solution size and versioning and is very flexible as you can have cross-cutting solutions. But from a tooling perspective, we can provide you with better support so this is an area for improvement. As an example, if you try to remove a project from a solution in Visual Studio, it removes all of the dependencies on that project too. If you are following the MPS approach, this is not necessarily what we want. This is not as bad as it looks as in most projects I have seen, the solutions are created and maintained by dev leads, architects and/or build engineers so as long as they know what they are doing, it will be fine but it would be nice to have a proper solution here. 

    I have found a workaround for this, which is to unload the projects that depend on the project we are trying to remove before removing the project. This will prevent the dependencies from being dropped automatically. Another approach is to manually edit the solution file and remove the project(s). 

    As I said, these are workarounds not solutions. When we remove a project, we ideally want to be able to specify whether we want the project to be removed from the dependencies or we are just trying to exclude that project from the solution. So maybe we could add an “Exclude” option to the project context menu in the Solution Explorer?  

    So… have you used the MPS approach in your development projects? If yes, can you share your experiences? What are the challenges you have faced and how have you addressed them? What kind of support do you expect from the IDE in this area?

    Windows Installer Custom Actions, Windows Vista and Terminal Server

    December 23, 2008 2 comments

    Using a setup project in Visual Studio is a nice and easy way of creating a deployment solution for your application. In some cases, built-in features such as file copy, GAC registration and registry modification are good enough but there are cases where you need to perform a custom action such as configuring CAS or running a script.

    If you have used Visual Studio 2005 to build the setup package (with custom actions) and have tried to run your setup package on Windows Vista with UAC enabled, then you may already know that the setup can fail. This is because Windows Vista is enforcing an architectural intent according to Robert Flaming’s blog post. So in order to make sure your custom action runs on Windows Vista without a problem, you need to edit the MSI package and change the custom action type flag to include msidbCustomActionTypeNoImpersonate (see here for the list of options). So for example, if your custom action is defined in a class library, this is how you can calculate the type value for Windows Vista:

    msidbCustomActionTypeDll + msidbCustomActionTypeInScript + msidbCustomActionTypeNoImpersonate = 0×00000001 + 0×00000400 + 0×00000800 = 3073

    (Note that Visual Studio 2008 sets this value correctly to 3073).

    You can then update the type value for this custom action in the Orca tool:

    And instead of performing this step manually, you can use a script that does this for you and then run this script as a post-build event of your setup project. Aaron Stebner has a great blog post on this.

    So now all is good and we have an automated process for setting the right value for the custom action type. Now what happens if you want to run the same setup package on Terminal Server? If you are performing a per-machine install, the custom action runs with no user impersonation by default and you may need to perform some tasks that rely on the user being the administrator. In order to force the custom action to run with user impersonation, you need to include another flag (msidbCustomActionTypeTSAware), which is ignored if msidbCustomActionTypeNoImpersonate is already present. This makes sense as one is forcing impersonation and the other one is preventing it. But now the challenge is, how can we create a setup package that runs on both platforms?

    Windows Vista needs: msidbCustomActionTypeDll + msidbCustomActionTypeInScript + msidbCustomActionTypeNoImpersonate = 0×00000001 + 0×00000400 + 0×00000800 = 3073
    Terminal Server needs: msidbCustomActionTypeDll + msidbCustomActionTypeInScript + msidbCustomActionTypeTSAware = 0×00000001 + 0×00000400 + 0×00004000 = 17409

    This is where the deployment conditions come to the rescue. First, a bit of background on deployment conditions:

    All setup project deployment artifacts such as files, folders, registry entries and custom actions have a Condition property, which will determine whether that item will be installed/run. These properties tell you about the hardware configuration (memory size, CPU type), OS (version, service pack and build number) and other information elements such as user name and computer name. The property reference section on MSDN has a full list of property values you can use. You are not limited to one condition and you can perform logical operations and equality checks too (see Conditional Statement Syntax and Examples of Conditional Statement Syntax).

    So let’s go back to our scenario. We were looking for a solution that allows a single setup project to be used on Windows Vista and Terminal Server. There is a deployment condition called TerminalServer, which is defined only if we are running on Terminal Server. The deployment condition “TerminalServer” will be true in a Terminal Server environment and the “NOT TerminalServer” will be true in all other environments, including Windows Vista. So we can achieve our objective by creating the following two custom actions:

    • One for Terminal Server environments, Condition: TerminalServer, Type: 17409
    • One for other environments, Condition: NOT TerminalServer, Type: 3073

    This doesn’t necessarily mean you need to create two installer classes though. You can add the default output of your class library (which contains the installer class) to the setup project twice and then add two custom actions, each of which uses one of those outputs. You can then use the Orca tool to set the types manually (make sure you set the right type for each action) or use the scripting approach as explained by Aaron Stebner (note that you will need to change the script to satisfy the requirements).

    Other links:
    Operating System property values for deployment conditions

    Categories: Visual Studio
    Follow

    Get every new post delivered to your Inbox.