Visual Studio’s capabilities, when dealing with .csproj files, are somewhat limited. It restricts users – both when searching for content in .csproj files – as well as the ability to ‘edit’ a csproj file. Part of the reason is that csproj files are meant to be maintained by the studio environment – and not manually tweaked. Be that as it may, there are a few occasions where one needs to tweak these files (updating incorrect library references is a common one). In order to get around Visual Studio quirks, here are a couple of easy ways to edit the .csproj files in your solution.

edit_csproj

Editing .csproj files – Start by unloading the project

Right click on your project and select Unload Projects. Once your project(s ) are unloaded, you will be able to Right Click it and Edit its csproj file (see image above).

agent_ransack_search_results

Searching for content in .csproj files – Use Agent Ransack

To edit our .csproj files using this route, we leave Visual Studio altogether – and go into Windows Explorer. We need to install a free search utility called Agent Ransack.

Agent Ransack is a free windows utility. It takes over where Windows Explorer search leaves off. It has powerful search capabilities that make it ideal to look through solution directories etc.  Right click the windows directory that contains your solution and do an Agent Ransack search for all .csproj files containing the particular text that you are interested in.  The search results show up in a split window (see screenshot above) – with the files in left pane – and the actual contained text (that was found by Agent Ransack) in the right pane. This makes it easy to eyeball all the results and figure out whether they are correct without opening all the .csproj files one by one.  To edit a particular file, use your favorite text editor (I prefer Textpad – which is a free, powerful text editor. One of the things I like about it is that it has auto-notification for files that it has open – and that are being changed behind the scenes (great for viewing log files – which need to be refreshed every time new log entries are written). 

NOTE: If you have a large number of projects in your solution, you may find this post (about an extension which collapses all projects in the Solution Explorer view) handy.

Summary

If you are ever faced with the task of looking through all the .csproj files in your solution (and it could be in the hundreds, depending on the size of your solution), use one of the above techniques for making your life a little easier.

Anuj holds professional certifications in Google Cloud, AWS as well as certifications in Docker and App Performance Tools such as New Relic. He specializes in Cloud Security, Data Encryption and Container Technologies.

Initial Consultation

Anuj Varma – who has written posts on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.