Upgrading to npm 3 or 4

As part of writing a post on getting Angular 2 working with ASP.NET Core I needed to upgrade to npm verson 3. All went well on my main machine, but when I tried it on my laptop things didn’t go so well. No matter how many times I ran npm install -g npm the version returned via npm -v always returned 1.4.9.

After a bit of googling I came across this post on Stack Overflow. The post also points to npm’s github wiki on the upgrade process which can be found here. I am going to go over the option that I used to get my laptop upgraded.

Open an administrator command prompt and navigate to the install directory for nodejs. This should be either C:\Program Files (x86)\nodejs or C:\Program Files\nodejs and then run npm install [email protected].

Now if you run npm -v you should see a 3.x version of npm.

npm 4

Since writing this npm 4 has come out. The above should still apply if you find that npm is stuck as a previous version. Check out the npm release notes page for details.

Visual Studio 2015 Team Explorer Fails to Undo Changes Using Git

At times I will make some quick changes to a project in Visual Studio to try something out knowing that I will undo the changes when done. Most of the time this works great with no problems, but a few times I am unable to get Visual Studio to undo the changes. Fist I am going to review the steps I normally use to undo and then I will cover the steps I use when files refuse to be undone. Just to be clear I am using Git base source control.

Normal undo changes

Normally when I am ready to undo a set of changes I open the Team Explorer window and select Changes from the drop down at the top of the window. Next I right click on the file, files, or directory I want to undo changes on and click Undo Changes.

undochanges

This show a message box asking for confirmation before undoing the changes. Click Yes to undo the changes.

undochangesyesnomessagebox

If all goes well the select files and/or directory will have reverted and no longer have any changes.

Undo failed now what?

If you undo didn’t clear the changes as expected now what? Well the best answer I have found is to open a command prompt and navigating to the directory that contains the file that needs to be undone and then run the following command. In this example the changes to gulpfile.babel.js  will be undone. This will work for both added and changed files.

git checkout gulpfile.babel.js

If you want to undo all the changes in a branch it takes a couple of commands. This first command will remove all changes to tracked files including staged files.

git reset --hard

Next if you have any files that were added (or not already tracked by Git) the following command will remove them.

git clean -f

Your repo will be back to its starting state as if it had just been cloned.

Caution

When using the above commands be careful as any changes will be gone and Git will have no record of them. For added files the file will be removed and again Git will have no record of the file. This mean these operations are permanent and should be used with a great deal of caution.

Change from Bundle & Minifier to Gulp in Visual Studio

When ASP.NET Core 1.0 was released Microsoft switched gulp for Mads Kristensen‘s Bundler & Minifier. This post is going to cover taking a project that is using Bundler & Minifier and change it to use gulp instead. Don’t take this as problem with Bundler & Minifier I am just more familiar with gulp and didn’t mix in another new tool.

The extension

There is a Bundler & Minifier extension available that make the change to gulp super simple. You could do all this yourself, but the extension seems to be the fastest way to convert without having to worry about htting. Click the Tools > Extensions and Updates menu. Then in the Extensions and Update dialog on the left select Online. Next on the top right enter “bundler & minifier” in the search box. Then click the download button next to Bundler & Minifier and follow the prompt to install and then restart Visual Studio.

ExtensionBundlerMinifier

The conversion to gulp

Right click on your project’s bundleconfig.json (this is the file that is used to configure the default bundling and minification stuff) and select Bundler & Minifier > Convet To Gulp.

converttogulpmenu

This will show a warning dialog saying that the process will take a few minutes due to npm restores, etc. When the process is done you will now have a gulpfile.js file. The gulpfile.js file that is created will require bundleconfig.js in order to expose your existing tasks.

Required edit to bundleconfig.js

Since the generated gulpfile.js is using the existing tasks in bundleconfig.js all the comments must be removed from bundleconfig.js before gulp will work properly. This is due to comments not being valid json and the parser that gulp uses sees the json as being invalid. The following line exists in the generated gulpfile.js, but it is easy to miss so I wanted to call it out.

bundleconfig = require("./bundleconfig.json"); // make sure bundleconfig.json doesn't contain any comments

Wrapping up

package.json is the other file that got created during this process. If you are doing this manually don’t forget this file. I had tried this conversion manually once before and I am pretty sure this file is the reason I was not successful.

As I stated above I went the route of the extension so I wouldn’t miss anything and it worked out well. Now knowing what needs to be changed I could do it manually, but the extension works so well I recommend using it.

Thanks to Jon Galloway as I first saw this process at one of his talk at Code on the Beach.

Add Git Ignore to existing Visual Studio Project

Last week I mentioned adding a .gitignore file to keep a configuration file from causing issues across machines. Visual Studio make it super easy to add, but the next time I made a change to the project the configuration file showed up in my changes again. Turns out that if Git is already tracking a file adding it to the ignore file will not do anything. I am going to walk through adding an ignore file and then cover the one of the processes that can be used to stop Git from tracking files that are in your ignore file.

