Sort System namespaces above others while using namespaces in C# / Publish Single Item in Context Menu

I've seen floors split smithereens while developers drag daggers including brothers taking opposite sides mainly because of code review comments. You say it always happens?


Never mind. Just wanted to begin the blog with some kind of starting note! 

This blog article is with regard to removing unused namespaces as well as sorting those alphabetically. Even when you sort, you usually want to keep the system namespaces on top while sorting others below. 

I keep forgetting how to do this so, I decided to blog it since my grandma used to say this: if you want to remember something, write it and if you don't want to forget, practise it once  and you won't forget for life!


So, I decided to do both together! I always forget how to sort system namespaces on top of other namespaces in c# code. 

So, here is the setting in Visual Studio:

Tools > Options > Advanced > Using Directives > 

Click the option - Place 'System' Directives first when sorting usings

Press OK button

That's it


Next time, when you sort usings in Visual Studio, the sorting will follow the set rule!


Now, Don't blame my grandma if you forget this the next time!

****************************************************************

Publish Single Item in Context Menu:

Are you unable to publish single items like JS and html/cshtml views. Or, in other words, you don't find the context menu option  on right clicking the item?

Then, the possibility is that you haven't created a local publish profile. So, create a local publish profile to the local webroot folder and check for the context menu option.

If you don't have a local publish profile or the pubxml file, you won't be able to publish individual front-end assets through Visual Studio:



Comments

Popular Posts