Visual Studio Team Foundation Server :- Tips & Tricks #1-Use of Annotate Feature in TFS

Annotate is a very important feature of Visual Studio Team Foundation Server which most of us ignore while developing our applications and working with the Team Foundation Server.Annotate Feature allows us to see changes which occurred in a particular file with respect to a particular change set.It will show you all the change sets and you can click on any change set to view what exactly it did.This is a very useful feature when you are working in a team and you are working on a particular file and unable to understand what changes your teammates have actually caused in that file.

Annotate feature was not available out of the box in VS2005.It came only when you install the Team Foundation Server Power Tools. After installing TFS Power Tools you have to type the following command to invoke the Annotate Viewer tfpt annotate <path_to_file> But in Visual Studio 2008 Team System with Team Explorer this functionality is built in,if you are working on any team project and want to use this functionality just right click any file and from the menu just choose "Annotate".

After clicking this option the file will be opened in the IDE with the change set numbers stated first followed by whom the change set was triggered and the date on which the change set was triggered.

If you click on any particular change set then this will open the full information about that change set in the above example i clicked on the change set 4424 so it opened the change set information window 4424 for me.

This approach can be very useful if you just want to look at the changes made to that file within the IDE, this comes very handy when you are working on that file and want to see who has modified it and for what reasons and what changes your team members have made.


Visual Studio Tips & Tricks #4:- Adding a new website mapped to IIS

How to create a new website which resides inside your solution folder as a web project but is automatically mapped to the IIS.Benefit  of this approach is that we will be using IIS as the web server to run and debug this website not the Cassinni web server which is the default in Visual Studio.Another benefit is that we will escape the problems caused by the port no's which Cassinni bring by default.Some of us who prefer to use Cassinni can go on with it no probs!!!.But personally i like that each of my website in my project is mapped to a virtual directory in IIS.

Another benefit of creating IIS mapped website's is that when you share you code and other people open the solution then it automatically creates a website on the localhost no need to again map it to open with IIS.So given here is a step wise process along with pictures to illustrate how it is done.

I personally prefer to add a blank solution and then add new website's and projects to it,you can go other way round by choosing to create a new website with the option in Project And Solution in the Options menu in VS2008 to always create a solution for a project or website.By default Visual Studio will not create a solution if you only add a website. More information on how to create empty solutions and solution for only one web project refer to my article https://www.smallworkarounds.com/index.php/2009/02/20/visual-studio-tips-tricks-3-how-to-open/ Now right click on your empty solution or solution to which you want to add the new mapped website.It will ask you few options and there will be  a drop downlist also from where you can select where you want to create new website. iiswebstart So here by default you will have filesystem, so go and change it to  "http" from the dropdownlist and then click browse.This will take you to another selection box where in the top right you will see 3 buttons:- 1.Create New Web Application 2.Create New Virtual Directory 3.Delete So here from these 3 options just select the "Create New Virtual Directory" option iiswebnew Now it will ask your for Alias Name and the Folder,just go and give any name what you want your virtual directory to be named as and the map it to the folder where you have initially kept your solution. iiswebsave Press OK that's it now everytime when you click open your solution, it will check for the virtual directory if its there then well and good if its not there it will automatically create one for you. Happy Programming!!!!


Visual Studio Tips & Tricks #3:- How to open an empty solution

Sometimes we need to create an empty solution and add new projects to that solution.This approach comes handy when you first just want your empty solution within a folder structure and then you later want to just add new projects to this solution.

1.One possible solution is to Enable "Always Show Solution" in the Projects And Solution Tree inside the Options in Visual Studio.If you enable this then whenever you create a new project a solution will also be created for you with that project.This sometimes is a problem when we create only a single website and want a .sln or "solution file" to load that project. alwayscreatesolution 2. Another approach is just navigate to Other Project Types and in that go the subtree "Visual Studio Solutions" and here you will find "Blank Solution" template, this will open for you a blank solution into which you can add projects. Empty-Solution Initially there will be no projects loaded as we have not created any project.Just right click the solution and go to Add and then add new project,add new website, add existing project,add existing website what ever you feel like. emptysolutionvisualstudio Happy Programming!!!!


Installing Collabnet Subversion + Tortoise SVN + AnkhSubversion for Source Code Sharing for Visual Studio related Development

Introduction Source Control is a must while developing big projects with big teams ideally you should use a source control if you are not working alone on the project. With Visual Studio there are a no of options available but today in this article i will discuss about Collabnet Subversion in combination with ANKH Subversion and Tortoise SVN. Although other options available are also good and have their own unique features but if you want a source control combination for free then this is the combination which is best suited to you. Among other options Source Gear Vault and Source Fortress which are also good source control tools. Other option available is VisualSVN which is a Visual Studio Plugin, which integrates within the Visual Studio the power of Subversion and Tortoise but its not free so the best combination available is Collabnet Subversion+Tortoise SVN + AnkhSubversion.

