Why does RTVS open Notepad?!?

For the past few weeks, I’ve been going through the Mastering Software Development in R specialization on Coursera.  After Matthew Renze mentioned R Tools for Visual Studio (RTVS) during his workshop at CodeMash, I had to see what this was about.

As I have been going through my courses – which use swirl() – I have been looking at how things work, comparing RStudio to RTVS.  One of the things that was maddening for me was going through one of the courses in RTVS and having R files open in Notepad.  Notepad?!?  RStudio wasn’t doing this, so I was even more frustrated.  I could also open R files with Visual Studio right from the file system, so the file association was already in place.  This didn’t make sense.  However… RTVS is an open source project, as is swirl().  So I spent tonight looking at code in GitHub.

After poking around swirl(), I found something that led me to try the following command:

getOption("editor")
[1] "notepad"

Wait… how?! Why?!  Poking around some more, I realized that R has its own profile file – similar concepts to the PowerShell profile file and the bash profile file.  I found this post on Customizing Startup (Quick-R) leading me down the right direction.  With a bit of trial and error and finding this closed issue in the RTVS repo, I moved my .Rprofile file to Documents, and RTVS was happier.

Before changing the editor, I wanted to make sure that I could call the editor – so that when I change it, I could make sure it changed.  This is the command I tried, with the sampleTest.R being in my working directory:

edit(file="sampleTest.R")

Sure enough, this loaded my sample file in Notepad.

Using the sample Rprofile.site file from the Quick-R site as a guide, I edited my default editor to the full path to Notepad++.  This looks like it could be the right direction.

Calling the same command from above:

edit(file="sampleTest.R")

Now this loads in Notepad++, which means I have syntax highlighting.  (I would have pointed at Visual Studio Code, but I’m on the one laptop that didn’t have it installed just yet.)

Next goal: How to tell the R Interactive to open the R files in the current instance of Visual Studio….

Microsoft ♥ Linux and Open Source

A long time ago, when I was much younger, I used to see Microsoft as this gigantic, unapproachable power that was popular in homes.  I saw Linux as this operating system that truly hardcore geeks played with, geeks who were anti-social and more like hackers.  This was my misperception as a youngster.

As I got older, my friend Nivex introduced me to Linux – a friendlier, gentler idea than I had perceived.  Sure, I may have had to compile my kernel and install the distro quickly on my own since I kernel panicked in a record amount of time.  But Slackware Linux… it was still totally hardcore in my mind, hardcore and made me wonder “why was I trying to learn to work with an operating system that I felt was out-of-my-league?”

I also saw the flame wars and vitriol in the Linux community whenever Microsoft was mentioned.  Seeing the immaturity of that community steered me away from that.  For a community that embraced open source, they were closed minded, not open-minded.  It wasn’t something for me to dabble in, community-wise.

However, as time has gone on, I have continued to use both operating systems while staying on the mindset that one day they may come close.

Running .NET on Linux

Fast-forward to 2008/2009… I had caught wind of the Mono project.  Mono is an open source implementation of .NET that would bring .NET technologies to Linux, or so they claimed.  I didn’t believe it – Microsoft technologies on Linux without being in a Windows emulator… this idea just wasn’t computing.  I had to try it out for myself.

Being the polyglot that I am, I also heard about running non-Microsoft languages on top of .NET – specifically IronRuby and IronPython.  Again, mixing Microsoft with communities that aren’t typically friendly of Microsoft… I was skeptical of the idea and had to see it myself.

So what did I do?  Since Ruby has a stronger community than Python in Cleveland, I decided to take the road less traveled and venture down exploring IronPython.  But wait… Mono does .NET on Linux, and python runs on Linux…. could IronPython run on Linux?

PyCon 2009 – Showing IronPython on Linux

In my adventures of clearing up my skepticism, I had fun playing with IronPython and learning how to work with it on Linux.  Somehow, I decided it was a good idea to submit a talk to the national Python conference – PyCon – on running this.  What I hadn’t known was that the IronPython team and the father of the language (Jim Hugunin)  would be in my audience.  To this day, I remember this presentation experience clearly – from Jim taking over the Q&A session (politely!) and then waiting for me after my talk to tell me that it was cool to see since Microsoft didn’t let him play with Linux at work.  These are my slides from that conference:

So there I was, in 2009, showing that the community was wanting Microsoft technologies to be cross-platform and friendly with other languages.  But… it was truly at the community level.  Corporate marketing wasn’t there.  So Microsoft had to rely on polyglots and adventurous devs like me to help draw attention to this move.
Fast Forward to Today
Microsoft has come a LONG way since then.  They had CodePlex for their open source projects, but thanks to listening to the community, they have moved from CodePlex to GitHub.  They have moved a lot of their .NET functionality to the open source realm – check it out on their .NET Foundation repos website.
Mono has grown since then with more support and more ported libraries than it did back then. It is compatible with .NET 4.6, .NET 4.5, .NET 4.0, .NET 3.5, .NET 3.0, .NET 2.0, and yes, even .NET 1.1.  Check out Mono’s compatibility documentation for more details.
Microsoft is playing nicely with Linux.  In 2014, OpenShift mentioned that you can run Microsoft .NET apps on their platform.  Mark Russinovich reached out to the Linux faithful to encourage them to send in their resumes – they want to work with people who want to help the two come together.  Microsoft just announced a partnership with Red Hat  for cloud solutions.  Check out this demo of Microsoft .NET over on OpenShift:
They also are encouraging developers to write code for multiple platforms and adding tooling for this. With Visual Studio 2015, Microsoft brought in Visual Studio Tools for Apache Cordova.  Through this tooling, we can use Visual Studio to write apps for iOS, Android, and Windows via web .  They’re also getting their tools cross-platform, with the introduction of their code editor called Visual Studio Code – which can run on Windows, Linux, and Mac.  Visual Studio  Code has syntax highlighting for a variety of languages.  Below are screenshots of Visual Studio Code with Python, XML, and Java files:
java-vscode
Java in Visual Studio Code
python2010-vscode
Python in Visual Studio Code
xml-vscode
XML in Visual Studio Code
Conclusion
Youngster me thought that maybe one day Microsoft and Linux would get closer together and may one day play nicely.  However, I had no idea it would get to where it is today.  Microsoft has made great strides to get here, and I can only imagine where it will be going in our future.  Youngster me is very teary-eyed and proud of Microsoft and where it’s been going.

