views:

692

answers:

3

I've created a one-line batch file to run SqlMetal to regenerate a LINQ to SQL DataContext for my database; this works great.

*Refresh_DataContext.bat*:

"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sqlmetal.exe" 
     /server:.\sqlexpress /database:MyDatabaseName 
     /code:"%~dp0\DataContext.vb" /context:DataContext 
     /views /functions /sprocs /pluralize

So far I can run this by opening the enclosing folder in Explorer and running the batch file, and I've also added it to the Tools menu (Tools/External Tools.../Add).

Now I'd like to run this batch file whenever I build (in certain configurations). How do I do this?

+2  A: 

What you seem to be looking for can be found under "Pre-build event command line" under your project's properties. Click the "Build Events" tab, and you'll have a little space to enter in a command line which does what you want.

Dave Markle
A: 

I have the same problem. VS2005 had a Build Events tab, VS2008 doesn't. Did you find how to add a pre-build event in VS2008?

No, unfortunately I haven't gotten an answer yet.
Herb Caudill
A: 

Doh! Of course. Web Application projects have pre- and post- build events; Web Site projects don't.

Herb Caudill