如何使用nant任务来增加构建版本?更具体地说,我如何将其与assemblyinfo.cs中的版本号联系起来?
发布于 2011-03-15 18:35:55
您需要考虑使用某种系统来管理您的版本增量。一种常见的方法是通过持续集成,例如CruiseControl.NET。如果你走这条路,你可以像这样使用一个构建目标:
<target name="set.version" description="generates the version number">
<echo message="Setting the build version to ${CCNetLabel}..." />
<attrib file="AssemblyInfo.cs" readonly="false" />
<asminfo output="AssemblyInfo.cs" language="CSharp">
<imports>
<import namespace="System" />
<import namespace="System.Reflection" />
</imports>
<attributes>
<attribute type="AssemblyVersionAttribute" value="${CCNetLabel}" />
<attribute type="AssemblyFileVersionAttribute" value="${CCNetLabel}" />
</attributes>
</asminfo>
<attrib file="AssemblyInfo.cs" readonly="true" />
</target>其中,CCNetLabel是在执行nant时从CruiseControl设置的动态属性。
发布于 2011-03-15 18:19:31
NAnt的 task可以帮助您生成AssemblyInfo.cs。
发布于 2011-03-15 18:33:08
我们使用TeamCity为NAnt提供一个版本号。然后将版本号注入到AssemblyInfo中,如下所示:
<asminfo output="${solutionDir}/CommonAssemblyInfo.cs" language="CSharp">
<imports>
<import namespace="System" />
<import namespace="System.Reflection" />
</imports>
<attributes>
<attribute type="AssemblyVersionAttribute" value="${version}" />
</attributes>
</asminfo>这将创建一个具有指定版本的CommonAssemblyInfo.cs文件,该文件需要链接到解决方案中的所有项目。
https://stackoverflow.com/questions/5309895
复制相似问题