The One Code to Rule Them All

I’m at the Microsoft MVP Summit this week, which means that there are a lot of things I won’t be able to share due to all sorts of non-disclosure agreements, lawyers, etc.  However, there may be some cool non-NDA stuff that I’ll be able to share as well, and you can bet that if it’s that cool, then I’m telling you guys about it.

While checking out some work that MVPs and Microsoft has done, I came across this gem: Microsoft All-In-One Code Framework.

So, Sarah, what’s so cool about this?

Have you ever had a moment while coding when you wondered “How do I do {xyz}?”  Sure, you may have looked up that in your search engine of choice.  However, if you have Visual Studio 2010 or Visual Studio 2012, there’s an add-in for you that lets you search a code repository of various samples.  If you’re more of a “Let’s look at code samples and maybe get inspired” kind of person, their Sample Code Browser is a great app for that.  The VSIX for the Visual Studio extension and the ClickOnce for the app are both available from their download page.

Let me get this straight. Someone did something cool with a code repository?

Yes! Here’s a look at what I downloaded just this morning from their site:

OneCode

 

While the menu and layout remind me of my nemesis – the Zune software, the content is helpful.  Also, I have a good feeling that there’ll be even more features, as talking with these guys, I gathered that they are open to feedback and would love to see this take off.

That’s pretty… but where’s my Visual Studio Add-In? I know I installed it here somewhere…

Once it’s installed and Visual Studio has been restarted, you’ll see a toolbar that looks like this (minus the search criteria):

OneCodeAddIn

 

Okay… not so confused anymore.  Show me how you find stuff for graphs, since you hinted at it above.

 

Now, let’s say you’re working on a project that uses graphs.  Business people like seeing data in charts and graphs, so we better do an app for them.  In my add-in, I typed graph and pressed Enter, which opened the following results:

OneCodeGraphSearch

 

180 results is a lot to sift through!  Let’s filter these so that I’m only looking at HTML5 stuff, as this client is trying to target multiple platforms and thinks HTML5 might be the way to do it.  Click in the box, and the filtering selections appear.  I’m changing my Technology to HTML5.  Much smaller!

OneCodeGraphSearchHTML5Filter

 

 

Let’s take a look at a sample and what it has to offer.  I’ve chosen the top one.

What are the details, documentation, and social about?

I’m getting there!  First off, the details section:

OneCodeGraphSearchHTML5FilterDetails

 

This section contains a link to where I can find the app.  You can see what technologies are supposedly used, the license, the supported Visual Studio edition(s), the author, ratings, last update, and download count.  If you click that download button, it’ll download the sample and change to an open button.  Clicking that button will open the sample in Visual Studio.

The documentation panel shows any documentation that is associated with the project.

OneCodeGraphSearchHTML5FilterDocumentation

 

This shows any important information the creator included for their project.  In this particular case, we see the software that’s required plus a note on unblocking the ZIP file.  Helpful information indeed!

The social panel shows any social media activity for that project – currently tracking Twitter, Delicious, Digg, and Facebook.

OneCodeGraphSearchHTML5FilterSocial

 

As you can see, I Tweeted about this, as it need a little love.

Okay… I don’t care about graphs. I went back to the pretty home screen and was seeking some inspiration.

Me too!  I’ve been getting rusty on my SQL skills and figured I could use some inspiring in that department, so I clicked on the SQL Server button on that page.  That in turn took me to these results:

OneCodeSQLServer

 

So now I have samples to help inspire me.

You mentioned they’re open to feedback.

Yep!  Click the Sample Request Service link at the top, and then click the bright red Submit a Request button.  This will take you over to their Codeplex Issue Tracker, where you can submit your suggestions.

Okay… this is nifty! But… Zune software style seems old school.  I’m running Windows 8. Can I use this on my tablet?

Ah yes… if you do a search for “All-In-One Code Browser” on the Windows Store, there’s a beautiful version for the Windows 8 {Metro UI/Windows UI/”fancy tiles that need a better branding name” UI}.

OneCodeFrameworkWindowsStore

This Sample Browser app has a nice user experience, inline with the new tablet-esque/tablety user experience.

More on that in a future blog post…  did I mention I’m at the MVP Summit?  Gotta eat breakfast for the big day ahead!  Hopefully will blog about Sample Browser later.

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.