Thursday, February 28, 2013

Web Deploy Improvements in ASP.NET and Web Tools 2012.2 Update

Last week Scott Guthrie announced the release of the ASP.NET and Web Tools 2012.2 Update. This release not only offers some really nice new features for ASP.NET WebForms, ASP.NET MVC, ASP.NET Web API, SignalR and the web tooling in Visual Studio, but also adds some nice improvements to Web Deploy. (For the full list of new features, have a look at the release notes). 

What’s new?
  • First of all, Web site projects now have the same publishing experience as Web Application projects including publishing to Windows Azure Web Sites. 
  • Selective publish – for one or more files you can perform the following actions (after publishing to a Web Deploy endpoint):
    • Publish selected files.
    • See the difference between a local file and a remote file. (this even works for images!)
    • Update the local file with the remote file or update the remote file with the local file.
  • Apply config transformations on the publish profile next to the build profile.
    • This will combine the transformations you’ve specified at the build profile level with the transformations you’ve specified at the publish profile level.
    • An example:
      • “You have a QA environment and want to apply the same transformation to both a release and debug build. Before you had to configure a build configuration for every combination. In this case it was QA-Release and QA-Debug and copy the same transformation over between the 2 configs. Now you can create a config transform for QA, and keep the Release and Debug build configuration intact.”
  • One that isn’t new, but I want to mention again is the web.config transform preview. This allows you to preview the result of a transformation.It was added when releasing VS 2012 but a lot of people don’t know it exists.

PreviewTransform

For more information, have a look at the videos from Sayed Ibrahim Hashimi.

Wednesday, February 27, 2013

SQL Server 2012 Data Quality Services

One of the hardest parts of a DBA’s job, is keeping the data quality of the databases good over time. You would expect that only correct data is entered into the system, but we are all humans, so mistakes happen…

A powerful tool that  can help your DBA’s detect and prevent data quality issues is Microsoft SQL Server 2012 Data Quality Services (DQS). DQS is a knowledge-driven solution that provides both computer-assisted and interactive ways to manage the integrity and quality of your data sources. DQS enables you to discover, build, and manage knowledge about your data. You can then use that knowledge to perform data cleansing, matching, and profiling. You can also leverage the cloud-based services of reference data providers in a DQS data-quality project.

DataQualityProject

From MSDN:

DQS provides the following features to resolve data quality issues.

  • Data Cleansing: the modification, removal, or enrichment of data that is incorrect or incomplete, using both computer-assisted and interactive processes. For more information, see Data Cleansing.

  • Matching: the identification of semantic duplicates in a rules-based process that enables you to determine what constitutes a match and perform de-duplication. For more information, see Data Matching.

  • Reference Data Services: verification of the quality of your data using the services of a reference data provider. You can use reference data services from Windows Azure Marketplace DataMarket to easily cleanse, validate, match, and enrich data. For more information, see Reference Data Services in DQS.

  • Profiling: the analysis of a data source to provide insight into the quality of the data at every stage in the knowledge discovery, domain management, matching, and data cleansing processes. Profiling is a powerful tool in a DQS data quality solution. You can create a data quality solution in which profiling is just as important as knowledge management, matching, or data cleansing. For more information, see Data Profiling and Notifications in DQS.

  • Monitoring: the tracking and determination of the state of data quality activities. Monitoring enables you to verify that your data quality solution is doing what it was designed to do. For more information, see DQS Administration.

  • Knowledge Base: Data Quality Services is a knowledge-driven solution that analyzes data based upon knowledge that you build with DQS. This enables you to create data quality processes that continually enhances the knowledge about your data and in so doing, continually improves the quality of your data.

The following illustration displays the DQS process:

DQS Process

 

A good article on how to get started, can be found here.

Tuesday, February 26, 2013

Apply an XSL transformation and show the result in a web control

For an application we build for a customer, a new feature had to be added. The application calls a 3th party web service and logs all XML messages for auditing purposes.

Now the users were asking for an easy way to see these XML messages in a more readable format, preferably nicely integrated into the application. This is a perfect fit for XSL transformations, so we decided to integrate a WebBrowser control into our application and load the XMLs after applying the XSL transformation.

Monday, February 25, 2013

TFS Administrators Toolkit

Last week, when listening to DotNetRocks, I heard about the TFS Administrators Toolkit.

TFS Administrators Toolkit for VS2012

TFS Administrators toolkit is a set of tools primarily focused on easing the burdon of tfs admins

