Server Core, application development and FxCop

Server Core is a new Windows installation option introduced in Windows Server 2008.

The original Windows Server 2008 Server Core did not include .NET -- and that limited the things you could use it for. In Windows Server 2008 R2, Server Core includes .Net 2.0 and .Net v3.5 (neither are installed by default), which opens a new set of possibilities only available in full Server installs until now. Server Core can now run a wide variety of managed applications, including hosting ASP.NET, WCF, WF, Windows Services and Console Applications.

An important part of the original Server Core vision is to keep the installation small and focused, minimizing servicing, install time, size, etc. When we added .NET to Server Core, we maintained that vision, putting in only the parts most likely to be needed. For instance, we've left out the graphics interface (WPF and Windows Forms), design time assemblies, and some tools etc. We've also included only the 64 bit version of the Framework and tools by default.

When writing .NET applications for Server Core, you can use most – but not all – of the functionality in .NET 2.0 or 3.5 (depending on which you have installed). If, on your development machine, you use some functionality that is not present in the Server Core version of .NET, your program will probably start to run – but then give hard to diagnose errors when it hits the functionality that is not included.

Those errors can be hard to diagnose, particularly since the code will run fine on a developer machine, with full .NET. To make it easier to check for these kinds of errors, FxCop can come to the rescue, especially if you use VS 2005 or VS 2008. FxCop is a standalone application that can be downloaded from https://www.microsoft.com/downloads and is used to analyze managed code assemblies. It reports issues concerning violations of the Microsoft framework design guidelines for writing robust and easily maintainable code using .NET. For Server Core, we’ve provided a set of FxCop rules that you can use to validate your applications before you deploy them. For example, imagine that you have a Windows Service application that uses the System.Media namespace to emit a particular sound when an event happens: on a full server, with full .NET, this works just fine; on Server Core, it will fail. In this case, by loading the Server Core FxCop rules and scanning your code, you will find all the dangerous places where your application may break. We highly recommend using these rules before deploying your application to a Server Core box.

Like every other rule, this one can be loaded into FXCOP by using the “Project” menu and selecting “Add Rules…” option. To check if the action succeeded, you can see it in the rules tab.  Once loaded, these rules will scan all the assemblies in your FxCop project, looking for illegal usage of non-supported Framework type.

If you wish to download the FxCop Server Core validation rule, it can be found in this post. Also, be advised that these rules were only tested against FXCOP version 1.36.

For a complete list of supported namespaces, please, refer to Server Core’s documentation.

References:

The Server Core step by step guide is at:

· Read online: https://technet.microsoft.com/en-us/library/cc753802.aspx

· Download as a Word doc: https://www.microsoft.com/downloads/details.aspx?familyid=B16F4DC4-A3D3-4DC7-AA51-A1C6728B217A&displaylang=en

The namespace list is at: https://blogs.technet.com/server_core/archive/2008/11/25/net-2-0-and-server-core-in-windows-server-2008-r2.aspx and once the WS08 R2 SDK is published it will be include there as well.

W2K8ServerCore.zip