Using Visual Studio to add a .gitignore file

Inside of Visual Studio open the Team Explorer window. If you don’t already have it open use the quick launch in the upper right hand side of the window to search for it. If it is not already on the Home page click the house icon in the top of the Team Explorer window.

TeamExplorerHome

Click the settings option.

TeamExplorerSettings

Then click Repository Settings.

TeamExplorerRepositorySettings

Now click the add link next to the Ignore File description. This will add the .gitignore file will all the defaults set for things that should be ignored. You could add the file manually, but then you would not get the nice set of default values. If you do decide to add the file manually this repo contains all the defaults that should be ignored for a project using .NET/Visual Studio.

Now that the file exists check it in.

Stop tracking files that should be ignored

To stop tracking the files in the ignore file open a command prompt and navigate to the directory that contains your solution file (.sln) and run the following commands.

git rm -r --cached . 
git add .
git commit -am "Remove ignored files"

That seemed to do the trick for me. The git commands I found here. If you click on that link you will see there are lots of options on which commands to use for this process. If the above doesn’t work for you one of the other answers should meet your needs.

In the future I will be making sure my ignore file exists first just to avoid any issues.

Conference Retro

The last few weeks have been extremely busy for me. I had the pleasure of attending both Code on the Beach and Music City Code over the last couple of weekends.

Code on the Beach

My employer was very kind and sent my whole team to Jacksonville, FL for this event. One of the neat thing about this event is that is fairly small number of attendees. There were less than 300 or so people present. The speakers were awesome with surprising number of them who speak on a national level. Just to name a few I got to see Scott Hunter, Jon Galloway, Jeff Fritz, Kathleen Dollard, Stacey Mulcahy and David Neal.

I have not been to a ton of conferences, but Code on the Beach had the best schedule I have seen by far. There were four sessions to choose from in each time slot and the number of time slots didn’t exceed six. For me this was great as it didn’t overload me with choices. There was also couple hour break in the middle of the day for lunch and a little beach time. The break really help give my brain a rest and made it easier to stay engaged for the afternoon sessions.

If you can work it out I highly recommend getting your whole team out of town for a conference. I feel like the team getting to spend time with each other outside of our normal environments was a huge benefit. The team building aspects this trip were well worth the cost.

Music City Code

This year was Music City Code’s (MCC) second year and it takes place in my home area of Nashville, TN. The event has expanded a lot since last year going from a single day event to three days and from 250 attendees to 500. Since this event is only in its second year I was expecting to see mostly speakers from the areas around Nashville, but the speaker pool was much more diverse than I was expecting. Some of the people I got to see speak include Christina AldanHeather Wilde, David Neal, Jeremy ClarkJoel Tosi, Paul Jones, and Scott Drake.

MCC had a schedule more like I was used to with a lot of choices per time slot. The downside of that of course is that a lot of times I wanted to be in multiple places at once. One of the really neat things about this conference is during lunch they have a band playing and want attendees to get on stage and play or sing with the band.

This was something I choose to attend myself and only one other person from my company was there. Since I was not there with a team I met more people than I would have otherwise. I know above I recommend going to a conference with your teams, but I am also going to recommend going to a conference without your team in order to get to know people you wouldn’t be interacting with if you were surrounded by your teammates.

Positives

Conferences have tons of positives. Leaning about new technology is a lot of peoples top reason for attending and it is a great benefit, but not the top one in my option. For me the best part is the interactions with my teammates and people from the broader community. Not only does the interactions with people open the door to new friendships, but it also means getting to hear about the gritty parts of actual implementations of different technology. That is not to say that speakers only tell you about the good parts, but talks have time restrictions and don’t leave enough time to cover all the potholes a particular technology has.

Exhaustion

As great as both conferences were I am happy to have a weekend back with my family. Two weekends away from them was hard. I am not used to travelling which that added to my exhaustion. I have more empathy for how much of a challenge it is for people who are required to travel a lot.

Thank You

I am going to end this post with an open thank you to conference organizers, speakers, volunteers and attendees. Without every ones time and effort great events like Code on the Beach and Music City Code would not happen.

Motivation

The Problem

I am sure I am not the only one to have struggles with motivation. One of my goals is to write at least one blog post a week, but some weeks getting enough motivation to do the required prep work and then write the post is hard. Some weeks personal things come up, other weeks medical, some weeks work is more challenging than normal. The list could go on and on as you all well know.

The Present

Take this week for example I had an idea in mind for a post and worked on a project to test the idea out for most of the week without any success. As the week passed and I was no closer to finishing the project my motivation levels dropped rapidly. I found myself more interested in reading How To Win Friends and Influence People for the second time than working on the post for this week.

Life will always throw us curve balls and plans will need to be adjusted. It feels like life has been nothing but curve balls over the last few months which has drained my inventory of posts. The last few weeks every weekend I am in a mad rush to get a sample done and get the associated write up finished before publish time. The stress of this rush every week has added to my decline in motivation.

