views:

50

answers:

1

I have created a msbuild task that minifies and combines javascript and css files that is triggered when my visual studio project is built.

This task adds the minified and combined files to the file system.

However I would like that they automatically be added into the visual studio project. Is this possible and if so, how can I achieve this?

A: 

I would recommend against doing this inside the default "Build" target of your project file -- IMO the Build target should be pristine and should do nothing but compile/build the project itself. It also can create headaches depending upon how and when your builds execute in your build lifecycle.

Instead, create a new MSBuild target in your build file which performs this addition for you. I hope you have a main build file outside your Visual Studio project -- this will make everything much easier. Since your CSProj file is just a simple XML (MSBuild) file, it's easy enough to write your own custom task which modified the project to add whatever files you like to it.

Dave Markle
Yes I have created a new build task that minifies etc the files. I want to add a step to it to add the minified files to visual studio. Any ideas how this step can be done? As an aside, how do I add a main build file outside your Visual Studio project?
Niall Collins