Features and benefits

  • Subscriptions
    List and filter existing subscriptions - server wide, Unsubscribe existing subscriptions.
  • Find In Files
    Search for text or regexp in files (and all file versions) in source control. For more info please refer to
    http://mskold.blogspot.se/2012/09/find-in-files-new-feature-of-tfs.html
  • Test Attachment Sizes
    List test attachment size per team project, what kind and extensions, Clean projects directly from the UI by calling Test Attachment Cleaner.
    For more info please refer to
    http://mskold.blogspot.se/2012/05/test-attachments-sizes-new-feature-of.html
  • Update reports
    Push new reports from a template to selected team project.
  • Update Work Item Types
    Push work item type definitions to multiple team projects
  • Source control folder size
    Get a feeling for team projects size in source control
  • Search for large files in source control
    Search on size for Source control items

Download it here. Or have a look at the source code at http://tfsadmintoolkit.codeplex.com/.

I especially like the fact that you can search for files in Source Control, a very useful feature!

Go try it out yourself…

Friday, February 22, 2013

Team Foundation Server 2012: The team project does not support Microsoft Feedback Client.

One of the new features in Team Foundation Server 2012, is the Microsoft Feedback Client; an easy way to allow your users to give feedback on specific functionality of your applications.

This all works fine when you created a new project in TFS 2012, but what if you want to use this feature on an existing project? I f you try to open the Feedback Client for an existing project, it will fail with a similar error message:

The team project ProjectName does not support Microsoft Feedback Client. The team project configuration does not contain valid entry for 'Microsoft.FeedbackRequestCategory'. Contact your Team Foundation Server administrator. For more information, see http://go.microsoft.com/fwlink/?LinkId=223624.

How can we fix this?
  • Open a command prompt
  • Browse to the following location: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE.
  • Export the categories.xml file:
    • witadmin exportcategories /collection:"collection url" /p:ProjectName /f:c:\categories.xml
  • Update the categories.xml. The exact xml will be different depending on the Process Template. You will have to add at least the Microsoft.FeedbackRequestCategory and Microsoft.FeedbackResponseCategory.

clip_image002

  • Select the appropriate template and click Configure

clip_image004

  • That’s it!

Remark: Depending on the level of customization you did, it’s possible that you have to change some stuff before TFS wants enable these features. For more information have a look at http://msdn.microsoft.com/library/ff432837(VS.110).aspx.

Thursday, February 21, 2013

Coming soon(hopefully): TfPlugable, a solution to dynamically deploy plug-ins for TFS

Team Foundation Server always offered a rich extensibility model. It is very easy to create your extensions. The only problem was how to get these extensions to your users.

But this can change…

Martin Hinshelwood started the idea to simplify this process(think ‘NuGet for Team Foundation Server Extensions’). These are the key integration points he wants to cover:

  1. TF Job – These jobs can be schedules or one off and run within the context of the TFS Server Itself. They are a compiled DLL that has to be deployed to a particular folder on the TF Server in order to be loaded and registered with TFS.
  2. TF Event Sink – Events are fired on the TF Server as a result of Work Item, Build, Source Code changes and implement the ISubscriber interface. Again they need to have the containing DLL dropped into the correct folder on the TF Server.
  3. Custom Controls – Sometimes you want to extend the UI of work items capability to display data and this requires both server side and client side components to be deployed.
  4. Check-in Policy – These policies are evaluated at check-in both on the Client and on a Build Server as part of a Gated Check-in. They need to be registered in the system register to be executed but have no special folder.
  5. Soap Events – These are like TF Event Sinks but they are more disconnected from TFS. They do need to be registered with TFS, but it is a SOAP registration rather than integral to the server itself. With the introduction of TF Event Sinks there is little need for this, but if you want to have events from TFS 2008 or TFS 2010 then it may be a viable solution for backward compatibility.

I really like the idea. It would simplify my job a lot.

Hopefully we’ll see the first release appear soon…

Wednesday, February 20, 2013

Exclude a property from serialization

Last week I had to serialize a class. The important thing was that I wanted to serialize all values except one. Most of the time I use the following construct:

The [NonSerialized] attribute is only supported on field types, so I had to find another solution. As I was serializing to XML, I decided to use [XMLIgnore] as an alternative:

Tuesday, February 19, 2013

Team Foundation Server Update 1: Viewing the Kanban board

With the release of Update 1 for Team Foundation Server 2012, Microsoft added a Kanban board to the list of available features.

But where can I find this feature? If I click on View board in the ACTIVITIES list on the team home page, I end up at the original task board.

image

Same thing if I click on the board menu option that appears on the Product Backlog page.

image

