å°ãåãŸã§ãç§ã¯ãµãŒããŒã¢ã»ã³ããªçšã®ããã€ãã®NAntãããžã§ã¯ããšæ¢ã«ãã¹ã¿ãŒãããŠããMSBuildã®ç¶ç¶çãªçµ±åã䜿çšãå§ããŸããã ãã€ãã®ããã«ãä»äºã®éçšã§ãç°ãªã笊å·ïŒãã©ã¹ãšãã€ãã¹ã®äž¡æ¹ïŒãæã€ããŒãã¹ãæ€åºãããŸãã CIãµãŒããŒã®ã³ã³ããã¹ãã§ããŸããŸãªãšã³ãžã³ïŒMSBuildãNAntïŒã«ããã¢ã»ã³ããªã®è©³çŽ°ã«èå³ãããå Žåã¯ãcatã«æåŸ ããŠãã ããã
çµç«å·¥çš
æåã«ãã¢ã»ã³ããªããã»ã¹ãã€ãŸããœãŒã¹ãã¡ã€ã«ãæçµè£œåã«ãªãããã«ééãããã§ãŒãºã®ãªã¹ãã«ã€ããŠç°¡åã«æ€èšããŸãã
- åã®ã¢ã»ã³ããªã®çµæããã¢ã»ã³ããªãã©ã«ããåé€ãã
- ãã«ãããã»ã¹ã®åæåïŒããšãã°ãã³ãŒããã¡ã€ã«ã«æ£ããããŒãžã§ã³ãã€ã³ã¹ããŒã«ããïŒ
- ã³ãŒããã¡ã€ã«ã®ã³ã³ãã€ã«
- è©Šé転
- ãã€ããªãã¡ã€ã«ã«åºã¥ãç¹å¥ãªãã¡ã€ã«ã®äœæïŒmsiã€ã³ã¹ããŒã©ãŒãNuGetããã±ãŒãžãªã©ïŒ
- ãã«ãçµæã®å ¬éïŒFTPãžã®ã¢ããããŒããnuget pushïŒ
ãã®ã¢ã»ã³ããªã¢ãã«ã¯ãéèŠã§ãªã詳现ã§è°è«ãæ··ä¹±ãããªãããã«ååã«åçŽåãããŠããŸãã ãã®ãããã³ã³ãã€ã«ãã§ãŒãºã«ã¯ãªããžããªããããã±ãŒãžãããŠã³ããŒãããããšãå«ãŸãããã¹ããã§ãŒãºã¯åäœãã¹ããšçµ±åãã¹ãã®å®è¡ã«åå²ãããŸãã ç§ã®æèŠã§ã¯ãçµã¿ç«ãŠããŒã«ãç®çã®ããã»ã¹ã«é©åãããèœåã¯ãéžæã«ãããããªãéèŠãªèŠçŽ ã§ãã
MSBuildã§ã®ãã«ãããã»ã¹ã®ãµããŒã
MSBuildã¯IDEïŒVisual StudioãSharpDevelopïŒã®éåžžã®ãã«ããŒã§ãããããæåã¯MSBuildã§äœæ¥ããŸããã
ãããžã§ã¯ãããã«ãããããã«ãããã€ãã®è¿œå ã®ã¹ã¯ãªããã䜿çšãããŸããã ãªãã«ããã«ã§ã¯ãªããæ£ç¢ºã«ã«ããã«ã§ããïŒ ãã¹ãŠãéåžžã«ç°¡åã§ããMSBuildã¯ãã¹ã¯ãªããã®å®è¡äžã«ã¿ãŒã²ãããã¡ã€ã«ãèªã¿èŸŒãããšãã§ããŸããã æåã«ã¹ã¯ãªããã§æå®ããããã¹ãŠã®ãã¡ã€ã«ãã€ã³ããŒãããŠãããã¢ã»ã³ããªããã»ã¹ãéå§ãããŸãã ãã®ãããæåã®ã¹ã¯ãªããã¯NuGetãªããžããªããè¿œå ã®ã¿ãŒã²ãããã¡ã€ã«ãããŠã³ããŒãããããšã®ã¿ãæ åœãã2çªç®ã®ã¹ã¯ãªããã¯ããã«èœã¡ããã¹ãŠã®è³ç£ã䜿çšããŠãã«ãã¹ã¯ãªãããå®è¡ããŸããã
åã ã®ãããžã§ã¯ãããã«ãããããã«ãçæãããIDE csprojãã¡ã€ã«ã䜿çšãããå€æ°ãç°¡åã«å å®ãããŸããã MSBuildã§ã®ãããžã§ã¯ãã®ç¶æ¿ã«ãããç¶æ³ã¯å³ããããšãå€æããŸããã æ£ããå®è¡ããã«ã¯ã芪ã¹ã¯ãªãããåå ã®ãã©ã¡ãŒã¿ãŒã»ããå šäœãå®å šã«æž¡ãå¿ èŠãããã芪ã®æ¬äœã®ããããã£ã®åçŽãªå®çŸ©ã§ã¯äžååã§ããã ãã¡ãããããã¯èŽåœçã§ã¯ãããŸããããäœåãªäœæ¥ãè¡ããŸãã
æåã®3ã€ã®ãã§ãŒãºã«ç¹å¥ãªåé¡ããªãå Žåãæ®ãã®ãã§ãŒãºã®å®è£ ã«ã¯ããçšåºŠã®ã¹ãã«ãå¿ èŠã§ãã ãªããªã IDEã¯csprojãã¡ã€ã«ã䜿çšããŠãããžã§ã¯ãã管çããŸãããããŸãå€æŽããããšã¯ã§ããŸããã 解決çã¯ãã¡ã€ã³ã¹ã¯ãªããã«æ®ãã®ãã¹ãŠã®ãã§ãŒãºã®ã¢ã»ã³ããªã¹ã¯ãªãããèšè¿°ããããšã§ããã ãã®ãœãªã¥ãŒã·ã§ã³ã®å©ç¹ã¯ããã¹ãŠã1ãæã§èšè¿°ãããããšã§ãã ãã ãããããã¯ã·ã§ã³ãããžã§ã¯ããšåäœãã¹ããããžã§ã¯ãã®æ°ã10ã«å¢ãããšããã®ãããªãã«ãã¹ã¯ãªãããç¶æããããšãé£ãããªããŸãã
IDEã¯ããã©ãããã©ãŒã /æ§æã®çµã¿åããããšã«åå¥ã®åºåãã©ã«ããŒãçæããããããã«ãããã»ã¹äžã«ãåç §ãããžã§ã¯ãã®dllãã©ã®ãã©ã«ããŒã«ããããåžžã«å€æããã®ã¯ç°¡åãªäœæ¥ã§ã¯ãããŸããã
ãããžã§ã¯ãã§NuGetããã±ãŒãžãªããžããªã䜿çšããããšã«æ±ºããå Žåãããã«éè€ããŸãã ããã±ãŒãžããdllãžã®ãªã³ã¯ã¯ãcsprojãã¡ã€ã«ãšpackages.configãã¡ã€ã«ã®2ã€ã®å Žæã«ãããŸãã Nugetã¯ã©ã€ã¢ã³ãã«ã¯ãããã2ã€ã®ãã¡ã€ã«ã®åæãç¶æããéã®æ¢ç¥ã®åé¡ããããŸãã ç¹ã«ãããã±ãŒãžãæŽæ°ããŠããåžžã«æãŸããçµæãåŸããããšã¯éããŸããã
NAntãã«ãããã»ã¹ã®ãµããŒã
NAntã®çŸåšã®ããŒãžã§ã³ã¯0.92ïŒ2012幎å€ãªãªãŒã¹ïŒã§ãããããç§ã®ç 究ã§ã¯ããã«äŸåããŸããã
ããã§ã¯ãããããç¹å®ãããæ¬ ç¹ããå§ããŸãã
åºæ¬çãªIDEïŒVisual StudioãSharpDevelopïŒã¯NAntã奜ãŸãããã®ãããžã§ã¯ãã®æšæºãã©ãŒãããã¯ãµããŒãããŠããŸããã ãã ããå®å šãæãããã«ãSharpDevelop NAntã®å€ãããŒãžã§ã³ã®1ã€ããµããŒããããŠããããšã«æ³šæããŠãã ããã çŸåšãSharpDevelopã®çŸåšã®éçºéšéã§NAntãµããŒããæå°éã«æããããŠããã®ã¯è¬ã®ãŸãŸã§ãã
NAntã«ã¯ç¬èªã®ããŒãã¹ããªããMSBuildïŒWPFãªã©ïŒã䜿çšããã«ç¹å®ã®çš®é¡ã®ãããžã§ã¯ããåéã§ããŸãã MSBuildã䜿çšããçµæãæå°éã«æããæ¹æ³ã«ã€ããŠã¯ãåŸã»ã©èª¬æããŸãã
楜ããããŒãã¹ã«ã¯äœããããŸããïŒ
ãã¹ã¯ã䜿çšããŠãã¡ã€ã«ãæäœãããšãäžåºŠæžãããã¹ã¯ãªããããµããŒãããããã®äœæ¥éãæå°éã«æããããšãã§ããŸãã
ãããžã§ã¯ãéã®ããããã£ã®ç¶æ¿ã«ãããç°ãªãã¬ãã«ã®ãããžã§ã¯ãéã§ãã¹ãŠã®å€ãæ瀺çã«è»¢éãããããšãå¿é ããå¿ èŠããªããªããŸãã ããšãã°ãåã ã®ãããžã§ã¯ãã®binãobjãã©ã«ããŒãå¢ãã代ããã«ããã¹ãŠã®ã³ã³ãã€ã«çµæã®ã³ã¬ã¯ã·ã§ã³ããœãªã¥ãŒã·ã§ã³ã¬ãã«ã§1ã€ã®ãã©ã«ããŒã«æŽçããã®ã¯ç°¡åã§ãã
NAntã®å¿ é æ§ã«ãããåã ã®ãããžã§ã¯ãã¿ãŒã²ãããé©åã«ä¿®æ£ããããšã容æã«ãªããŸãã å žåçãªã¿ã¹ã¯ã®å®è£ ïŒã©ã€ãã©ãªã«å ããŠãBeforeBuildããã³AfterBuildã€ãã³ãã䜿çšããŠèªå®¶è£œã®æ§æãããã€ãã³ããŒããŸãïŒå éšã§ã¯MSBuildã¿ã¹ã¯ã䜿çšããŸããããéåžžã¯cmdãŸãã¯Powershellã¹ã¯ãªããã䜿çšããŸãïŒã
ãã«ã¿ã€ã ã®Java Antãã«ããŒã®åºåã·ã¹ãã ã¯ããã«ããµãŒããŒã§é·ãé解æãããŠãããããNAntã«ç¹å¥ãªåé¡ã¯ãããŸããã Jenkinsãã«ããµãŒããŒïŒHudsonïŒçšã®NAntçšã®åå¥ã®ãã©ã°ã€ã³ããããŸãã
NAntã¯ãMSBuildãšã¯ç°ãªããã¹ã¯ãªããå ã§æ瀺çã«æå®ããããšãã«è¿œå ã®ã¿ã¹ã¯ã»ãããåçã«ããŒãããããNAnt.exeã®æšªã«æ£ããå Žæã«ããå Žåã¯èªåçã«ããŠã³ããŒããããã§ããŸãã ãããã£ãŠãxcopyã¡ãœããã䜿çšããŠã³ã¬ã¯ã¿ãŒèªäœãé åžã§ããŸããããã«ãããè€æ°ã®ãã·ã³ã§åäžã®ã³ã¬ã¯ã¿ãŒæ§æã䞊è¡ããŠäœ¿çšããããšãéåžžã«å®¹æã«ãªããŸãã éåžžã®ã¿ã¹ã¯ã»ããã«è¿œå ããã䟿å©ãªã©ã€ãã©ãªã®ãã¡ã次ã®ããšã«æ³šæããŠãã ããã
- NAnt Contribã¯ã MSBuildããã³Subversionãšã®çžäºéçšæ§ãå«ããNAntã®å€æ°ã®ã¢ããªã³ã»ããã§ãã
- Wixãã«ã MSIã€ã³ã¹ããŒã©ãŒ
- ããã±ãŒãžãããŒãžã£ãŒã§ã®äœæ¥ã«å¯ŸããNugetã®ããŒãã¹
äžèšã®ãã¹ãŠã®çµæã«ãããšãç§ã«ãšã£ãŠæé©ãªçµã¿åããã¯æ¬¡ã®ãšããã§ãããIDEã§äœæ¥ããŠãããšãã«MSBuildããã«ãããCIãµãŒããŒãæ©èœããŠãããšãã«NAntãèµ·åããŸããã
WPFãããžã§ã¯ããæ§ç¯ãã
æçš¿ã®æåŸã§ãã¿ãŒã«ãã¬ã«ã«èèã1ã¹ããŒã³å ¥ãããã®ãã€ãŸãNAntã䜿çšããWPFãããžã§ã¯ãã®çµã¿ç«ãŠã«ã€ããŠã話ããããã£ãã®ã§ãã ããã«ã³ã³ãã€ã«ïŒxaml-> cs-> dllïŒãå®å šã«å æããéæ³ã¯ãªããšããã«èšããŸãã ãã ããNAntã®æ³šææ·±ãç£èŠã®äžã§ãMSBuildãtrapã«è¡ãããã«èšç·Žããããšã¯ãŸã å¯èœã§ãã
NAntã¢ã»ã³ããªã®ã³ã³ããã¹ãã§MSBuildãèµ·åãããšã2ã€ã®éèŠãªåé¡ããããŸãã
- MSBuildã¯ãäŸåé¢ä¿ãããžã§ã¯ãããã«ãããå¿ èŠããããšèª€ã£ãŠèããŠããŸã
- MSBuildã¯ãäŸåé¢ä¿ãããžã§ã¯ãããã«ãããåŸã«ããã¯ãã®äŸåé¢ä¿ãæã€DLLãæ¢ããŠããŸã
æåã®åé¡ã¯ãã¢ã»ã³ããªããŒ/ pïŒBuildProjectReferences = falseãèšå®ããããšã§è§£æ±ºãããŸã ã
2çªç®ã¯é¡ã§ã¯è§£æ±ºãããªããããå察åŽããå°ãè¿ã¥ããŸãã NAntãä»ããŠã¢ã»ã³ããªãå®è¡ããããã«csprojãã¡ã€ã«ã®éçããŒãžã§ã³ãå«ããããšã¯ãå©çããããŸããã äž¡æ¹ã®ããŒãžã§ã³ããµããŒãããå¿ èŠããããŸãã ãã®ããããã®ãããªããŒãžã§ã³ããã®å Žã§çæããå¿ èŠããããŸãã å°ããªXSLå€æãååŸããŠèšè¿°ããã¹ã¿ã€ã«NAntã¿ã¹ã¯ãå®è¡ããŠã調æŽããããããžã§ã¯ããMSBuildã«ãã£ãŒãããŸãã ã¹ã¿ã€ã«ã¿ã¹ã¯ãéå§ããããšãæ¢ã«ã³ã³ãã€ã«ãããDLLãã¡ã€ã«ãžã®ãã¹ãå«ã1ã€ã®ãã©ã¡ãŒã¿ãŒãæž¡ãããŸãã
XSLå€æ
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msbuild="http://schemas.microsoft.com/developer/msbuild/2003"> <xsl:output indent="yes" method="xml"/> <xsl:param name="dllPath"/> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="//msbuild:ItemGroup/msbuild:ProjectReference"> <xsl:element name="Reference" namespace="http://schemas.microsoft.com/developer/msbuild/2003"> <xsl:attribute name="Include"> <xsl:value-of select="msbuild:Name/text()"/> </xsl:attribute> <xsl:element name="HintPath" namespace="http://schemas.microsoft.com/developer/msbuild/2003"> <xsl:value-of select="$dllPath"/> <xsl:value-of select="msbuild:Name/text()"/>.dll</xsl:element> </xsl:element> </xsl:template> <xsl:template match="*|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
ãããã£ãŠãMSBuildã¯ãããžã§ã¯ããåç¬ã§ãã«ãããä»ã®ãããžã§ã¯ãã«ã€ããŠäœãçããªãããã«ããããšãã§ããŸãã 人ã ãèšãããã«ããããªãã¯ããŸãç¥ããªããããç ãããããã¯MSBuildã管çããããã«éåžžã«éèŠã§ãã
çµè«ã®å ŽæïŒä»£ããã«ïŒ
ã©ã®æ¹æ³ãšäœã䜿çšãããã¯ãåžžã«èªåèªèº«ãŸãã¯ããŒã å ã§æ±ºå®ãããã¹ãŠã®é·æãšçæãæ éã«æ€èšããå¿ èŠããããŸãã
MSBuildããå§ããã®ãæåã§ãã éåžžãéçºè ã®ãã·ã³ã«æ¢ã«ã€ã³ã¹ããŒã«ãããŠãããã¡ã€ã³èšå®ã§äžèŠãªãžã§ã¹ãã£ãŒãå¿ èŠãšããŸããã
NAntã§ã®äœæ¥ãè€éã§ã¯ãããŸããããéçºè ããã®è³ã®ç¹å®ã®ãã¿ãŒã³ããå¿ èŠã§ãã