Packages to download and install

  1. Collabnet Subversion  ---->  http://www.collab.net/downloads/subversion/
  2. Tortoise SVN --------> Tortoise SVN is the best Subversion GUI available.-------->http://tortoisesvn.net/downloads
  3. Ankh SVN Plugin for Visual Studio  ------> Ankh is an open source Subversion Plugin for Visual Studio                                                           --->http://ankhsvn.open.collab.net/servlets/ProjectProcess?pageID=3794

 

Steps to download and install Collabnet Subversion + Tortoise SVN  + Ankh Subversion

  • First download and install Collabnet Subversion. Download url ---> http://www.collab.net/downloads/subversion/
  • It will ask for default repository just let it be on the default location ie c:svn_repository or if you change the repository then remember the path which you used for the new repository because we will require that repository in future while configuring new projects or else we can create a new repository to enter new projects.
  • Collabnet Subversion will automatically ask you to install apache tomcat let it install the tomcat for you on its default port as 80 do not change the port initially as in some case if you initially give a different port it will not work after installations.
  • But when you install it on default port 80 many of your IIS related applications or sharepoint sites may seize to work but don't worry we will change it later.
  • Now after installing Collabnet Subversion just go to the installation directory and just search for the httpd folder and there you will find httpd.config file where just modify the listening port to 85 or any other port just keep in mind many firewalls generally block port above port 3000 so just check with your firewall if you are using a port number above 3000.
  • Now just install the tortoise SVN client from ---------> http://tortoisesvn.net/downloads
  • After installations also install ANKHSVN  from ---------> http://ankhsvn.open.collab.net/servlets/ProjectProcess?pageID=3794
  • We are using 2 clients because this tortoise SVN do not integrate itself with Visual Studio its only directory based where as this AnkhSVN gets itself attached with visual studio very well you can update and commit changes directly from Visual Studio.So the million dollar question is why not use only ANKH svn so the million dollar answer is that ankh svn is not having its own client GUI its only integrated from visual studio and its easy to do checkouts for the first time from tortoise and it helps in repository manipulations directly from the front end ui or else we have to do everything with the command line for the Collabnet svn server to create repository on the server .

Configuring and creating repositories the easiest way

    • Now after you have installed Collabnet Subversion you need to create repositories so i am describing the simplest way to create repositories.
    • Create a folder in your disk where you want to save all your projects for subversion say you called it svn.
    • Now inside svn start creating folders like ProjA and ProjB for different projects.
    • After creating the repositories you have to configure the config files in order to provide right authorization and authentication.
    • I will describe here the simplest form i.e using authentication you can also implement groups and other stuff that you can change in the auth file.
    • So to create repository the simplest and the easiest way is to use Tortoise SVN client you can also create it using command prompt but i prefer the Tortoise SVN way.
    • Right click inside the ProjA folder you just created and you will have a TortoiseSVN shell menu item saying Create Repository here click on this and the  repository files , config files and database files are created.
    • After creating the repository just go to the conf folder and open you will find svnserve.conf file.
    • Open this file in notepad and remove everything from this file except what is given below
[general]
# anon-access = read
auth-access = write
password-db = passwd
# authz-db = authz
realm = subversion
    • Now save this file and open another file in the same folder named passwd, open this file also with notepad, in this file write your usernames and passwords for the users who are authenticated for this repository.
[users]
abc = abc
user = password
  • Save this file and you are done.
  • On the client open the server using Repo Browser from Tortoise SVN you will get repo browser option by right clicking anywhere in the explorer and exploring the Tortoise Shell options.
  • In the repobrowser type snv://yourservername/yourrepositoryname/ and you will be able to acess the repository.

Visual Studio Tips & Tricks #2:-Decrease your loading delay by stopping the splash screen to load on Visual Studio Startup

Sometimes you may find that your Visual Studio IDE is taking a lot of time to startup and this is annoying. So there can be many reasons why your IDE is behaving so strange and slow. So one of the visual enhancement trick is to disable the splash screen which comes when visual studio starts up. To disable this splash screen just go to your Desktop icon which says "Microsoft Visual Studio 2005/2008" and right click on it. No click on the Properties and in the target to this shortcut just add /nosplash. Now your target looks as "C:Program FilesMicrosoft Visual Studio 9.0Common7IDEdevenv.exe" /nosplash. And now if you open your IDE with this shortcut then you will not find any splash screen while loading. Remember this removes the splash screen option only from your shortcut, so if you use devenv Run shortcut then you will see the normal splash screen. Stay tuned for more tips and tricks... Happy Programming!!!!!