So how can I open the Kanban board?
  • On your team's home page, choose View backlog to navigate to the product backlog page.

  • Highlight Product Backlog in the explorer pane and choose the board tab.

image

  • The Kanban board opens.The Kanban board automatically displays the top-ranked items in backlog priority order. Column titles will vary based on your process template.

KanbanBoard

  • What’s nice is that you can limit the WIP(Work-in-Progress) per column.

image

More information at: http://msdn.microsoft.com/en-us/library/vstudio/jj838789.aspx#ViewKanban

Monday, February 18, 2013

NHibernate: change command timeout

Every query you execute in NHibernate has a default timeout value. This timeout is set on every IDbCommands generated by NHibernate. Most of the time the default value is just fine, but sometimes you have this annoying query that just takes a little bit too much time.

You have multiple options to change the timeout value.

Global change

If you want to change it for all queries in your application, you can configure the following value in your NHibernate configuration:

  • command_timeout: Specify the default timeout of IDbCommands generated by NHibernate.
Local change

If you only want to change this for a specific query, you can set it using the SetTimeout method on ICriteria:

or on QueryOver:

Friday, February 15, 2013

ASP.NET Web API HTTP Message Lifecycle Poster

Interested in ASP.NET Web API, but you have a hard time figuring out all the different components. This poster can help you understand what’s going on(maybe a good interview question Glimlach).

 image

Thursday, February 14, 2013

Error when executing Unit Tests for Windows Store apps

When creating  unit tests for a Windows Store app,  the test runner always failed with the following error message:

------ Run test started ------

Creating a new clean layout...

Copying files: Total 4 mb to layout...

Registering the application to run from layout...

Deployment complete. Full package name: "2c5c99b8-8b5d-4ed3-8e1e-f638b2312c72_1.0.0.0_neutral__0c27qnas074n4"

Exception has been thrown by the target of an invocation.

========== Run test finished: 0 run (0:00:04,6740956) ==========

If we try to attach the debugger to see where it goes wrong, it also fails:

clip_image001

 

We tried some things but nothing helped. In the end we found the solution on Stackoverflow. It seems that this can be caused if you start changing some stuff(yes some stuff, no exact indication what can cause it and what not) in the App.xaml file.

In the StackOverflow answer they mention for example the following situations:

  • Application tag in app.xaml setting any properties (like RequestedTheme)
  • App.xaml referencing a ResourceDictionary which uses custom attached properties.

We were using the RequestedTheme property. After moving this property from the XAML file to the code behind our tests started to work.

Seems like a bug to me!

Wednesday, February 13, 2013

NUnit: Invalid signature for SetUp or TearDown method: SetUp

As Microsoft finally added out-of-the-box support for other Testing Frameworks to Visual Studio, I found it was time to move away from MSTest. I spend some time looking at xUnit but in the end I decided to go for NUnit.
To convert all my tests I started with a  simple find and replaces to switch things like [TestMethod] to [Test] and [ClassInitializer] to [TestFixtureSetUp].After everything was converted and compiling nicely I ran into a problem when executing the tests. Any test that used [TestFixtureSetUp] or [TestFixtureTearDown] were just being skipped by the test runner with the error:
“Invalid signature for SetUp or TearDown method: SetUp”
In the NUnit documentation I found the reason, MS Test uses static methods for its class initializer whereas NUnit requires instance methods.
So I had to change:
[TestFixtureSetUp]
public static void SetUp() {...}

to:
[TestFixtureSetUp]
public void SetUp() {...}

Tuesday, February 12, 2013

Portable Class Library Compliance Analyzer

I’m working on a cross platform application. To re-use most of the code we are refactoring the existing components to use the Portal Libraries.

The Portable Class Library project in Visual Studio 2012 supports the cross-platform development of .NET Framework apps.

Use this project to write and build portable assemblies that work without modification on multiple platforms, such as Windows 7, Windows 8, Silverlight, Windows Phone, and Xbox 360. For example, you can create classes that contain shared business logic for desktop apps, Windows Store apps, and mobile apps, and you can then reference those classes from your apps.

The Portable Class Library project supports a subset of assemblies from the .NET Framework, Silverlight, .NET for Windows Store apps, Windows Phone, and Xbox 360, and provides a Visual Studio template that you can use to build assemblies that run without modification on these platforms. If you don't use a Portable Class Library project, you must target a single app type, and then manually rework the class library for other app types. With the Portable Class Library project, you can reduce the time and costs of developing and testing code by building portable assemblies that are shared across apps for different devices.

