I recently started playing around with LuaInterface to get Lua scripting working in my C# programs. In order to easily create Lua scripts from within Visual Studio, I installed a Lua syntax highlighting plugin and created an Item Template so that I could create new scripts by right clicking on the project file and selecting “New Item->Lua Script”. This works quite well.
In order for the program to find the scripts, they need to be placed in the same directory (or a subdirectory) of the build location. This is exactly where I want them, but in order to do this, I have to change the “Copy to Output Directory” setting for each new file I create.
Is there a way to change the default setting of this option? Right now it defaults to “Do not copy”. I could only find one other question asking essentially the same thing but the only answer provided there suggested a post-build event copying all files with the same extension to a defined location. I don’t really want to do this since the target destination may change or more targets may be added (and would require additional events?) and I would like to be able to change that setting on a per-file basis.
This is just a convenience issue, as I can change that option manually for each file, but having been able to automate the rest of the process, I was hoping I could automate this one last detail as well.
You should be able to add an
IWizardreference to the template, this will run when you click ok in the File -> Add window. You’ll need to add the assembly and type to the vstemplate file.Implement the
RunFinishedor possibly theProjectItemFinishedGeneratingmethod. You can then use theEnvDTEobject exposed by Visual Studio to manipulate any item in the solution using the standard Visual Studio Extensibility model..The following code snippit (from the open source T4 Toolbox) shows how to set this property.