Friday, April 3, 2009

Enabling syntax highlighting in your Blogger Blog

This is a test of the SyntaxHighlighter code snippet formatter.

public void Foo(string bar, int baz)
{
if (YouSeeThis())
{
Console.WriteLine("It worked!");
}
}
For the above to work you need to have the following code:

<script src='http://[yourhostname]/scripts/shCore.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushBash.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushDelphi.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushDiff.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushGroovy.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushJava.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushPlain.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushPython.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushRuby.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushScala.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushVb.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushXml.js' type='text/javascript'/>
<link href='http://[yourhostname]/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://[yourhostname]/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script class='javascript'>
//<![CDATA[
function FindTagsByName(container, name, Tag){
var elements = document.getElementsByTagName(Tag);
for (var i = 0; i < elements.length; i++){
if (elements[i].getAttribute("name") == name){
container.push(elements[i]);
}
}
}
var elements = [];
FindTagsByName(elements, 'code', 'pre');
FindTagsByName(elements, 'code', 'textarea');

for(var i=0; i < elements.length; i++) {
if(elements[i].nodeName.toUpperCase() == 'TEXTAREA') {
var childNode = elements[i].childNodes[0];
var newNode = document.createTextNode(childNode.nodeValue
.replace(/<br\s*\/?>/gi,'\n'));
elements[i].replaceChild(newNode, childNode);
}
else if(elements[i].nodeName.toUpperCase() == 'PRE') {
brs = elements[i].getElementsByTagName('br');
for(var j = 0, brLength = brs.length; j < brLength; j++) {
var newNode = document.createTextNode("\n");
elements[i].replaceChild(newNode, brs[0]);
}
}
}
SyntaxHighlighter.all();
//]]>
</script>

Thanks go to the following for getting this working:

Tips for software engineer: Using SyntaxHighlighter on BLOGGER

Test of SyntaxHighlighter

This is a test of the SyntaxHighlighter code snippet formatter.

public void Foo(string bar, int baz)
{
if (YouSeeThis())
{
Console.WriteLine("It worked!");
}
}
For the above to work you need to have the following code:

<script src='http://[yourhostname]/scripts/shCore.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushBash.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushDelphi.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushDiff.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushGroovy.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushJava.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushPlain.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushPython.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushRuby.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushScala.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushVb.js' type='text/javascript'/>
<script src='http://[yourhostname]/scripts/shBrushXml.js' type='text/javascript'/>
<link href='http://[yourhostname]/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://[yourhostname]/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script class='javascript'>
//<![CDATA[
function FindTagsByName(container, name, Tag){
var elements = document.getElementsByTagName(Tag);
for (var i = 0; i < elements.length; i++){
if (elements[i].getAttribute("name") == name){
container.push(elements[i]);
}
}
}
var elements = [];
FindTagsByName(elements, 'code', 'pre');
FindTagsByName(elements, 'code', 'textarea');

for(var i=0; i < elements.length; i++) {
if(elements[i].nodeName.toUpperCase() == 'TEXTAREA') {
var childNode = elements[i].childNodes[0];
var newNode = document.createTextNode(childNode.nodeValue
.replace(/<br\s*\/?>/gi,'\n'));
elements[i].replaceChild(newNode, childNode);
}
else if(elements[i].nodeName.toUpperCase() == 'PRE') {
brs = elements[i].getElementsByTagName('br');
for(var j = 0, brLength = brs.length; j < brLength; j++) {
var newNode = document.createTextNode("\n");
elements[i].replaceChild(newNode, brs[0]);
}
}
}
SyntaxHighlighter.all();
//]]>
</script>


Thanks go to the following for getting this working:

http://developertips.blogspot.com/2007/08/syntaxhighlighter-on-blogger.html

Thursday, April 2, 2009

NAnt/MSBuild ClickOnce publishing ‘publish.htm’

The secret to this is specifying in the properties passed to MSBuild either directly or via NAnt. There are two specific properties you need to get the publish.htm published:

CreateWebPageOnPublish true
WebPage publish.htm

You can specify these as command line parameters as follows:

/property:CreateWebPageOnPublish=true

/property:WebPage=publish.htm

Once you are passing these parameters to MSBUILD it will move your publish.htm up to your publish location. Note, that there are many more properties that you can specify in the same way. Take a look inside of your .csproj file Property/PropertyGroup for a list of the values. You can experiment with the GUI inside of Visual Studio and then see how the values change so you can tweak your MSBuild/NAnt script accordingly.

UPDATE: It turns out I'm wrong on this. The above solution does not auto-generate a publish.htm. More to follow.


Technorati Tags: ,,

Adding your own Pre-requisite installer to a ClickOnce app

STEPS

  • Download and install the Bootstrap Manifest Generator
  • Start a New Project and choose Package Manifest
  • Give your project a name and code (these can be the same)
  • Click on Project/Add Install File and choose your installer
  • Give a Display Name in the Install File settings
  • Build your project with Project/Build
  • On Vista this will ignore any properties about where it creates the file. Look for it in \Users\{username}\Documents\{Project Name}
  • Copy this to your packages location. Usually here: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\

You should now be able to choose this in your Project Properties\Publish\Prerequisites list.

LINKS

Bootstrap Manifest Generator

Customising your ClickOnce deployment

Technorati Tags: ,,