开发者

How to replicate visual studio setup project's "detected dependencies" functionality?

Question

Is there a canned solution that will detect (recursively) all dependencies of a given visual studio project file? This is basically what a visual studio setup project's "detected dependencies" functionality does -- but I need programmatic access to the list of dependencies (ideally from MSBuild).

Background (read if you want to know about the actual problem I'm trying to solve)

I am working on the automated build for a WinForms application that utilizes third party UI libraries. In order to successfully build the application, the libraries must be "installed" (via the vendor's installer) on build/dev machines (this puts the assemblies in the GAC and installs licensing components). The vendor's dlls must then be referenced via the GAC in our project files. Unfortunately, there is no way to avoid this "installation" requirement (I would love to use local references that are fetched from my source control system, as I do with nearly all of our other 3rd party references, but this is not possible in this case).

We utilize a "plugin" architecture, so the executable project does not directly reference any of these components -- they are all indirectly referenced via the "plugin" projects (which are in turn referenced by the executable project). Therefore, setting the GAC references to "copy local = true" in the "plugin" projects only copies the vendor dlls into the output directory of the plugin project; they are not recursively copied to the output directory of the executable project. Hence, an xcopy deployment of the executable project's output directory does not work on a machine without these vendor dlls installed, as they are not present in the output directory.

We currently use msi deployment (via a visual studio setup project) and would like to switch to xcopy deployment. The vendor dlls are currently getting packaged into our msi because the dependency is "detected" by whatever magic happens inside the setup project's "detected dependencies" functionality. My solution to make xcopy deployment work is to just require that the executable project directly reference the vendor dlls used by its referenced plugins with "copy local" set to true. To ensure that all required vendor dlls have been referenced in this manner, I would like to generate a list of the "detected dependencies" of the executable project, assert that all those dependencies are present in the executable project's output directory, and fail the build if they are not all present.

I could do this myself by analyzing the csproj file, compiling a list of all "Reference" entries and recursively following project references. However, I am hoping that the开发者_StackOverflowre is canned functionality somewhere that does this -- especially considering that "detected dependencies" is smart enough to filter out the framework dlls but includes my GAC-referenced vendor dlls.

Thanks!


Most possibly you can solve this with Reflection - your plugins and their host most likely have a common interface contract. Your code would scan all assemblies for the usage of a set of known interface contracts after they are built and add / update these to the installer project by IDE extensibility automation. Writing a plugin that does this refresh manually may be one option, writing and registering an MSBuild task the better one.

I know this is not a 'canned solution' but the amount of work required should be less than one KLOC.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