Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to auto generate "Additional Dependencies" for "Custom Build" in Visual Studio?

I have a custom build step in a Visual Studio 2013 solution. The custom build step calls a python script on a text file that refers to several other files in my solution. I want the custom build step to be called whenever any of those files change or when the output of my script is missing. However, I don't want to manually maintain the custom tool "additional dependencies" and "outputs" fields.

I can easily make the script generate a list of dependencies in the same way that gcc can generate a .d file when passed in -MM. Is there a way I can use the .d output of my script to automatically populate the "Additional Dependencies" in my Custom Build step? Is there some other way to avoid maintaining the "additional dependencies" and "outputs" fields"?

The help page only shows how to add individual files.

like image 285
Carlos Pinto Coelho Avatar asked Mar 18 '13 23:03

Carlos Pinto Coelho


1 Answers

Assuming that your script for generating .d files can generate files in any format that you want, you should be able to achieve the results that you need with the use of Import element:

  1. Write a script that produces a small project file instead of a .d file. The output of your script would be a small project file that contains the "additional dependencies" and the "outputs" fields.
  2. Use the Import tag to make the generated file a dependency of your main project
  3. Run the script as needed when the composition of your dependencies changes.

This approach lets you maintain the main project file separately from the auto-generated dependency file, which could be re-generated as needed. The only drawback is that your generated dependency file is an MSBuild project file, not a pure dependency file. However, this should not be a huge problem, because you own the script that generates the dependency file.

like image 65
Sergey Kalinichenko Avatar answered Sep 28 '22 14:09

Sergey Kalinichenko