Created
July 7, 2010 08:11
-
-
Save anonymous/466455 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<configuration> | |
<configSections> | |
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > | |
<section name="auto_build.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> | |
</sectionGroup> | |
</configSections> | |
<applicationSettings> | |
<auto_build.Settings> | |
<setting name="SolutionName" serializeAs="String"> | |
<value>SolutionName</value> | |
</setting> | |
<setting name="SolutionPath" serializeAs="String"> | |
<value>D:\path\to\solution\here</value> | |
</setting> | |
<setting name="SetupProjectPath" serializeAs="String"> | |
<value>D:\path\to\solution\here\setup</value> | |
</setting> | |
<setting name="SvnPath" serializeAs="String"> | |
<value>C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe</value> | |
</setting> | |
<setting name="SvnUpdateCommand" serializeAs="String"> | |
<value>/command:update /path:"{0}" /notempfile /closeonend</value> | |
</setting> | |
<setting name="DevenvPath" serializeAs="String"> | |
<value>D:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe</value> | |
</setting> | |
<setting name="DevenvClean" serializeAs="String"> | |
<value>{0}\{1}.sln /clean</value> | |
</setting> | |
<setting name="DevenvBuildRelease" serializeAs="String"> | |
<value>{0}\{1}.sln /build Release</value> | |
</setting> | |
<setting name="WinrarPath" serializeAs="String"> | |
<value>C:\Program Files\WinRAR\WinRAR.exe</value> | |
</setting> | |
<setting name="WinrarPathArgsForCreatingAnArchive" serializeAs="String"> | |
<value>a -afzip -ep {1}\{0} {1}\*.*</value> | |
</setting> | |
<setting name="DestPath" serializeAs="String"> | |
<value>\\qa_server\Projects\path\abc\project_name\</value> | |
</setting> | |
<setting name="AssemblyInfoPath" serializeAs="String"> | |
<value>{0}\Properties\AssemblyInfo.cs</value> | |
</setting> | |
<setting name="SolutionRoot" serializeAs="String"> | |
<value>D:\work_items\project\</value> | |
</setting> | |
<setting name="ZipFileApplicationName" serializeAs="String"> | |
<value>ProjectName</value> | |
</setting> | |
<setting name="ZipFileNameDateTimeFormat" serializeAs="String"> | |
<value>dd-MM-yyyy_h-mm-tt</value> | |
</setting> | |
<setting name="ZipFileNameFormat" serializeAs="String"> | |
<value>{0}_v{1}_Setup_{2}.zip</value> | |
</setting> | |
</auto_build.Settings> | |
</applicationSettings> | |
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region | |
using System; | |
using System.Diagnostics; | |
using System.IO; | |
#endregion | |
namespace auto_build | |
{ | |
internal class Program | |
{ | |
private const string Title = "auto_build v0.01"; | |
private static void Main(string[] args) | |
{ | |
Console.Title = Title; | |
var settings = Settings.Default; | |
PSeperator(); | |
P(Title); | |
PSeperator(); | |
P("Settings"); | |
PSeperator(); | |
P("Updating Source from SVN..."); | |
Run(settings.SvnPath, string.Format(settings.SvnUpdateCommand, settings.SolutionRoot)); | |
PBlankLine(); | |
P("Cleaning Solution..."); | |
Run(settings.DevenvPath, string.Format(settings.DevenvClean, settings.SolutionPath, settings.SolutionName)); | |
PBlankLine(); | |
P("Building (Release Config) Solution..."); | |
Run(settings.DevenvPath, | |
string.Format(settings.DevenvBuildRelease, settings.SolutionPath, settings.SolutionName)); | |
PBlankLine(); | |
P("Zipping the Setup..."); | |
//ex: "NAME-SG v1.0.0.3106 Setup 06-Jul-2010 10-40" | |
var zipFilePath = string.Format("{0}\\Release", settings.SetupProjectPath); | |
var zipFileName = string.Format(settings.ZipFileNameFormat, settings.ZipFileApplicationName, | |
GetProjectVersion(), | |
DateTime.Now.ToString(settings.ZipFileNameDateTimeFormat)); | |
Run(settings.WinrarPath, | |
string.Format(settings.WinrarPathArgsForCreatingAnArchive, zipFileName, zipFilePath)); | |
PBlankLine(); | |
P("Coping the zipped archive to the destanation..."); | |
var directory = | |
Directory.CreateDirectory(string.Format("{0}//v{1}", settings.DestPath, GetProjectVersion())); | |
File.Move(string.Format("{0}//{1}", zipFilePath, zipFileName), | |
string.Format("{0}//{1}", directory.FullName, zipFileName)); | |
PBlankLine(); | |
P("Done!"); | |
P("Press any key to exit..."); | |
Console.ReadLine(); | |
} | |
private static string GetProjectVersion() | |
{ | |
using ( | |
var reader = | |
new StreamReader( | |
new FileStream(string.Format(Settings.Default.AssemblyInfoPath, Settings.Default.SolutionPath), | |
FileMode.Open, FileAccess.Read))) | |
{ | |
while (!reader.EndOfStream) | |
{ | |
var line = reader.ReadLine(); | |
if (!line.Contains("// [assembly: AssemblyVersion(\"") && | |
line.Contains("[assembly: AssemblyVersion(\"")) | |
{ | |
var start = line.IndexOf("[assembly: AssemblyVersion(\"") + | |
"[assembly: AssemblyVersion(\"".Length; | |
var end = line.IndexOf("\")]"); | |
var length = end - start; | |
return line.Substring(start, length); | |
} | |
} | |
} | |
return "x.x.x.x"; //couldn't find the assebmly version | |
} | |
private static string Run(string command, string paras) | |
{ | |
var pProcess = new Process | |
{ | |
StartInfo = | |
{ | |
FileName = command, | |
Arguments = paras, | |
UseShellExecute = false, | |
RedirectStandardOutput = true | |
} | |
}; | |
pProcess.Start(); | |
//Get program output | |
var strOutput = pProcess.StandardOutput.ReadToEnd(); | |
pProcess.WaitForExit(); | |
return strOutput; | |
} | |
#region Console Text Output Helpers | |
private static void P(string text) | |
{ | |
Console.WriteLine(text); | |
} | |
private static void PBlankLine() | |
{ | |
P(string.Empty); | |
} | |
private static void PSeperator() | |
{ | |
PBlankLine(); | |
P("------------------------------------------------------"); | |
PBlankLine(); | |
} | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment