利用SVN改正ラベルをCCNET
-
08-06-2019 - |
質問
を使用していCCNETサンプルプロジェクトSVNとしての私のソース。CCNETが設定されていく構築べてのチェック。CCNET用MSBuild、ソースコード。
を使用したいので、最新のリビジョン番号を AssemblyInfo.cs
を作成.かを検索最新の改正からsubversionの価値CCNET?
編集:私は使用しないNAntみMSBuild.
解決
CruiseControl.Net 1.4.4は、 組版Labeller, 生成するバージョン番号に対応す。純組み立てます。
私のプロジェクトまで設定:
<labeller type="assemblyVersionLabeller" incrementOnFailure="true" major="1" minor="2"/>
(警告: assemblyVersionLabeller
な発svn正ラベルで実際のコミットトリガの構築が発生します。)
そして消費することからMSBuildプロジェクト MSBuildCommunityTasks.AssemblyInfo :
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<Target Name="BeforeBuild">
<AssemblyInfo Condition="'$(CCNetLabel)' != ''" CodeLanguage="CS" OutputFile="Properties\AssemblyInfo.cs"
AssemblyTitle="MyTitle" AssemblyCompany="MyCompany" AssemblyProduct="MyProduct"
AssemblyCopyright="Copyright © 2009" ComVisible="false" Guid="some-random-guid"
AssemblyVersion="$(CCNetLabel)" AssemblyFileVersion="$(CCNetLabel)"/>
</Target>
日本酒のcompletnessでも簡単にプロジェクトを使用NAntの代わりにMSBuild:
<target name="setversion" description="Sets the version number to CruiseControl.Net label.">
<script language="C#">
<references>
<include name="System.dll" />
</references>
<imports>
<import namespace="System.Text.RegularExpressions" />
</imports>
<code><![CDATA[
[TaskName("setversion-task")]
public class SetVersionTask : Task
{
protected override void ExecuteTask()
{
StreamReader reader = new StreamReader(Project.Properties["filename"]);
string contents = reader.ReadToEnd();
reader.Close();
string replacement = "[assembly: AssemblyVersion(\"" + Project.Properties["CCNetLabel"] + "\")]";
string newText = Regex.Replace(contents, @"\[assembly: AssemblyVersion\("".*""\)\]", replacement);
StreamWriter writer = new StreamWriter(Project.Properties["filename"], false);
writer.Write(newText);
writer.Close();
}
}
]]>
</code>
</script>
<foreach item="File" property="filename">
<in>
<items basedir="..">
<include name="**\AssemblyInfo.cs"></include>
</items>
</in>
<do>
<setversion-task />
</do>
</foreach>
</target>
他のヒント
す基本的には二つの選択しかない。のいずれかを書いてますが、簡単なスクリプト開始されると解析の出力
svn.exe 情報--改正ヘッド
を得るビジョン番号(その発生AssemblyInfo.csのですが、ここでは直進)で利用プラグインのためのCCNET.ここでは:
SVN改正Labeller でのインターフェイス CruiseControl.純ることを可能にする 生CruiseControlラベルのご ビルドに基づき改定数 のSubversionします。この できるカスタマイズとの接頭辞および/または 専攻/マイナーバージョン番号
好きですから最初のオプションだから約20行のコード:
using System;
using System.Diagnostics;
namespace SvnRevisionNumberParserSample
{
class Program
{
static void Main()
{
Process p = Process.Start(new ProcessStartInfo()
{
FileName = @"C:\Program Files\SlikSvn\bin\svn.exe", // path to your svn.exe
UseShellExecute = false,
RedirectStandardOutput = true,
Arguments = "info --revision HEAD",
WorkingDirectory = @"C:\MyProject" // path to your svn working copy
});
// command "svn.exe info --revision HEAD" will produce a few lines of output
p.WaitForExit();
// our line starts with "Revision: "
while (!p.StandardOutput.EndOfStream)
{
string line = p.StandardOutput.ReadLine();
if (line.StartsWith("Revision: "))
{
string revision = line.Substring("Revision: ".Length);
Console.WriteLine(revision); // show revision number on screen
break;
}
}
Console.Read();
}
}
}
まっていNAntビルドファイルを取り扱う解析SVN情報の作成ます。その後、利用者のプロパティの値を種々の課題の設定、ラベルを作れます。その結果が、先ほど任天堂さんの目標にSVN改正Labellerによlubos hasko大きます。
<target name="svninfo" description="get the svn checkout information">
<property name="svn.infotempfile" value="${build.directory}\svninfo.txt" />
<exec program="${svn.executable}" output="${svn.infotempfile}">
<arg value="info" />
</exec>
<loadfile file="${svn.infotempfile}" property="svn.info" />
<delete file="${svn.infotempfile}" />
<property name="match" value="" />
<regex pattern="URL: (?'match'.*)" input="${svn.info}" />
<property name="svn.info.url" value="${match}"/>
<regex pattern="Repository Root: (?'match'.*)" input="${svn.info}" />
<property name="svn.info.repositoryroot" value="${match}"/>
<regex pattern="Revision: (?'match'\d+)" input="${svn.info}" />
<property name="svn.info.revision" value="${match}"/>
<regex pattern="Last Changed Author: (?'match'\w+)" input="${svn.info}" />
<property name="svn.info.lastchangedauthor" value="${match}"/>
<echo message="URL: ${svn.info.url}" />
<echo message="Repository Root: ${svn.info.repositoryroot}" />
<echo message="Revision: ${svn.info.revision}" />
<echo message="Last Changed Author: ${svn.info.lastchangedauthor}" />
</target>
見 この プロジェクトをgoogleのコードです。この CCNET
プラグインのラベル CCNET
.
の DLL
トされて CCNET 1.3
することが明らかと CCNET 1.4
ました。私たこのプラグインのラベルマ。
直接渡す MSBuild
...
希望の場合は、その MSBuild
側 CCNet
configのようになる MSBuild
地域の業務拡張の SvnVersion
タスクの立場から展開させていただきます。
私は現在、"手動でやる"というテーマによってprebuild-execタスクを使って、 cmdnetsvnrev ツールが誰かを知っていccnet-統合の方法は、嬉しい:-)
カスタマイズcsprojファイルautogenerate AssemblyInfo.cs
http://www.codeproject.com/KB/dotnet/Customizing_csproj_files.aspx毎回新しいC#プロジェクト、 Visual Studioをありの AssemblyInfo.csファイルです。ファイル 定義の組み立てメタデータのように そのバージョン設定、 プロデューサー。
見つかり、上記の手法を自動車-gen AssemblyInfo.csをMSBuild.今後のサンプルが視野に入ってまいりました。
さんがこの仕事CCNETなった SVN版のプラグイン のための 建版の増加 プロジェクトCodePlex.このツールは柔軟に設定可能で自動的に作成するバージョン番号を使用していまsvnに改訂される。必要としないことから書面で任意のコード編集、xmlといわーい!
これは立ちます♪
私のアプローチは、上記のプラグインのためのccnet、nantエコーのタスクを生成する VersionInfo.cs
ファイルを含むもの属性です。今回の VersionInfo.cs
ファイルの構築
エコータでの出力文字列のIでは、ファイルです。
がある場合は同様のMSBuildタスクに、そのまま使うことができます。この小さなnantタスクを使ってい:
<target name="version" description="outputs version number to VersionInfo.cs">
<echo file="${projectdir}/Properties/VersionInfo.cs">
[assembly: System.Reflection.AssemblyVersion("$(CCNetLabel)")]
[assembly: System.Reflection.AssemblyFileVersion("$(CCNetLabel)")]
</echo>
</target>
してみてください:
<ItemGroup>
<VersionInfoFile Include="VersionInfo.cs"/>
<VersionAttributes>
[assembly: System.Reflection.AssemblyVersion("${CCNetLabel}")]
[assembly: System.Reflection.AssemblyFileVersion("${CCNetLabel}")]
</VersionAttributes>
</ItemGroup>
<Target Name="WriteToFile">
<WriteLinesToFile
File="@(VersionInfoFile)"
Lines="@(VersionAttributes)"
Overwrite="true"/>
</Target>
ごん非常に親密になりMSBuild、スクリプトはどのように変動するという作業のボックスと必要な是正...
に基づくskolimas液を更新しNAntスクリプトも更新AssemblyFileVersion.コskolimaのコード!
<target name="setversion" description="Sets the version number to current label.">
<script language="C#">
<references>
<include name="System.dll" />
</references>
<imports>
<import namespace="System.Text.RegularExpressions" />
</imports>
<code><![CDATA[
[TaskName("setversion-task")]
public class SetVersionTask : Task
{
protected override void ExecuteTask()
{
StreamReader reader = new StreamReader(Project.Properties["filename"]);
string contents = reader.ReadToEnd();
reader.Close();
// replace assembly version
string replacement = "[assembly: AssemblyVersion(\"" + Project.Properties["label"] + "\")]";
contents = Regex.Replace(contents, @"\[assembly: AssemblyVersion\("".*""\)\]", replacement);
// replace assembly file version
replacement = "[assembly: AssemblyFileVersion(\"" + Project.Properties["label"] + "\")]";
contents = Regex.Replace(contents, @"\[assembly: AssemblyFileVersion\("".*""\)\]", replacement);
StreamWriter writer = new StreamWriter(Project.Properties["filename"], false);
writer.Write(contents);
writer.Close();
}
}
]]>
</code>
</script>
<foreach item="File" property="filename">
<in>
<items basedir="${srcDir}">
<include name="**\AssemblyInfo.cs"></include>
</items>
</in>
<do>
<setversion-task />
</do>
</foreach>
</target>
なか見つかります。私はこのインターネット上のどこかに".
この更新すべてのAssemblyInfo.csファイルは以前に構築します。
作品のような魅力です。すべての私exeとdllのショーとして1.2.3.333場合は"333"のSVN改正時までです。) (オリジナル版のAssemblyInfo.csファイルを思い切った計画を立ててみてはい"1.2.3.0")
$(ProjectDir)(my.slnファイル在住)
$(SVNToolPath)(ポイントsvn.exe)
私のカスタム変数を宣言/定義で定義されていない。
http://msbuildtasks.tigris.org/ および/または https://github.com/loresoft/msbuildtasks の(FileUpdateとSvnVersion)事ができます。
<Target Name="SubVersionBeforeBuildVersionTagItUp">
<ItemGroup>
<AssemblyInfoFiles Include="$(ProjectDir)\**\*AssemblyInfo.cs" />
</ItemGroup>
<SvnVersion LocalPath="$(MSBuildProjectDirectory)" ToolPath="$(SVNToolPath)">
<Output TaskParameter="Revision" PropertyName="MySubVersionRevision" />
</SvnVersion>
<FileUpdate Files="@(AssemblyInfoFiles)"
Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
ReplacementText="$1.$2.$3.$(MySubVersionRevision)" />
</Target>
編集--------------------------------------------------
上記の場合を開始失敗後、SVN改定数に達し65534ます。
参照:
ここでは、回避策.
<FileUpdate Files="@(AssemblyInfoFiles)"
Regex="AssemblyFileVersion\("(\d+)\.(\d+)\.(\d+)\.(\d+)"
ReplacementText="AssemblyFileVersion("$1.$2.$3.$(SubVersionRevision)" />
この結果をとるとき
Windows/Internet Explorer//ファイル/物性.......
組み立てのバージョン1.0.0.0.
ファイルのバージョン1.0.0.333場合333はSVNに改訂される。
注意しなくてはならない。の構造を有するビルド番号が一定であることが理由のひとつが天井かの高さに改定できます。
当社において思いを超えた。
しようとすると組み易いのではないかと思いビルド番号99.99.99.599999のファイルのバージョンプロパティが実際にしようとしてい99.99.99.10175.