To help us refactoring the code to support this, I found this great tool: PCL Compliance Analyzer. Select an assembly file, set of platforms you want to target, and it will show you if the assembly is PCL compliant and what calls are not. Here are the results for Mono.Cecil for example:

MonoCecil

PCL Compliance Analyzer is an open-source project hosted at GitHub, you can download the application here.

Monday, February 11, 2013

SQL Server Reporting Services: The feature: "Scale-out deployment" is not supported in this edition of Reporting Services.

When restoring a SQL Server Reporting Services database to a new server, the service didn’t want to start. Instead I got the following error message:

“The feature: "Scale-out deployment" is not supported in this edition of Reporting Services.”

When I was checking the report server configuration manager, I found out that in the Scale Out SSRS deployment both the new server and old server were listed. To clean up the scale out deployment configuration and remove the old server I had to do the following:

  • Open a command prompt.
  • Browse to the following path C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\
  • List the report servers found in the database type using the following command:
    • RSKeyMgmt –l
  • A list of servers with their GUID is shown. Note the GUID of the server that you want to remove.
  • Remove the instance by using the following command:
    • RSKeyMgmt -r GUIDoftheSSRSserverTobeRemoved
  • Say yes if you are asked for confirmation.

That’s it…

Friday, February 8, 2013

Hosting your own NuGet feeds

There are multiple ways to host your own NuGet feeds:

  • Using a fileshare
  • Using MyGet
  • Using the NuGet server package
  • Using the NuGet Gallery  code
Hosting your NuGet feeds using a fileshare

This is probably the easiest solution. Just create fileshare on a server somewhere and put all your packages on this share. This approach has one big disadvantage, it becomes rather slow when the number of packages grows.

Hosting your NuGet feeds on MyGet

image

MyGet, also known as ‘NuGet as a Service’ allows you to create and host your own NuGet feed. It allows you to include packages from the official NuGet feed or upload your own NuGet packages. It offers lots of nice features and best of all if you don’t need private feeds, it’s free!

Hosting your NuGet feeds using the NuGet server package

This option needs a little bit more work.

  1. Create an empty ASP.NET MVC(or WebForms) project.
  2. Download the NuGet.Server package from the official NuGet feed. This will create a simple oData feed.
  3. Deploy the application to a webserver of your choice.
  4. Add or remove packages by putting them in the Packages folder that is created for you.

Big advantage of this approach is that it introduces some caching improving the performance of the NuGet feeds.

Hosting your NuGet feeds using the NuGet Gallery

image

The last option but also the most complex one is to use the NuGet gallery, the same code that the NuGet team is using to host NuGet.org. Unfortunately you’ll have some work to get everything up and running:

  1. Download the latest source from GitHub.
  2. Navigate to the Website subdirectory and open the web.config. Inside the web.config change the following options:
    1. Modify the configuration/connectionStrings/NuGetGallery key so it points to your locally hosted SQL Server.
    2. Change the appSettings/GalleryOwnerEmail to the email address of the person who is going to administer the site.
    3. Change the appSettings/Configuration:SiteRoot to reflect the domain name you are going to use for the site.
  3. Run the Build-Solution.ps1 script using Powershell in the root directory. This will compile the website and assemble the binaries.
  4. Open up your IIS Manager
    1. Create a new application pool. The pool should use the 4.0 framework and use an integrated pipeline.
    2. Create a new website. Set the site’s physical path to point at the Website directory. Also make sure the site uses the application pool that you created in the previous step. Do not start the website yet.
  5. Open up SQL Server Management Studio
    1. Grant db_creator to the identity of the application pool you created earlier. The account needs db_creator because the first time you run the application, the Entity Framework context initializer will run. If no database exists yet then it will create the database for you. After the database is created, you can trim back the permissions to db_datareader and db_datawriter.
  6. Navigate to the NuGet gallery website. It may take a second or two for the page to appear because the database gets created during the first run.

Thursday, February 7, 2013

Copy VHD’s between Windows Azure Accounts

A colleague asked me how to copy aVirtual Hard Drive (VHD) from one Windows Azure subscription to another. Doing this is simple using the Windows Azure Powershell cmdlets.

First follow the instructions on http://msdn.microsoft.com/en-us/library/windowsazure/jj554332.aspx to download and install the Windows Azure Powershell plugin. Once the installation has completed, you can execute this one line of code from the Windows Azure command-line:

azure vm disk upload <source-path> <target-blob-url> <target-storage-account-key>

Some information about the arguments:

  • <source-path>: The url of the VHD or blob that you want to copy.
  • <target-blob-url>: The url of the Windows Azure Storage container in the destination Azure subscription.
  • <target-storage-account-key>: The storage account key for the Windows Azure Storage container.

