Archive for the ‘Tools’ Category

Visual Studio Command Prompt in Console

I’m a big fan of Console – it’s a nifty little app that lets you host multiple disparate command prompts in a single tabbed interface. I have a regular command prompt, a Git bash, a Powershell prompt and a Python … Continue reading 

CoffeeScript, Sass and LESS support for Visual Studio and ASP.NET with the Mindscape Web Workbench

There's some really impressive stuff happening in the .NET Community lately. Folks are reaching outside their standard built-in tools and pulling inspiration from everywhere. It's been said that (some) Microsoft developers don't like to use…

Symptoms of a centralized VCS

Reading the TFS 2010 Branching Guide on CodePlex (no, I’m not a glutton for punishment, just want to know what else is going on in the world), I found an interesting note on scratch or temporary branches that pretty much … Continue reading 

Scheduled tasks with Quartz.NET

I’ve used a few different task schedulers on my current project, where I have to kick off NServiceBus sagas at very specific times of day (every night at 2AM etc.) We started out using the built-in Windows Task Scheduler, which … Continue reading 

MvcConf 2– February 8th, 2011

We’re getting ready for the next version of MvcConf on Tuesday, 2/8/2011 from 8AM-5PM CST! What is MvcConf? MvcConf is a virtual conference focused on one thing: writing awesome applications on top of the ASP.Net MVC framework. Your brain will expl…

Protip: Viewing large XML files

There are lots of editors that can view large XML files, such as Visual Studio, Notepad++, UltraEdit and so on.  But all of these have one flaw – they try and do too much in viewing XML.  Things like coloring, expand/collapse widgets and so…

Using Solution Factory + NuPack to create Opinionated Visual Studio Solutions.

Using Solution Factory inside of NuPack opens up a great new world of creating Solution Level templates. Previously, I wrote a lot of code in Solution Factory that just kept running into edge cases working against the Visual Studio automation API ,DTE….

Automating scheduled tasks

Back in the day, I used to develop scheduled tasks by writing my own task scheduler and batch execution program.  I don’t think at the time I knew about the Task Scheduler service built in to Windows.  It support just about any scheduling algorithm I could throw at it, outside of building dependent or cascading tasks.

For build automation, I often want to create, stop and start these scheduled tasks.  Luckily, there’s a handy command-line tool to do so: schtasks.exe.  Not only can you administer tasks on your own machine, but other machines as well.  This is perfect for build and deployment automation, where I need to not only copy files, but execute SQL migration scripts, start/stop services, and power down/up scheduled tasks.

The command-line tool lets you do quite a few things:

  • Create a task
  • Delete a task
  • Run a task
  • End a task
  • Query a task for status/information
  • Modify a task

I typically don’t create the tasks, as that really only needs to happen once.  However, it would be fairly trivial for me to do so, and have all of the task setup driven through automation.

One thing I like to do is disable batch jobs before the deployment happens, then turn them all back on.  I don’t want to do this with all the tasks there, so I use NAnt to pull from a text file of the scheduled tasks I’m interested in.  However, I don’t want to disable running tasks, as I want to just let them finish and have the build stop:

<echo message="Disabling batch jobs..." />
<foreach item="Line" in="batchjobs.txt" property="taskName">
    <exec program="schtasks.exe"
                commandline="/Query /TN ${taskName} /FO TABLE /NH"
                output="task.txt" />
    <loadfile file="task.txt" property="batchjob.info" />
    <exec program="schtasks.exe"
                commandline="/CHANGE /TN ${taskName} /DISABLE"
                if="${string::contains(batchjob.info, 'Ready')}"/>
</foreach>

In this NAnt snippet, I loop through the batch jobs I care about.  I then call the “schtasks.exe”, querying the tasks status by name and outputting the result in the form of a table to a “task.txt” file.  Next, I load that file into a NAnt property.  Finally, I use the “/CHANGE” switch to disable the scheduled task, but ONLY IF its status is “Ready” and not “Running” or something else.

Next, I’ll run through the batch jobs file again, this time querying for any task that hasn’t been disabled.  If there are any, I’ll just fail the build.  I could sleep the build script, and poll until the task completes.

Once the build is done, I’ll enable all the configured scheduled tasks:

<echo message="Enabling batch jobs..." />
<foreach item="Line" in="batchjobs.txt" property="taskName">
    <exec program="schtasks.exe" commandline="/CHANGE /TN ${taskName} /ENABLE" />
</foreach>

Build automation can really cut down on those launch-night headaches and uncertainty.  Having a good command-line tool goes a long way to enabling easy build automation scripts.

Kick It on DotNetKicks.com

Integrating the Git bash into Console

One of the essential development tools (found on Hanselman’s tools list) is a better command shell.  The regular “cmd.exe” that comes with every version of Windows is quite lame.  Console offers a host of improvements over the build-in command prompt, not least of which is the tabbed interface, allowing me to have one Console window with tabs for different directories/shells.

Another cool feature of Console is that you can host different shell configurations.  And since the git bash is build on top of cmd.exe, it’s pretty straightforward to plug the git bash into Console.

First things first, make sure you have msysgit installed.  You can find the installation instructions from Jason’s Git for Windows Developers series.  Next, you’ll need to install Console, which you can download from the SourceForge site.

After launching Console, we’ll need to add a new tab launcher by navigating to Edit->Settings:

image

In the Settings window that pops up, click the “Tabs” section, then the “Add” button to add a new Tab:

image

This will bring up the settings for the new tab you created.  In the configuration options in the “Main” tab below, I use the following settings (without quotes):

  • Title: “git bash”
  • Icon: “C:\Program Files (x86)\Git\etc\git.ico”
  • Shell: “C:\Program Files (x86)\Git\bin\sh.exe –login –i”
  • Startup dir: “C:\dev”

I installed Git to the “C:\Program Files (x86)\Git” directory, so this might be different on your machine.  The Icon setting is not necessary, but it’s nice to see the Git icon in a tab for differentiation.  Click “OK” and you can now create a new Git tab:

image

You now have a git bash in a tabbed interface, letting you keep multiple git bashes/command prompts around at once in a nice tabbed interface:

image

You can add tabs for other kinds of command prompts, such as the Visual Studio command prompt (with the correct PATH variables set) and so on.  Next up is trying out posh-git

Kick It on DotNetKicks.com

DevExpress is a Platinum Sponsor of Austin Code Camp 2010

dev-exp-logo-with-slogan-350

Developer Express Inc. develops Feature-Complete Components for ASP.Net and Winforms, Reporting Tools, IDE Add-ins, and Business Application Frameworks for Visual Studio.

Information at www.devexpress.com

On behalf of the Austin .Net Users Group (ADNUG) and every attendee of Code Camp 2010, we would like to thank DevExpress for your contribution to Code Camp 2010. This event is funded by your contribution and would not be possible without your support of the local technology community:

Our Sincerest Thanks,

Austin Code Camp 2010 Committee

 

To Attend, Speak, Volunteer, or Sponsor the Austin Code Camp go to http://Codecamp.Adnug.org

Kick It on DotNetKicks.com