Visual Studio 2008 Tips & Tricks for Developers:- This includes some shortcuts and some hidden features in Visual Studio 2008 which will increase your productivity

  1. Working in Full Screen Mode in Visual Studio
    1. Alt+Shift+Enter is the shortcut to enter to fullscreen mode in Visual Studio
    2. Its sometimes really helpful and more appealing for developers to work in full screen mode
  2. Editing
    1. For Copying a line in the IDE just go to the start of the line and press Ctrl+C,there is no need to select anything
    2. For Pasting a line just go to the start of the line and just press Ctrl+V
    3. For Deleting  a line just go to the start of the line and press Ctrl+X,  this is not actually delete but its similar to cut if you do Ctrl+X on current line and go to some other place in your code and do Ctrl+V then it will paste the same line there.
  3. Expanding and Collapsing the code units
    1. This nice little shortcuts has saved me a lot of time.Whenever i am working on a large piece of code i always get confused and make some changes in other Method or property because they were looking similar.
    2. But now with this shortcut i collapse one method as soon as it is finished.
    3. The shortcut is Ctrl+M+M.
    4. Just go to the beginning or end of the method or property or any code block and hit the shortcut it will expand or collapse the code block comparing to its present state.
    5. If you want to collapse all your code units or blocks to their definitions then the shortcut to achieve this is Ctrk+M+O or Ctrl+M Ctrl+O.This is also a very handy shortcut which helps a lot in development.
  4. Automatic Text Indentation and Formatting
    1. This shortcut helps me to write beautiful and decorative code which is easy to understand by any person.
    2. Shortcut is just press Ctrl+K+D.
    3. This works not only in C# and VB code behind but it works well in aspx pages.
    4. If you want to just format the selected piece  of code then just press Ctrl+K+F
  5. Automatically adding Namespaces
    1. Use the Ctrl+. (Remember this is Ctrl+[period] if you get confused) shortcut key to automatically get intellisense for probable namespaces.
    2. Just press enter to include the required namespace.
    3. There are much cooler tricks when using a refactor like Resharper.I will discuss those tricks later this month in one of my posts.
  6. Commenting And Uncommenting The Code
    1. This trick saved me a lot of time.
    2. Just select the code to be commented and press Ctrl+K+C,this will comment your code block.
    3. For uncommenting the code just press Ctrl+K+U,this will uncomment the code block.
  7. Automatically generating properties
    1. Generating dummy getter and setters or properties is also a pain in big projects.
    2. Although i would recommend you some refactors like Resharper which can do it for you or some code generators like Code Smith and also give a try to inbuilt on in Visual Studio 2008 called T4 or Text Template Transformation Toolkit.
    3. But if you don't have such a mass volume project and just don't want to write your getter and setters then just type this prop + TAB+TAB
    4. Remember you don't have to type all of this but you only type prop and then press TAB two times for VS2008 to automatically generate the property for you now you can change the name and any other thing by navigating and just pressing TABS.
  8. Increasing and decreasing the indentation
    1. Select the code block for which you want to increase the indentation and after selecting just press TAB,this will increase the indentation.
    2. To decrease the indentation just select the required code block and then press SHIFT + TAB,this will decrease the indentation of the selected code block.
  9. Selecting a single word then line and then other lines within that block and then.......
    1. This is also a cool trick if you are in middle of something and want to do something on either the word you are on or the entire code block, or entire method, or entire class then just go on pressing Ctrl+W,it will start selecting for you starting from the current word.
    2. After selecting the desired code block you can perform any operation on that code block.
  10. Build & Debug Shortcuts and tricks
    1. To build  a solution just press Ctrl+Shift+B
    2. To start debugging just press F5
    3. To stop debugging just press Shift+F5
    4. If you are already debugging or your WebDev.WebServer.Exe is running or any other webserver is running you can directly attach to that process escaping the hussle to build again this is a great time saver.Remember always build or rebuild if you have done some major changes but if simply you want to debug and have done no changes in any other class library projects then you can use this trick
    5. Simply Press Alt+D+P then the Attach to process window will open.
    6. Simply choose your web server process to attach and you will see without building your entire solution your solution has been attached to the debugger.
  11. Find Options
    1. You are already familiar with Ctrl+F option to find something either in current documents or all open documents or entire project  or entire solution,but another find option is Ctrl+Shift+F, this trick is helpful when you want all your results to be listed in a find window rather then to navigate one by one in every file where the searched string exists.
  12. Switching Between Design And Source Views
    1. F7 is the key used to switch between design and source (ie c# or vb files) views in IDE
    2. If you want to just toggle the markup's design and source view or want to view both then press Ctrl+PageDown
  13. Some other common used shortcut keys which can be helpful
    1. Ctrl+Alt+L for opening Solution Explorer
    2. F4 for opening properties window
    3. Ctrl+Alt+X for showing the toolbox
    4. Ctrl++T for displaying the tasklist
    5. Ctrl++E for displaying the error list
  14. How to navigate between various opened tabs inside Visual Studio
    1. Ctrl+TAB key will let you navigate between various open tabs in Visual Studio IDE
  15. Going to Declaration and then again returning to the actual usage
    1. Just press F12 to go to declaration
    2. And press Ctrl+- to return back to the piece of code where you were earlier.
  16. Selecting Source Control Plugin
    1. If you are working in a team you probably will be using a source control there are many options to choose SVN,Visual SVN,TeamFoundationServer,Source Vault and Source Fortress and many others.
    2. But when selecting a client you have to mention it in Source Cotrol Plugin Selection as shown below
  17. I want solution for every project which i create
    1. If you want a solution for every project which you create then you have to enable this as shown below

I would have really forgotten many things which could be added in this list.I will update this list regularly  as I encounter any new thing,so stay tuned for more Also I would be doing an extensive post on Resharper 4.0,the most sharpest refactoring tool available out there its not just a refactor but a way beyond that Believe me i use it in my day to day coding and it makes development process 100K faster. Happy Programming!!!! Update 12Dec2008

  1. For deleting a line in Visual Studio just place the cursor in front of it and press Ctrl+Shift+L

Update 4 Jan 2009

1.This post links to a tip used to decrease the load time of the IDE by disabling the splash screen. https://www.smallworkarounds.com/index.php/2009/01/04/visual-studio-tips-tricks-2-decrease/   “If someone wants to purchase Visual Studio 2008 at a discounted price, you can purchase at a low price from eCostSoftware.”


Visual Studio is missing default templates

If your Visual Studio either VS2005 or VS2008 is missing some default tempates, or whenever you want to add any new item and click add new item you are surprise to find that either your add new WebForm is missing or any other similar item is missing from the add new item list then your templates defaults are corrupted due to some reasons or latest updates or patches or any other software which you have recently installed. Workaround So the workaround to this problem is:-

  1. Just go to the Visual Studio command prompt.
  2. Close all opened instances of Visual Studio
  3. Run this command devenv/installvstemplates on Visual Studio Command Prompt.
  4. And thats it all your templates will be set to defaults.

JQuery with Asp.net and Visual Studio 2008 intellisense

Here is a small post on Jquery which is a far better alternative to Aspnet Ajax.Its a small JavaScript library with immense power and most widely used these days.A few months ago Microsoft announced that they will be shipping JQuery with Next Release of their Visual Studio i.e Visual Studio 2010. Visual Studio 2010 and .net framework 4.0 Community Technology Preview are already available  for download from http://www.microsoft.com/downloads/details.aspx?FamilyId=922B4655-93D0-4476-BDA4-94CF5F8D4814&displaylang=en I am not sure about the intellisense support for JQuery and JavaScript in this new version but as Microsoft Promised they will surely ship it in their final release. As for now with Visual Studio 2008 full intellisense for JQuery is achieved using a .vsdoc.js file.   Steps to follow to get full intellisense

  1. Install this Hotfix which will fix many issues for Visual Studio Team Systems 2008 and also enable and enhance you script intellisense if somehow it is disabled or its not coming with many other fixes. Download Link :-https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=10826
  2. Jeff King has a very good post describing the second step here.

http://blogs.msdn.com/webdevtools/archive/2008/10/28/rich-intellisense-for-jquery.aspx

Here a hack is applied so there two files are given one is "jquery-1.2.6.js" another is "jquery-1.2.6-vsdoc.js".So the first file is the actual Jquery file which should be downloaded on the clients browser along with the markup whereas second file should only be available while using intellisense inside the Visual Studio 2008.The markup comments shown above are achieving the same thing. A very simple Visual Studio Solution is attached at the end of this post for you to see the architecture of how to include jquery files and how to do very basic things using Jquery in an aspx page having basic markup as HTML.

After following these steps you are now ready to start Jquery development in Asp.net Download Source Code Here :-http://9wtpog.bay.livefilestore.com/y1pPZ0KF1m2F28wRGe4wQYrbDCyIuWruESEpdlcILrP_8rIkJfe2eTchl6iw6KSUMwRroVAQ2UvoCo/JqueryIntellisenseInstallation.rar?download