I’m running lots of Angular 2 using the CLI on OSX (and loving it).
I have one small issue…
Often after stopping the app, when re-running it I get
‘Port 4200 is already in use.‘
Here is a little linux magic for you:
lsof -t -i tcp:4200 | xargs kill -9 | ng serve
This will find the process using port 4200, kill it, then re-serve your application.
(Posted for my FireBootCamp students that are having this issue.)
http://tv.ssw.com/6628/asp-net-5-de-b… The change from ASP.NET 4 to ASP.NET 5 brings a whole lot of awesome to web development, but it’s the biggest change since MVC was introduced and the learning curve is massive.
SSW shipped 2 enterprise apps on ASP.NET 5 while it was still in Beta (wow, that hurt).
Don’t spend weeks trying to understand how to get your new project right.
This session isn’t just ‘hello world’, it’s the stuff we wish we’d known in those first head-scratching weeks.
Continuously deploying from GitHub to Azure should be easy. In this video I discuss 2 issues I found when deploying an API using ASP.Net 5
Here is what I was trying to do:
- I had a simple ASP.Net 5 Web API project.
For this demo, I just went file | New and chose the Web API Template for an ASP.Net 5 project
- I checked it into GitHub
- I went into Azure and created an API app (I could do the exact same demo using a Web App)
- Then I went in and configured continuous deployment in the Azure portal
It should have been simple…..
There are two issues:
#1: Even the most basic ASP.Net 5 project requires at least a B1 Azure instance size. For Free and Shared instances, there will be insufficient space for the build, even though they give you 1 GB of storage.
#2: If you want to successfully deploy an ASP.Net 5 project, even if it doesn’t require the wwwroot folder, you need to include it for Azure to recognise the project as an ASP.Net 5 project that needs to be deployed.
i.e. even for a pure web API project that serves no static content. If you don’t have a wwwroot folder the project won’t be published to Azure, the repo will just be pulled… then the app won’t run. (the project.json webroot setting appears to be ignored)
For the Microsoft Team:
- #1: I would like to be able to create a simple ASP.Net 5 API or Web project and continuously deploy it to Azure via GitHub.. and have it work on the Free instance size.
- I think it is important for developers interested in Azure to have the freedom to experiment without worrying about getting charged
- This may involve expanding the size of the free tier on Azure, or maybe it means making some exceptions about what is counted towards the 1 gb of storage…. but we want a frictionless entry to continuous deployment of ASP.Net to Azure
- #2 The second thing I really want to see is a few more smarts around how we identify if an application is a .Net app and if it needs to be pulled straight into Azure from GitHub, or wether it needs to be compiled and published. It appears at the moment it is looking for the existence of a wwwroot folder to make the decision. Suggestion: should we be checking for the existence of a project.json or a hosting.json and then checking for the webroot setting to assist in this determination? similar to the work being done on default logic around the webroot https://github.com/aspnet/Announcements/issues/94
ASP.NET 5 (formerly known as ASP.NET vNext), along with .NET Core, is Microsoft’s ground-up rewrite of the .NET Framework. It is designed specifically for modern cross-platform web-application development and involves a number of breaking changes and new concepts that the .NET developer will need to be aware of.
While everyone is making the move to MVC 6 (and it is pretty awesome), not everything is there yet.
Until it works out of the box, here is an easy way to wire up your MVC 6 project to log all exceptions to Application Insights.
Create the Application Insights resource via the Azure Portal
- Sign in to the Azure portal, and create a new Application Insights resource. Choose ASP.NET as the application type.
A resource in Azure is an instance of a service. This resource is where telemetry from your app will be analyzed and presented to you.
The choice of application type sets the default content of the resource blades and the properties visible in Metrics Explorer.
The key identifies the resource, and you’ll install it soon in the SDK to direct data to the resource.
Create the Exception Filter to log all exceptions
Figure: Add the ApplicationInsights.Web NuGet package
Figure: Create the Telemetry class to instantiate an instance of the TelemetryClient with your InstrumentationKey & the AiHandleErrorAttribute class that will log exceptions to Application Insights.
Figure: Wire up the ExceptionFilterAttribute in Startup.cs
I L.O.V.E. developing on my 15” MacBook Pro, but I had some fiddling to get it just right.
Here is a quick post about how I have it configured.
– Software: Parallels for Mac (I intend to check out VMware Fusion when I get some time.)
– I don’t use a BootCamp partition.
If you run Parallels from a BootCamp partiton you lose the ability to take snapshots, which I love.
In the future, when working more with mobile emulators, I might find that I need to boot natively into Windows and change to working from a BootCamp partition.
Figure: I allocate 8 of my 16Gb of RAM and 4 of my 8 ‘virtual’ CPUs because Visual Studio is still awesomely fast, and I often use the spare Ram and CPUs for other VMs (e.g. for testing older browsers)
Figure: My sharing settings.
The ‘Shared Profile’ setting determines if you integrate Windows into OSX. I don’t enjoy this experience at all.
Tip: Install DropBox on OSX, not in Windows and then tick ‘Shared Cloud’
As always, I love feedback and suggestions.
I get asked a lot about the secret to the success of FireBootCamp, and how we get such great results from our intense developer training.
The SSW.TV team kindly put together this collection of behind-the-scenes footage.
If you want to see more of the actual bootcampers in action during sprints 1 and 2 check out the following (more serious) videos
And here are the highlights from graduation day
I seriously love my Windows Phone… except for the availability of apps.
Making Visual Studio the best environment for multi-platform development will be key to the success of Windows Phone. If developers that need to build IOS and Android apps move to Visual Studio from the native options in order to get cross-platform compatibility, they are far more likely to ship Windows Phone apps as well.
Here is a very brief overview of the options for creating cross-platform applications in Visual Studio. If you aren’t across these options already, you should get reading. This is way forward!
Stay tunes, I’ll be writing a lot more about each of these options.
Option 1: Cordova for building web based cross platform applications
Watch Out: It takes effort and know-how to make these apps slick on underpowered, occasionally connected devices.
Option 2: Xamarin for building native cross platform applications
Build apps for iOS, Android & Windows Phone by writing all your common code in C#, and then building separate native User Interfaces for each platform.
Great Because: You get the full native experience on each platform
Watch Out: You need to build a separate UI for each platform
Option 3: Universal Windows Apps
Build apps that will run on Windows Phone, Windows 8 & XBox.
Great Because: The Windows platforms are converging. This is great news for Windows Phone.
Watch Out: You don’t get IOS or Android support.
This is what I consider to be my list of ‘essential’ tools / skills for a serious .Net developer.
An Agile or Lean methodology
If your projects are not being delivered successfully Scrum will either enable you to start delivering software, or highlight the reasons why you aren’t.
The Scrum Guide which contains all the rules of Scrum is 13 pages long. There is no excuse for not having read it.
If you aren’t doing Scrum, or you aren’t doing it well… get some help.
Out of the box, it gives you so much. I find it incredible how many people have TFS but are only using it for Source Control.
Learn both Team Foundation Source Control and Git, and the strengths of each.
Work Item Tracking
Being able to successfully deliver value to the customer while triaging bugs requires efficient work item tracking processes and tools.
Why-oh-why isn’t everyone doing CI?
Check in your code, have a magic fairy build it, test it and tell you if you’ve broken anything – sounds too good to be true AND it only takes 60 seconds to setup!
‘Fail Fast’ is probably my favourite development catch-phrase: If you find out that the code you’ve just checked-in conflicts with some-one else’s code 2 minutes after you’ve checked it in, it’s easy to resolve the issue. If you only find out there is an issue a week later, it’s much harder.
Get your CI fairy to take the code she builds and then deploy it to a server for you.
If every time you finish a task you can send the user a link to the test server that you just deployed to and say ‘tell me what you think’. The customer will LOVE you… and you get feedback when it’s most helpful.
If you are using Azure, continuous deployment is just so damn easy.
Also, I am having a little love affair with a tool called Octopus Deploy http://www.octopusdeploy.com. Check it out!
As a .Net guy… you need to be familiar with Azure.
It’s remarkable how easy it has become to build and deploy web applications to the cloud. In 30 minutes I can create a source code repository on http://visualstudio.com, check in an MVC project and have it continuously deploying to an Azure website with both Release and Staging environments.
Check out Andrew Coates from Microsoft doing continuous deployment to Azure at FireBootCamp.
Azure is so much more than just websites… but as this is a ‘need to know’ list, I’ll force myself to not go on about how awesome Azure VMs and Web Roles are. If you take an interest in the cloud, Azure is a platform that will have you boring all your friends with tales of how cool it is.
Communication and interpersonal skills cannot be overemphasised. No matter how smart someone is, you don’t want them on your team if they can’t work as part of the team.
- You need to know how to take instructions
- You need to know how to provide feedback
- You need to know how and when to push back, and when to give in
- Sometimes, you just need to shut-up
Patterns, Practices and Principles.
This is the stuff I’m REALLY passionate about.
Building a complex application, that is still going to be maintainable after you have added features to it for several years requires some skills. My mission is to increase the understanding amongst .Net developers that the following are essential, not hard to learn, will improve your job satisfaction and your employers opinion of you when you continue to add value to his application well after other projects have ground to a halt.
This is not about swapping your SQL Database for an Oracle one!
There are many, many benefits to Dependency Injection: Here is the major one for me – you need dependency injection to ensure that your complex system is built in such a way that changes to one module does not cause flow on effects in other modules.
Typical on many projects: first 10 features get thrown together in a week, the next 10 features take 2 weeks, the next 10 take a month, and then every subsequent feature takes longer and longer because of the changes that need to be made throughout the project to implement the new features.
Dependency Injection is about ensuring you can continue to add features to your complex project.
Essential Reading: Dependency Injection in .Net by Mark Seeman
I’m not a code coverage guy. I don’t believe every single line of code needs a unit tests.
I believe the following
You NEED to be able to write great tests.
Your application should have unit tests over 100% of the code that requires unit tests.
This is a topic that I can (and do) talk about for hours, but in summary:
I write tests
- for fragile code, or code that is likely to break
for important code that you cannot afford to break
for code that is hard to read: Well written unit tests are the best form of documentation after well written code.
when writing the test provides me clarity about the code that I am about to write (slipped my TDD hat on there for a minute)
- When writing a unit test will save my boss money because it’s faster than the (damn) debugger
One of my favourite rants: It is often faster to write a unit test than to test the code you have just written any other way.
I see this a lot and it drives me crazy: I’m testing the credit card validation of my online store. I want to test the submitted card number against a regex before I submit it to the Bank.
Debugger Guy: I hit F5, wait for the whole solution to compile, the website to spin up and the debugger to attach. I then select several items to add to my cart, click next, enter my name, phone number and address, click next, enter the credit card number and click next, realise there is a typo in the Regex, click Stop, change one character and press F5 again ! aaaaaarrrrggghhh !
Unit Test Guy: Writes a 5 line unit test in half the time it takes Debugger guy to even reach the code, gets feedback in milliseconds, provides great documentation about what the regex is validating and ensures that changes to the code in the future do not invalidate the current requirements.
Essential reading: The Art of Unit Testing by Roy Osherove
My session on unit testing: Eat your vegetables! Baking Healthy Projects with Unit Testing and Dependency Injection
Common patterns like Repository and Unit of Work
Patterns are important.
They provide a way for developers to communicate about common problems and suggested solutions.
I hate to re-invent the wheel when smarter people have already come before me and done most of the heavy lifting.
Familiarity with common patterns (the good and the bad) is essential to any senior developer.
Clean Code & SOLID Principles
If software were disposable, I wouldn’t be writing this post.
If I could write software today, and then walk away and never have to look at it again I may not care about the day next year when I have to come back and make sense of it – but I do.
Because I have to maintain my code – I should very much care about making it easy to maintain. This is where the idea of ‘Clean Code’ and the SOLID Principles come in.
Essential reading: Clean Code by Robert Martin
Professional developers should be proud of the code they write.
I struggle to understand why most developers still don’t have a good understanding of the above topics. I strongly believe that these areas should be lived and breathed by every member of a development team.
Once again, you don’t have to always use them… but if you don’t have them in your tool-belt you’re selling yourself as a professional carpenter when you don’t even own a hammer.
I’ve deliberately left this until last.
Although most job descriptions are full of technologies, I believe that knowledge of the topics above are far more important.
Here is the current set of technologies that we use by default to build most of our web applications.
- Frameworks and Toolsets-> we like to keep across what’s out there, and being consultants doing new projects all the time we get to try out different things but our default stack at the moment is
- Twitter Bootstrap
- Telerik KendoUI
I deliver large, high performing web applications for enterprises. The processes, tools and technologies above are what I believe an enterprise web developer needs to know. Obviously other development disciplines require very different skills sets.
In many scenarios other tools, frameworks or methods may be more appropriate, but before you start learning all the alternatives you should know and understand the mainstream choice. Then you are qualified to have an opinion about whether something else is better.
ASP.NET.Identity 2.0 is out, and it adds a bunch of great features.
– Two-Factor Authentication (SMS, Email or custom)
– Account Lockout
– Account Confirmation via Email
– Password Reset
– Sign out everywhere
– Choose your Primary Key type (string, int, Guid)
– IQuerable Users and Roles
– Delete User
– Enforcing Unique User Names
The upgrade was more fiddly than I thought it would be. Here is what I had to do. I hope it helps.
1. Update Entity Framework to 6.1
2: Update all your OWIN components if they already exist in your project.
(Yes. NuGet should handle this for me. It didn’t. Upgrading the Owin components before the Identity packages resolved some issues for me)
3: Update Microsoft ASP.Net Identity Core and then ASP.Net Identity EntityFramework
4: Your model has now been updated to v2.0 !
If you are running Code First Migrations you now need to create a migration to reflect the changes to the database.
Figure: When you try to create the migration, it will tell you that the model backing the db context has changed. To resolve it, you need to update the constructor of your dbcontext.
Figure: Adding ‘, throwIfV1Schema:false’ as a parameter to the constructor will allow you to run the application, and create the required Code First Migration.
Figure: After updating the db context constructor, Add-Migration works as expected.
Figure: You can now inspect the changes to the schema in the Migration.
Now check out the links below to get help on how to implement the great new features in ASP.Net Identity 2.0.
ASP.NET MVC and Identity 2.0: Understanding the Basics
– a great overview of Identity 2.0
Announcing RTM of ASP.NET Identity 2.0.0
– definitely worth reading !
– contains list of features and some upgrade notes