Using StudioShell to generate WiX XML

I have to say it – after seeing Jim Christopher‘s StudioShell talk at devLink this past year, I think it’s been my most favorite Visual Studio tool so far.  I get to use my PowerShell knowledge to help script stuff out, saving my teammates a ton of work.  Today, we added about 10 new pages to one of our client’s sites and had to update a WiX installer.  Recognizing patterns and an opportunity for PowerShell, I just had to use StudioShell to eliminate the tediousness of generating the XML code manually.

Background

We have a Visual Studio 2010 solution with numerous projects – class libraries, WiX installers, and at least one web application.  One of the annoyances we have on our team is maintaining the WiX files every time we update a page, in order to make sure our pages get deployed properly.  So imagine our frustration today, after adding about 10 pages of content to our web application, we realized that we had to update our WiX installer for the website.

For those not familiar with WiX – Windows Installer XML (WiX) is what’s used in creating MSI files from XML.  You can use the WiX toolset to help you maintain these packages.  The WiX toolset documentation is available on SourceForge.  Every time we need to add a file to the server, we have to update our WiX wxs file.  Syntax for that looks something like this:

<File Id="SampleFile.aspx" Name="SampleFile.aspx" Source="$(var.OurSamplePath)SubfolderSampleFile.aspx" />

Problem and Solution

Our problem was that we needed to create that line for 10 new ASPX files.  Sure, we could have borrowed a line from one of the files already in the directory, copied and pasted it 10 times, and then manally search-and-replaced each of these instances.  But even that takes a long time.  Knowing what I did with what tools I had available, this is how I saw it.  That XML above pretty much boiled down to this for me:

<File Id="{0}" Name="{0}" Source="$(var.OurSamplePath)Subfolder{0}" />

I saw that pattern and realized I could turn that into a string and pass it the names of the files.  I also realized that I could use StudioShell to navigate through my project’s structure to get a list of the new files – which happened to be all of the ASPX files in a particular director and output them into this XML.  My StudioShell commands looked something like this:

