Best way to get power to stair lights
By definition an extension cord is a flexible cord and is covered under NEC Chapter 400. NEC 400 will tell you a flexible cord is not approved as a permanent wiring system. In the strictest interpretation of the NEC the minute you secure a flexible cord to a dwelling with just one staple or other permanent method, it becomes part of the permanent wiring system. 

So NO you can't use an extension cord to connect to your light fixture as you have described.

You can only use a permanent wiring system that is approved for running in an exposed area and all of those methods and materials can be found in NEC Chapter 300.

No need to answer the related question.

Good luck.