Skip to content

Commit 9e8c25f

Browse files
committed
1 parent b75a88d commit 9e8c25f

File tree

1 file changed

+141
-1
lines changed

1 file changed

+141
-1
lines changed

SharpZlib.build

+141-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0"?>
22

3-
<project name="#ZLib" default="build" basedir=".">
3+
<project name="#ZipLib" default="build" basedir=".">
44
<property name="debug" value="False"/>
55
<property name="optimize" value="True"/>
6+
<property name="version" value="0.85.1"/>
67

78
<target name="build">
89
<!-- compile SharpZipLib -->
@@ -22,6 +23,145 @@
2223
<nant buildfile = "samples/vb/samples.build" />
2324
</target>
2425

26+
<target name="releasebuild">
27+
<script language="C#">
28+
<code><![CDATA[
29+
static StringCollection SearchDirectory(string directory, string filemask)
30+
{
31+
StringCollection collection = new StringCollection();
32+
SearchDirectory(directory, filemask, collection);
33+
return collection;
34+
}
35+
36+
static void SearchDirectory(string directory, string filemask, StringCollection collection)
37+
{
38+
try {
39+
string[] file = Directory.GetFiles(directory, filemask);
40+
foreach (string f in file) {
41+
collection.Add(f);
42+
}
43+
44+
string[] dir = Directory.GetDirectories(directory);
45+
foreach (string d in dir) {
46+
SearchDirectory(d, filemask, collection);
47+
}
48+
} catch (Exception) {
49+
}
50+
}
51+
52+
static Regex AssemblyVersion = new Regex("AssemblyVersion\\(.*\\)]");
53+
static void SetVersionInfo(string fileName, string version)
54+
{
55+
StreamReader inFile = null;
56+
string content;
57+
58+
try {
59+
inFile = new StreamReader(fileName);
60+
content = inFile.ReadToEnd();
61+
} catch (Exception e) {
62+
Console.WriteLine(e);
63+
return;
64+
} finally {
65+
if (inFile != null) {
66+
inFile.Close();
67+
}
68+
}
69+
70+
if (content != null) {
71+
string newContent = AssemblyVersion.Replace(content, "AssemblyVersion(\"" + version + "\")]");
72+
StreamWriter outFile = null;
73+
try {
74+
outFile = new StreamWriter(fileName);
75+
outFile.Write(newContent);
76+
} catch (Exception e) {
77+
Console.WriteLine(e);
78+
return;
79+
} finally {
80+
if (outFile != null) {
81+
outFile.Close();
82+
}
83+
}
84+
}
85+
}
86+
87+
static string revisionNumber = "0";
88+
static string ReadRevisionFromFile()
89+
{
90+
try {
91+
StreamReader reader = new StreamReader(@"REVISION");
92+
using (reader) {
93+
return reader.ReadLine();
94+
}
95+
}
96+
catch (Exception e) {
97+
Console.WriteLine(e.Message);
98+
throw new Exception("Cannot read revision number from file: " + e.Message);
99+
}
100+
}
101+
static void RetrieveRevisionNumber()
102+
{
103+
try {
104+
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("svn", "info");
105+
psi.UseShellExecute = false;
106+
psi.RedirectStandardOutput = true;
107+
108+
try {
109+
System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);
110+
process.WaitForExit();
111+
string output = process.StandardOutput.ReadToEnd();
112+
113+
Regex r = new Regex(@"Revision:\s+(\d+)");
114+
Match m = r.Match(output);
115+
if (m != null && m.Success && m.Groups[1] != null) {
116+
revisionNumber = m.Groups[1].Value;
117+
Console.WriteLine("SVN Version '{0}'", revisionNumber);
118+
}
119+
if (revisionNumber == null || revisionNumber.Equals("") || revisionNumber.Equals("0")) {
120+
throw new Exception("Could not find revision number in svn output");
121+
}
122+
} catch (Exception e) {
123+
Console.WriteLine(e.Message);
124+
revisionNumber = ReadRevisionFromFile();
125+
}
126+
} catch {
127+
}
128+
}
129+
130+
static void SetVersion(string directory, string version)
131+
{
132+
StringCollection col = SearchDirectory(directory, "AssemblyInfo.cs");
133+
string[] dontTouchList = new string[] {
134+
"samples/HttpCompressionModule/src/AssemblyInfo.cs",
135+
"samples/DIME/DimeDataSetService/AssemblyInfo.cs",
136+
"samples/DIME/DimeDataSetServiceConsumer/AssemblyInfo.cs",
137+
};
138+
string versionNumber = version + "." + revisionNumber;
139+
foreach (string fileName in col) {
140+
bool doSetVersion = true;
141+
foreach (string dontTouch in dontTouchList) {
142+
if (fileName.EndsWith(dontTouch.Replace("/", Path.DirectorySeparatorChar.ToString()))) {
143+
doSetVersion = false;
144+
break;
145+
}
146+
}
147+
if (doSetVersion) {
148+
Console.WriteLine("set revision to file : " + fileName + " to " + versionNumber);
149+
SetVersionInfo(fileName, versionNumber);
150+
}
151+
}
152+
}
153+
154+
public static void ScriptMain(Project project)
155+
{
156+
Console.WriteLine("Hello World");
157+
RetrieveRevisionNumber();
158+
SetVersion(".", project.Properties["version"].ToString());
159+
}
160+
]]></code>
161+
</script>
162+
<call target="build"/>
163+
</target>
164+
25165
<target name="clean">
26166
<delete verbose="true" >
27167
<fileset basedir=".">

0 commit comments

Comments
 (0)