cd DTE:
cd solutionprojectsProjectNameSomeSubFolder
dir *.aspx | % { "<File Id=`"{0}`" Name=`"{0}`" Source=`"`$(var.OurSamplePath)Subfolder{0}`" />" -f $_.Name }

The StudioShell output looked something like this:

<File Id="AgeGroups.aspx" Name="AgeGroups.aspx"
Source="$(var.OurSamplePath)SubfolderAgeGroups.aspx" />
<File Id="Fees.aspx" Name="Fees.aspx"
Source="$(var.OurSamplePath)SubfolderFees.aspx" />
<File Id="Home.aspx" Name="Home.aspx"
Source="$(var.OurSamplePath)SubfolderHome.aspx" />

What took me a few minutes to type the command, run, copy the output, and paste into the wxs file could have easily taken longer if I hadn’t had StudioShell.

Note: While I could have fired up PowerShell and navigated my code via the FileSystem provider (as the dir command and the string formatting are PowerShell), I preferred to use StudioShell because our projects in the solution were in different folders and having the DTE:solutionprojects navigation that StudioShell made it that much more easier and convenient to just do this work from within Visual Studio.

Conclusion

Once again, having StudioShell as part of my installed Visual Studio tools made it that much easier for me to script out a process and get the results I needed within a much shorter period of time than doing it manually.  If you haven’t checked out StudioShell yet, you can find it at http://studioshell.codeplex.com.

A Special Message for Today

01010111 01101001 01110011 01101000 01101001 01101110 01100111 00100000 01100001 01101100 01101100 00100000 01100111 01100101 01100101 01101011 01110011 00100000 01100001 01101110 01100100 00100000 01100111 01100101 01100101 01101011 01100101 01110100 01110100 01100101 01110011 00100000 01100001 00100000 01110110 01100101 01110010 01111001 00100000 01101000 01100001 01110000 01110000 01111001 00100000 00110001 00110001 00101111 00110001 00110001 00101111 00110001 00110001 00100000 01100100 01100001 01111001 00100001

Microsoft Promoting Windows Phone App Building

I just noticed today’s date, and I’ve had my Windows Phone for about a year.  Has it been a year already?!?  Time flies when you have a phone that you like (and I truly like my Samsung Focus)!  But have you, as a developer, found yourself with a smart phone and a need for a particular app but couldn’t find the right app?  That’s an opportunity to build your own app!

The [Your App Here] Campaign

Yesterday, I received an email from Microsoft about their [Your App Here] advertising campaign program.  They’re looking for the next wave of great apps for Mango (Windows Phone 7.5) phones.  Unfortunately, this program is limited to developers in the United States.

The email mentions two campaigns – January and February – with respective submission deadlines of 11/16 and 12/22.  By submitting your app, you are entering for a chance to win placement in a digital Windows Phone campaign, with banner ads and up to a million impressions through the MSN Network.  The app will also be featured at the Windows Phone marketplace.

So that app you’ve been thinking about… maybe it’s time to build it and get others using it as well!  For more details, see The [Your App Here] Campaign site.

Windows Phone Camp Hands On Accelerator Lab

What better way to work on your Windows Phone app than to check out the Windows Phone Camp Hands On Accelerator Labs that Microsoft is hosting in various cities throughout the country?  Next week, Tuesday (11/15) through Thursday (11/17), Microsoft is hosting a 3-day camp in Columbus, OH to help you get your apps out to the Windows Phone market.  Whether you’ve got a totally new app idea or maybe have an Android, iPhone, or BlackBerry app that you want to see on Windows Phone, this can be a great opportunity to work with Microsoft resources on how to get your app built and out to the Windows Phone Marketplace.  For more details on the Columbus Windows Phone Camp Hands On Accelerator Lab, click here.

31 Days of Mango

My friend Jeff Blankenburg is a Developer Evangelist over at Microsoft who’s been passionate about Windows Phone for quite awhile.  He wrote a “31 Days of Windows Phone” series awhile back, and now he’s publishing his new series – 31 Days of Mango.  If you aren’t familiar with some of the new features in Windows Phone 7.5, then you really should check this series out.  I really like that these articles have pictures to go along with the descriptions, so that as the reader, we have some context as to what we should be seeing if we’re following along with the blog post.  There are plenty of resources in this series for working with Mango – to date, including emulator tools, reminders, motion, contacts API, and the calendar API. For more details, you can check this out at http://jeffblankenburg.com/31daysofmango.

Other Resources

There are plenty of resources for getting started with Windows Phone.  In addition to those above, you can always check out http://create.msdn.com.  With all of these resources at your fingertips and the need for an app on your Windows Phone, what are you waiting for?  Start your app today!

Words of Advice from an Inc. Success Story – Forget Gender

Now that I own my own business, I find myself reading more and more business-oriented websites.  Inc. is one of those sites.  While reading yesterday, I found one of their success stories intriguing.

Theresa Alfaro Daytner is the owner of a construction company.  Inc.’s success story is here: http://www.inc.com/video/201101/success-stories-daytner-construction-group.html.

There’s one question in particular that stands out:

What would you say to other women looking to break into male-dominated fields?

3:10 Theresa: As a woman, coming into a male-dominated field, look at the opportunities I have to redefine how we do it. So, I’m very intent on value-add to our clients. I really want to be a partner with our clients, and I gravitate toward the type of clients and projects that profoundly impact me, whether that’s in education, health care… Those are things that I naturally gravitate toward. So, what I would tell women who are interested is, “I wouldn’t worry about whether there are more men or women in a particular field.” If you feel like you have the resources to put together in a particular area to be exceptional at it, whether it’s something that more women are in, like marketing or advertising, or something like construction or engineering. If you think you can be excellent at it from a business model standpoint, and you’re passionate about the value-add that you can bring there, I say there’s really nothing that should stand in your way.

These words of advice are so very true. When I decided to explore computers professionally, it was based on a few things – (1) I could make better money with less effort in computers rather than in music, (2) I had a lot of fun tinkering around with code at home – from releasing a freeware address book on NoNags to working on websites, I liked it all, and (3) while I knew it was a male-dominated field, I wasn’t going to college for my MRS degree (awful joke some people made) – I had my supportive boyfriend back then and didn’t put any thought like that towards my friends.

I pursued a field that I was not only interested in from an educational standpoint, but I was also interested in tinkering with as a hobby.  I knew that I could work in the field writing business apps – if I could stay focused enough to write something as simple as an address book application, then I could handle writing serious applications.  However, at the end of the day, I knew I’d probably go home to work on some other projects, since I really really enjoyed playing with code.  It didn’t matter if it was Visual Basic, HTML, Perl, or even my nemesis at the time  – Javascript.  Here I am, out of college almost 10 years, playing with computers for over a decade,  and it still hasn’t gotten me bored or driven me away.  And you know what… I never considered the gender factor through any of this because I was too busy doing what I loved and wasn’t taught to worry about these factors.

So I agree with Theresa’s advice – if you think you can be excellent at whatever it is you’re interested in from a business model standpoint and you’re passionate about it, then go for it.  Live your dreams!

Spam SUX: Chase threatens…

Waitress: Well, there’s egg and bacon; egg sausage and bacon; egg and spam; egg bacon and spam; egg bacon sausage and spam; spam bacon sausage and spam; spam egg spam spam bacon and spam; spam sausage spam spam bacon spam tomato and spam;
Vikings: Spam spam spam spam…
Waitress: …spam spam spam egg and spam; spam spam spam spam spam spam baked beans spam spam spam…
Vikings: Spam! Lovely spam! Lovely spam!
Waitress: …or Lobster Thermidor a Crevette with a mornay sauce served in a Provencale manner with shallots and aubergines garnished with truffle pate, brandy and with a fried egg on top and spam.
Wife: Have you got anything without spam?
Waitress: Well, there’s spam egg sausage and spam, that’s not got much spam in it.
Wife: I don’t want ANY spam!

– Monty Python’s Flying Circus

I feel a lot like the wife in the Monty Python Spam skit.  I don’t know about you, but I don’t like spam – be it from someone I used to do business with, someone I’m currently doing business with, or even someone I may deal with in the future.  Though if you want to deal with me in the future, you’re smart enough not to spam me in the first place.  Lately, though, there have been some reputable companies that have been turning to spam that have made me sad and made me wonder – When did spam become an acceptable business practice?

Definition of Spam

Taken from Encarta, via Bing:

Definition
spam
NOUN
spams plural
1. electronic junk mail: an unsolicited, often commercial, message transmitted through the Internet as a mass mailing to a large number of recipients
TRANSITIVE AND INTRANSITIVE VERB
spammed past and past participle
spam·ming present participle
spams 3rd person present singular
1. send unwanted e-mail: to send an unsolicited e-mail message, often an advertisement, to many people
2. post unwanted electronic messages: to post a message many times to a newsgroup, or an inappropriate message to multiple newsgroups

Let’s see… words that stand out there – unsolicited, unwanted, and inappropriate.  That describes the piece that I am covering here in this post.

Chase – Threatening to Spam

This was piece of mail that we received at home, telling us that Chase realized that we weren’t on any of their mailing lists and that they were going to start mailing us all sorts of stuff unless we opted out.  Really?  My husband and I each got a copy of this letter – so count the postage on both to be sent out, the paper to print said letter, the trees that were killed unnecessarily.  Apparently one of the guys I follow on Twitter had this same experience:

 

Chase letter: “You are not being mailed any of our product spam. Circle the products you DO NOT want to receive by mail, sign & date.” #Evil
Nov 02 via TweetDeckFavoriteRetweetReply

Really, Chase, when did it become acceptable to realize you weren’t mailing your customers and figured it’d be good to warn them that you’d be mailing them if they didn’t opt out?  Rather than taking that approach, why couldn’t you have said, “We have {such and such services}.  If you’re interested, please fill in the circles of those you’re interested in.”  Sad state of affairs when you’re forcing people into your programs and making them opt out rather than taking the opt-in approach.   Customers really don’t appreciate that kind of business.