In the previous article, I wrote a simple PowerShell script to find all of the potentially missing file references from my Visual Studio project files, but there were a couple issues with it.
I realized, however, that the script has some performance issues. For a larger solution, it took quite a few seconds to get the work done. So, I thought it would be much better to write some kind of library for this job. The fact is, I do not want to write some external tools like a desktop application. I want to keep it simple. Simple like… installing the additional modules by nuget. Oh yeah, so just type some fancy command in the package manager console and let it be done.
Sounds perfect!
Powershell cmdlet
You can write your custom command extension for PowerShell called cmdlet. So I wrote one to meet my requirements. This is not a place for a tutorial “How to create custom cmdlet” that’s why if you want to know about it here you have a few hints about creating and dubugging cmdlets.
VSpniff
Let’s focus on my tool. I called it VSpniff – a shortcut from Visual Studio project not included files finder. You can download the tool from here. There is also instruction on how to get the tool work in your Visual Studio package manager console.
Finding missing files references
Ok. How does this works?
Let’s assume we have excluded files in the project
They could be accidentally excluded by a bad merge, for example, and we may not even know about it. After installing VSpniff you could use it to avoid such a situation. Just type in the PM console
And here we go
All the missing files listed.
Configuration
If we do not want to look for, let’s say, .png
files in the Images folder, just add a config.vspniff file to the Images directory.
Run the tool once again and here we go
Configuration file must have .vspniff extension.
There is a default configuration and looks like that
I’m going to explain more in details.
This is it. I hope you will find this tool useful and it will help you avoid many bugs.