Wednesday, February 6, 2013

Both Visual Studio and Team Foundation Server get GIT support

Last week at the ALM Summit Brian Harry did some exciting announcements: .

  1. Team Foundation Server will host Git repositories – and more concretely, Team Foundation Service has support for hosting Git repositories starting today.
  2. Visual Studio will have Git support – and concretely, Microsoft released a CTP of a VSIX plugin for the Visual Studio 2012 Update 2 CTP today.
Resources
  • You can get a good overview of how to get started (including all the download links) by reading this tutorial.
  • Watch this video for a 10 minute walk-through.
  • Also you can read the news and the Learn content on the Team Foundation Service welcome portal.
  • And don’t forget to have a look at Scott Hanselman’s opinion about it.

    I think this is really great news, Microsoft not only decides to support Distributed Version Control Systems(DVCS) but also  choose to integrate with the most popular DVCS Git(and all available services built on top of it).

    Most important question of course is when will this ship?

    “This” has many piece so let’s talk about each one in turn:

    • Team Foundation Service – As of today you can host Git repos in TFService projects. It is “shipping” now and ready for use.
    • Team Foundation Server – The plan is to include Git support in the next major release of TFS. No date has yet been announced.
    • Visual Studio 2012 support – A VSIX is provided today. It is a “community technology preview” of the Git VSIX on top of a “community technology preview” of VS 2012 Update 2 (VS2012.2).
    • Visual Studio V.Next – The Git plugin will be integrated into all editions of Visual Studio V.Next (including Express) and will appear in the various pre-releases and RTM.

    vs_heart_git

    Tuesday, February 5, 2013

    Team Foundation Server 2012: Request feedback remains disabled

    For a customer we are experimenting with the Microsoft Feedback Client.

    “Microsoft Feedback Client for TFS can help your development team gather both solicited and unsolicited feedback about your software projects from your customers and stakeholders.It allows you to launch an application, capture your interaction with it as video and capture your verbal or type-written comments as well. Your feedback is stored in Visual Studio Team Foundation Server 2012 to support traceability.”

    The easiest way to get started is to open the Web Access for a TFS project. On the Home page click on Request feedback under Activities:

    image

    The Request Feedback form is loaded. Here you can specify the people you want to contact for feedback, some instructions to load the application and some details about the kind of feedback you’re expecting.  After clicking on the Send button, an email is send to the selected people who can download the Feedback client and start using your application.

    image

    The only problem was that the Send button remained disabled. Bedroefde emoticonI was not the only one with this problem and the solution is simple. What I didn’t notice on the Request Feedback screen is that the yellow fields are required. So just provide a value and the Send button will be available…

    image

    Monday, February 4, 2013

    Shrink log files in SQL Server 2008 (or later)

    Some years ago, I blogged about the BACKUP LOG WITH TRUNCATE_ONLY commandHowever when I tried to use the same technique a few weeks ago, it no longer worked.
    When I executed the following statement
    BACKUP LOG Northwind WITH TRUNCATE_ONLY

    I got the following error message back.

    ?Msg 155, Level 15, State 1, Line 1
    'TRUNCATE_ONLY' is not a recognized BACKUP option.

    After some research on the Internet I discovered that ‘BACKUP LOG WITH TRUNCATE_ONLY’ is a dangerous command: it empties out the contents of your SQL Server’s transaction log without really backing it up. When you use it, you lose the ability to recover to a specific point in time.Therefore Microsoft decided to remove this capability from SQL Server 2008.

    The only workaround in SQL Server 2008 is to switch the database’s recovery model to simple as shown in Books Online. Afterwards you can call the following command to shrink the logs:

    DBCC SHRINKFILE(<TransactionLogName>, 1)

    Afterwards you can switch back to the full recovery model.

    Friday, February 1, 2013

    Stand-alone installer for TFS object model

    Team Foundation Server always had a rich extensibility story. By using the Team Foundation Server object model you could change or extend almost every part to your needs. The only disadvantage of the TFS object model is that the only way to install it was to install VS or Team Explorer, both of which included a VS shell, Office extensions and a bunch of stuff that you really didn’t need to do basic programmability against a TFS server.

    Good news! Last week Brian Harry announced that they released a stand-alone installer(as part of VS Update 1) that would just install the programmability components – making for a faster, smaller and less impactful install.

    You can download the installer here: http://visualstudiogallery.msdn.microsoft.com/f30e5cc7-036e-449c-a541-d522299445aa