Removing Unit Test dll files when using WIX

醉酒当歌 提交于 2019-12-12 14:31:48

问题


I'm trying to create an MSI for my project using WIX. I've got HEAT pointing to the correct directory and the file it spits out is correct, but for some reason when I actually run MSBuild on it it's also giving me all of my unit test dll files.

Anyone have any idea how to remove those from the build process?


回答1:


One option would be to write an XSL transformation modifying the generated HEAT output (e.g. removing the unwanted files):

heat.exe dir <other arguments> -t my.xsl

To remove a specific file your xsl could be something like:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="node()[child::node()[@Source='UnwantedAssembly.dll']]" />
</xsl:stylesheet>

This approach allows you to make other changes to the file as well. Though to only remove unwanted files it's usually simpler to just delete them from the build directory or to move the desired files into another directory and run HEAT there.




回答2:


Typically you wouldn't point heat.exe at your default build directory for just this reason. After you compile your product's binaries add a second step to stage the files you want into a second directory. Then, point heat.exe at the staged directory. That way you have more control over the files & paths that get harvested.



来源:https://stackoverflow.com/questions/7906578/removing-unit-test-dll-files-when-using-wix

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