Visual Studio Scripting – Writing Scripts for Visual Studio Projects

cnetvisual studio

What is the best way to write and run small scripts and tasks that are specific to a particular .Net project?
Such things as configuring a database or confirming proper connections to servers.

In Ruby, I would build rake tasks for this sort of thing.

I am currently using unit tests for these tasks as they are easy to run within VS and they have access to all the necessary libraries and project code. However, this is not really their intended purpose and, with the dropping of Test Lists in VS 2012, it does not work nearly as well as it used to.

Is there a better solution than writing a console project to handle these little code snippets I need to run periodically?

Best Answer

Powershell is the canonical answer if you need access to your project libs, as you wrote. However, for a lot of simple tasks I still use "classic" Windows shell scripts, as long as the task can be easily solved with that. For example, simple file copy operations, folder creation etc. Another alternative is VBScript, if Windows shell script is not powerful enough. VBS misses direct access to .NET libs, but it has access to classic COM components, and was ok for me in the past for example for text file manipulation with regular expressions and similar things.

Related Topic