Some Help

The question is how to prevent and/or get past a lack of motivation. I was catching up on some of John Sonmez’s YouTube videos when I came across The Secret Sauce For Continuous Motivation in which John addresses the issue keeping motivation levels up. The gist of the video is to always have a something that you are making progress on. I think John is on to something with this line of thinking. Without making progress on some front it is much easyer for negative emotions to pile up and make it feel like progress is impossible. If I had another project I could switch to that I know I can make progress on it would have provided some relief after hitting a wall.

The Future

In order to address this I am going to come up with a better plan with time boxes on how long I can spend on a particular project. This will allow me to switch to more productive projects if I hit a wall. I am hoping the time boxes will also remove some of the negative emotions associated with having to drop a project. Dropping a project will move from being a failure to being part of the plan while leaving the option to come back to the project at a later date.

In order jump start my progress I am going to go back and revisit some of the basic introductory topics I have covered in the past. Those have been some of my most popular posts and now that ASP.NET Core has released and Aurelia and Angular 2 are at the RC stages I feel there is value in revisiting those basic topics.

Some Encouragement

I am going to leave you with this video from John Sonmez that I found encouraging. You may find it corny or something, but John has personally replied to some emails  and I know he does that for thousands of people. Without his book and blogging course I would have never started this blog. It is nice to know that there are people out there who are willing to spend their time to help and support others. Where do you go when you are needing some support?

Books, Podcasts and Other Resources

It is time for another experiment. This week I am going provide a list of some of the resources I use to keep myself up to date in the development world. Please leave feedback on if you feel like this is helpful or with some of your own resources. I am intentionally keeping the list short to give a good starting point without being overwhelming.

Books

Soft Skills: The software developer’s life manual by John Sonmez – This is the book that finally got me motivated to create this blog.
Clean Code Collection by Rober C. Martin
The Pragmatic Programmer: From Journeyman to Master by Andrew Hunt and David Thomas

Podcast

.NET Rocks hosted by Carl Franklin and Richard Cambell – .NET plus other topics
Hanselminutes hosted by Scott Hanselman – Great mix of people and technology
nashdev check out the website for a host list – Programming related topics by local Nashville developers

YouTube Channels

Simple Programmer by John Sonmez – Soft Skills & general life advice for programmers
ProCoder by Jerrie Pelser – Web tech and tools
ASP.NET Community Standup by Scott Hanselman, Damian Edwards and Jon Galloway – Latest information straight from the team doing the work

Twitter

Scott Hanselman
Damian Edwards
Jon Galloway
Steve Smith
Rick Anderson
David Fowler
Jerrie Pelser
Scott Allen
Seth Juarez

Twitter tends to be the place I find interesting articles to read, but I often don’t have time to read them at the time I find them. It combat this problem I used pocket along with IFTTT so that anytime I like a tweet with a link in it the link get saved to pocket. Then when I have time I can go through pocket and read the articles saved from Twitter. This is the IFTTT recipe I am using for this functionality.

A Year of Blogging

Tuesday will mark one year since I made my first post on this blog. I don’t normally do a lot of nontechnical posts, but this will be one of the exceptions.

The Build Up

Over the years I had heard numerous people such as Scott Hanselman  and Cory House recommend blogging and community involvement in general. As I mentioned in this post I have been making an effort to be move involved with the community in the Nashville area over the last couple of years, but had up until this point ignored the advice to start a blog.

This started to change when I read John Sonmez’s book Soft Skills. John’s book really started make me feel the push to create content not just consume it. After reading Soft Skills I signed up for John’s free blogging course which I read, but didn’t take action on. After the course was done John continued to send the occasional blog related email one of which I finally got me to take action.

The Beginning

My first challenge was deciding on a topic area to focus on and I decided to go with ASP.NET. My first post LocalDB v11.0 or MSSQLLocalDB came from an issue I faced when trying to get started with ASP.NET. I remember pushing publish on that first post and being worried about people might say or what mistake I might have made that someone would use rip me to pieces.

What actually happen was nothing. The first few months I basically got no traffic. I had told almost no one about this blog and was not doing post notifications to Twitter.

ASP.NET 5

As I got more in to the world of ASP.NET I came across the beta releases of ASP.NET 5 (now ASP.NET Core) and this became the source of a lot of my entries. I really enjoyed doing entries that provided a guide from one beta to the next. The migration entries are also when I started to feel that I was providing some value to the community.

Exploration of ASP.NET 5 lead me to try Aurelia and Angular 2. This also lead to some exploration of gulp, systemjs, jspm, etc. There is so much to learn, but that is the great thing about being in software.

The Next Year

I am excited to see what the next year brings. ASP.NET Core will hopefully get updated release dates soon and along with that will come the .NET CLI. Both Aurelia and Angular 2 are moving forward toward release. There is never a shortage of things to learn!

If anyone has an topics they would like to see covered drop me a comment. Thanks for all the support over the last year!