Create MSBuild custom task to modify C# code *before* compile

笑着哭i 提交于 2019-12-04 04:53:37

Given your restrictions I think you can do the following:

  1. Create custom task that accepts the list of cs files to adapt prior to compilation
  2. The custom task adapts the list of files received and creates them on disk
  3. The custom task sets the list of changed files on the output parameter
  4. The output of the task would replace the original cs files list
  5. The compilation is done against the changed files.

The step 4 ensures that the files that are eventually compiled are the ones that were changed by your custom task.

You will heavily rely on the ITaskItem interface for the job.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!