Sunday, March 6, 2011

Output library project XML to asp.net bin folder on build?

I have a visual studio 2005 solution which has a web application and a class library project. The web application has a reference to the library project. I'd like the library project's code documentation XML to output to the web application's bin folder, along with the library's DLL. I can't seem to find any easy way of doing this.

From stackoverflow
  • Post-build step, perhaps? A bit ugly, but I think it would work.

  • Use a post build event on the library project that will copy the Xml file to the web application's bin folder.

    For example you could use something like: copy $(TargetDir)\ $(SolutionDir)\

    This is untested so you'll prolly need to tweak it.

  • Here is the post-build command that worked:

    copy "$(TargetDir)$(TargetName).xml" "$(SolutionDir)MyWebProject1\bin\$(TargetName).xml"
    copy "$(TargetDir)$(TargetName).xml" "$(SolutionDir)MyWebProject2\bin\$(TargetName).xml"
    

    A couple of problems inherent with this solution:

    • The xml is always copied even if that website is not part of the current build... so the documentation can get out of sync with the the dll in the bin folder until the next time that web project is built.
    • If we add a new web project that refers to this library, we need to add another post-build command, rather than having this all happen automatically.

    I'm accepting this as a kludgy but workable solution... if anyone has a more elegant suggestion, please let me know!

    Thanks,

    Mike

0 comments:

Post a Comment