visual studio - MSBuild or NAnt script that generates C# files, adds them to a project and compiles the project -
i've written code generator app fluentmigrator api emits unknown number of c# class files. wish compile code generator, run emit c# classes add new c# files existing c# project , compile final solution.
what's best approach adding code generated c# files project?
given know post, there couple approaches.
you have api generate class files , want integrate build process make api call generate new class files, incorporate class files build.
if executable emits output files it's current working directory, use exec task run command in $(intermeidateoutputpath) not clutter project's source tree:
<exec command="myexe.exe " workingdirectory="$(intermediateoutputpath)\autogenclasses\" />
following command, append output classes default compile group:
<itemgroup> <compile include="$(intermediateoutputpath)\autogenclasses\**\*.cs" /> </itemgroup>
now you'd want control when occurs, you'd embed code separate <target />
, schedule occur before build occurs.
<target name="autogenclasses" beforetargets="compile"> <message text="starting autogenclasses task..." importance="high" /> <exec command="myexe.exe " workingdirectory="$(intermediateoutputpath)\autogenclasses\" /> <itemgroup> <compile include="$(intermediateoutputpath)\autogenclasses\**\*.cs" /> </itemgroup> <message text="... completed autogenclasses." importance="high" /> </target>
Comments
Post a Comment