Monday, 1 October 2012

Adding extra files to a deployment package in Visual Studio 2012

Today i ran into that problem again.
In vs2010 the property "CopyAllFilesToSingleFolderForPackageDependsOn" contains targets, to add files that would go into a publishing package.

In Visual Studio 2012 it is renamed to "CopyAllFilesToSingleFolderForMsdeployDependsOn", it took some time to find the solution, so now i hope to help everyone that got the same problem.

Working Sample

This sample includes all the files from "$(SolutionDir)\files" into the package that can be deployed.

Wednesday, 13 June 2012

Sitecore logviewing made easy with log2console

Today i saw this tweet from @kiranpatils
My new  shared source module -- SCLogExplorer -- easier and faster way to analyze  log files --
 And that make me think I should share the tool I am using, when I am developing.


Log2Console is using the different logging library's ability to log over TCP or UDP.

Sitecore is using log4net as logging engine, where there are implemented UDP and TCP appenders (Link).

It can filter on different loggers, so you can filter out any loggers you don't want, eg. Sitecore Diagnostics, analytics and more.

Log2Console can also search in the log, and filter on what level off logging you want to see

How to setup a UDP receiver 

In log2console, there is a button on the top, named receivers.
In that window, press add, and pick UUDP (IP v4 and v6)

Now you have added a receiver, and can configure that receiver.
Just leave it as default, and pick up the configuration from the sample configuration.

How to configure Sitecore

Open up the web.config from the Sitecore solution you want to receive logs from.

Find the log4net section.
And insert the sample configuration, like i have done in the code below, between the log2console comments
One thing you need to modify, is the remote address it sends log messages to. 
Change it to, because at some reason localhost ain't working.
You also need to setup a logger to use the appender you just inserted.
I'm using root, so I will receive everything.
Now launch the browser, and start up the website, and see log messages 


One more thing

You don't want this to be in production. 
If you like me, using config transform from msbuild package pipeline, you can insert this code snippet in your web.config transform file.

I hope you like this little tutorial on how to use log2console, it has a lot more features that i haven't used, so if you find somthing good, let the community know about it.

Oh and one thing i hate with the original Log2Console, is using windows 7's way to show progress state, to show that there is log messages coming in - So i made a fork making that an option. 

Tuesday, 29 May 2012

Friendly message to the visitor when deploying

When using CI(continuous integration) you can end up with a site showing "503 Service Unavailable", if you, like me are shutting down the application pool, to clean up temp files and unused files.

To make a more informative and user friendly message - when the application pool is down, a app_offline.htm file is required.
When this file is in the web root, IIS will automatically shut down the application pool, and release all file dependencies.

So first make app_offline.htm, and place it somewhere (I got it under my solution directory, in a folder called Build)

Now it just need to be deployed instead of the step where the application pool is being stopped.

I'm using teamcity to perform our CI, and got a step that stops the application pool.
So I'm replacing that step with a msdeploy step that only deployes app_offline.htm

and when the deployment is done, I got a step that removes the app_offline.htm file.

Now there is a friendly message telling the visitor its down for maintenance, and will be back soon, and refresh the page for the visitor.