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?

  • 2
    Powershell. You got all of .NET exposed there and it is built-in for any recent version of windows. – Daniel Iankov Sep 9 '12 at 5:48
  • Why didn't you add this as an answer? You don't know of any good tutorials on programming for Powershell, do you? – oillio Sep 9 '12 at 17:01

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.