Dev Blog - Johan Danforth
I'm Johan Danforth and this is my dev blog - a mix of .NET, ASP.NET, Rest, Azure and some other random coding stuff.
-
[Team System] Team Building Web Application Projects and Deploying
I've been battling with Team Build and Web Application Project (WAP) solutions. I first thought that Web Deployment Project (WDP) was the way to go, but I found out the hard way that WDP + WAP + Team Build isn't best mates.
What I want to do is to build a number of solutions (which includes a bunch of projects) and after the build has completed, xcopy the web applications to a specific place, like under IIS webroot.
There are many, many different solutions to this scenario, but I think it's a very common one. Here's what I'm thinking of doing now. Step by step dummy:
1. I create a TFS project "WebApplication1"
2. I create a solution called "WebApplication1" with 2 projects in it; "WebApplication1" (WAP) and "LibraryX" (Class library), I create some dummy code where a web page calls some code in the class library (mostly for fun).
3. Compile and test.
4. I add the solution to SourceControl.
5. I then create a new Team Build called "WebApp1".
6. Go to Source Control Explorer and check out the TFSBuild.proj file for edit, then double click it to edit.
7. Page down to the end of the build file and add (before the </Project> tag):
<ItemGroup>
<WebFiles Include="$(BinariesRoot)\Release\_PublishedWebsites\**\*.*"></WebFiles>
</ItemGroup>
<PropertyGroup>
<DeployWebDir>c:\websites</DeployWebDir>
</PropertyGroup>
<Target Name = "AfterDropBuild" >
<RemoveDir Directories="$(DeployWebDir)" Condition="Exists('$(DeployWebDir)')" />
<MakeDir Directories="$(DeployWebDir)" Condition="!Exists('$(DeployWebDir)')" />
<Copy
SourceFiles="@(WebFiles)"
DestinationFiles="@(WebFiles->'$(DeployWebDir)\%(RecursiveDir)%(Filename)%(Extension)')"
/>
</Target>What the stuff above does is that it declares what files to copy (WebFiles) and where these files should go (DeployDir). Then there's a Target section which is called by Team Build after the drop has been made (AfterDropBuild) that removes the old files and copies the files from WebFiles to DeployDir. The $(BinariesRoot) property points to where the files have been built. WAP files are always built to the _PublishedWebsites\<project> directory.
My web application is now deployed to c:\websites\WebApplication1\ and I'm manually creating an IIS virtual directory which will always be pointing at this directory.
There are a number of additional things you might want to do as well, but I just wanted to show you a very simple way of always copying WAP files to the same place after a build.
If you don't want to use the Tean Build drop directory at all, you should be able to skip that step by setting the SkipDropBuild property to true in the TFSBuild.proj file.
MSBuild / Team Build Resources:
List of targets that can be customized in Team Build (like AfterDropBuild in my sample):
http://msdn.microsoft.com/en-us/library/aa337604(VS.80).aspx
MSBuild Task reference:
http://msdn.microsoft.com/en-us/library/7z253716.aspx
Brennan's blog with a 7 step tutorial on MSBuild:
http://brennan.offwhite.net/blog/2006/11/29/msbuild-basics-1of7/
How to create your own MSBuild task:
http://msdn.microsoft.com/en-us/library/ms400767(VS.80).aspx
-
[Service Factory] How the Service Factory Guys Think
Don Smith put a video up on the Service Factory Codeplex site about how they think about services, where they believe Service Factory is today and where they are heading. I thought the message about the different types of services was quite interesting because it is close to the way we're thinking when we're identifying service components for an enterprise. Note that the type of (web) services you may create as part of a specific solution because it may help you scale out, tier and get better availability and so on is something different to me. I'm more thinking of enterprise class services here.
Don mentions 3 types of services; Entity/Capability, Utility/Messaging and Process/Activity.
The first one is easy to understand and I think that's where most organisations start on their SOA roadmap. An Entity Service is usually very simple and may represent one or more business entities with data stored in a database or perhaps wrapped within a (legacy) system. You often se CRUD-like interfaces on these, but I recommend you to try and stay away from too granular methods. If you have an entity service for say a Person or a Customer, consider to not expose methods to get just the phone number or the email address, but rather get a complete Person or Customer object. These objects could be based on well known XML Schemas owned by perhaps information architecture group or something.
The second type of services I usually call "Infrastructure Services" and are typically Security Token Services (STS), message routers and such. Could also be metadata/taxonomy/ontology services to help out with information integration cross services and systems. If anyone was using UDDI, I think it could also be placed in this category ;) Having said that, I think this category of services are very, important. It's hard to maintain and govern enterprise class services without an STS and a proper service catalogue. Not sure I understand their view on "Message" in this type of services. "Simple" Message routing services based perhaps on ws-addressing and such could be placed here, but more complex message handling, perhaps handled by a workflow engine, I think would go into the third and final category of services...
...called Activity and/or Process Services, which usually (for us anyway) contains methods and interfaces that map to scenarios, use cases, routines/functions (depending on which methodology and terms you're using). Also good for long running processes which may involve message queues, perhaps BizTalk and Windows Workflow Foundation. These services most often use other services, like Entity Services, to orchestrate and aggregate data needed by service consumers. They may not have their own database like Entity Services, unless you need to save state for a workflow or to keep replicated and denormalized data for aggregated search or perhaps masterdata for partitioned entities. See the Entity Aggregation pattern for a detailed description. One could argue that services that implement the this pattern should go into the first category of services, but I usually put them into the Activity Service category anyway, for reasons I'll probably blog about some other time (it's getting late).
I'm happy to hear about where the Service Factory team is heading, to have better support for Utility/Messaging (Infrastructure) Services and move into support for Activity/Process Services. I wish there were some good guidance for activity and process services already. I'm quite interested in seeing what this team will do with LINQ in the near future. I'm not too fond of the data access code in current Data Access Guidance Package.
Anyway, go check out the video, it's short and the sound is a bit so, so, but it's a good message.
-
Modify the Paperclip Theme on weblogs.asp.net
The CS themes available on weblogs.asp.net are quite good, but maybe you want to add that extra personal touch to it. Say you want to change the big "masthead" picture on top of the screen of the paperclip themes. If you just have somewhere to host your own picture, it's not that difficult to override the theme settings.
To change the masthead picture of the paperclip theme, first have a look at the css for the theme and see how the picture is referenced. View source and find the stylesheet link:
<link rel="stylesheet" href="/Themes/Blogs/paperclip/style/cactus.css" type="text/css" media="screen" />
Then download that css file and have a look at it. Search for the name of the picture you want to override, like "winter-title.jpg":
/* The masthead sits at the top of the page.*/
#masthead
{
background: #ffffff;
background-image: url(../images/cactus-title.jpg);
}This tells me I need to override the css declaration called #masthead. Next, you create your own background-image for this section, and it's best if you use the old image as a template, or else you need to override other css settings, like where the paperclip text is written, width, height and so on. Personally I just saved cactus-title.jpg file and used Photoshop to create something new on top of it. When you're happy with the picture, upload it to wherever you want to host that file. Last thing is to go into the blog dashboard of weblogs.asp.net, click to "Global Settings" and "Change How My Blog Looks". Now go to the second tab of that page named "CSS Overrides" and past in something like this:
#masthead
{
background-image: url(http://www.somehost.com/pictures/my-title.jpg);
}
That's it. I'm about to create a new picture now :) -
Note to Self
I've not blogged much lately, and it's not because I don't have anything to blog about - quite the contrary. Too much to do right now. I got a few things I would like to blog about, just as a note to myself:
- The use of Software Factory to build WCF web services in a structured way (it's helping us out in a large SOA project now), and why you must be careful of using too long project names :(
- How you could modify Software Factory to fit your needs, add new recipies and tweak the code that gets generated (my colleague Eric has done some cool work with this, and I hope he will blog about how to enable DataContract generation from an XSD-schema)
- A few things to think about when writing XSD-schemas to be used for generating WCF DataContracts.
- The (what seems to be) lack of support for calling Workflows (WF) från WCF and vice versa. It wasn't as easy as dragging a WCF Activity från the toolbox... I'm still struggling with this one.
- Some experience from using DataDude with Software Factory and Team Foundation Server
- And some CI with TFS notes that may help other people out.
Sorry for not posting anything useful about the topics above right now, but I'll get to it, I promise. Stay tuned :)
-
Built Media Center PC, Streaming to Xbox
It's been a while since I blogged anything now. Not that I've not had anything to blog about, but rather the other way around.
During the holidays I built myself a new PC to run Media Center on, stuck a tuner card into it and set up my Xbox 360 as an extender. It works pretty well I must say. I'll write more about the custom PC later and things to think about when installing Media Center, transcoding movies and stuff. I didn't bother trying the Media Center version on Vista because I still have probs with device drivers for my printer, my scanner and a few other things :( Media Center Edition of XP works well for me I must say.
Something you want to look at if you're into streaming divx videos from MCE to your Xbox is the Transcode 360 project avaiable at http://www.runtime360.com/projects/transcode-360/. It's a must.
-
New Stuff, New Stuff, Go Download Already
First of all you got the VS 2005 Service Pack 1 for Team Suite, and it's said to contain some 2200 fixes?!?! It's available for download here. Note that it's a 430 MB download and it's also said to take some time to install.
Second good thing, and also a must to download and check out, is the RC1 of ASP.NET AJAX. You can read about it on Scott's blog. As usual, Scott gives you the info you need. I'm pretty sure that this package will used ALOT in the next couple of years, until something else pops up or becomes "cooler". Perhaps WPF(e) will beat it eventually, Another thing - the ASP.NET hompage news also says:
The Microsoft AJAX Library is also available in an easy-to-install, standalone package for development on non-Windows systems.
Sounds interesting, don't you think? You can download and read more about ASP.NET AJAX on their webby,
-
[.NET 2.0] Playing Around with BuildProvider and CodeDom
This is old news for some of you, but I've never looked at the ASP.NET buildprovider functionality in more detail until tonight, and it is pretty cool. The buildprovider can generate/build code from certain file types you drop into an ASP.NET project and I'm sure you're familiar with .xsd files and how VS.NET generates classes from those. The cool thing is that you can write your own buildprovider and generate code yourself.
If you think this sounds like fun, here's a few links for you to get you started:
- Fritz Onion's "Jaw Dropping Experience": http://pluralsight.com/blogs/fritz/archive/2004/09/06/2188.aspx
- Kirk Allen's "Web Services Contract First" blog post: http://blogs.msdn.com/kaevans/archive/2005/09/02/460231.aspx
- Daniel Cazzulino's article on code generation: http://msdn.microsoft.com/xml/default.aspx?pull=/library/en-us/dnxmlnet/html/xsdcodegen.asp
What you need to know though, is that if you need to do something more elaborate, the CodeDom stuff isn't a walk in the park. Also, the buildprovider only works for ASP.NET projects, which is sad news, but Scott Guthrie explained it in an old blog post of his:
In the beginning of the Whidbey project there was a plan to enable broad declarative support for file-types as compiler inputs (for example: XAML could have been processed this way). Unfortunately due to time/resources the compiler teams had to scale back their support for this -- and only web projects still contain them. I'm hoping we'll see broader support for them in all project types with future releases.
Buildproviders should also work in Web Application Projects, but I couldn't get it to run... Have to look at that again some other day. I saw Scott Guthrie mention this in some blog post, but I cannot find it now. UPDATE: I got a mail from Scott about this:
Unfortunately build providers don’t work directly with web application projects (they still work for the running app – but the assemblies they create aren’t linked to by the web application project assembly, so you can’t reference the types directly.
You can, however, use the VS feature called “single file generators” that enable you to generate .vb/.cs files from declarative types, and then include this within your project assembly.
Pity... guess I have to look at single file generators then if I want to follow up on this one. Or just run an external code generator manually. No time for this now anyway, too much work to do...
-
How to Use Msbuild.exe with CruiseControl.NET
I just updated my primer/tutorial/walkthrough on CruiseControl.NET with some information about how to use msbuild.exe instead of devenv.exe in your minimal cc.net configuration. One good reason to go with msbuild is that you don't need to install VS.NET on a dedicated build server, and you can also target unit tests, performance tests, code analysis etc. that you may have added using the Team Edition versions of VS.NET.
Please check it out and comment on it if you please.
-
System Restore...
I'm not sure what has happened with the WinXP Automatic Updates lately, but a while ago I noticed (for the first time) I had an option to Shut down and install updates at the same time. I tried it the second time I saw it and naturally it hung my whole system.
The machine wasn't working properly after that of course, but I managed to get in and install the updates more or less manually.
Today I got new problems with the updates. It started with a crash in the svchost.exe process and I tried to debug and see what it was. Windows popped up a webpage telling me there was a fix for this specific "Generic Host bla bla bla" problem. I installed it, it told me it won't fully work until I restart my machine. Alright, I kept running for a while, got the svchost.exe crash again and decided to restart.
After the restart, WinXP wanted to start install some Updates it appearently had in queue! At login? Weird. It didn't ask and I couldn't stop it. Of course the installation failed as it hung my whole box. I let it sit there for a long time before I decided to restart the machine.
Anyway, what saved me today was to restart the machine, hit F8, select to start with a "configuration that worked" or whatever the menu option says. Now I'm in, I've configured Automatic Updates in a way so that I will decide myself when to download and install. All seems to work WAY better now.
I wonder how far away SP3 is... I think I'm going for Vista as soon as I get my hands on the RTM version.
UPDATE: LOL, I was too fast... after this "manual" Windows Update and the recommended reboot, I got a new crash after logging into Windows, now it was the AutoUpdate.exe crashing on my... yeah... LET ME WORK FOR LOVE'S SAKE!
-
[Podcasts] Podcast Aggregator - Doppler
My buddy Jan-Erik has been listening to podcasts for a while now, and he pointed me to a program called Doppler which seems to be a decent podcast aggregator. I've only just started to use it, but it looks nice and seems to behave well. It got all the bells and whistles we're getting used to nowadays - async downloads, system tray, notifications and so on, and you can turn these features on and off as you please.
Go check Doppler out at http://www.dopplerradio.net/
Now I need to look for a seamless way to get these things over to my Sony Ericsson mobile without too many clicks.