From 8b127a3434bc5868ff0b06415106158ed0d8ed7a Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 13 Feb 2006 20:01:46 +0000 Subject: [PATCH] Use template file for SharpDevelop.exe.config to prevent Subversion conflicts. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1146 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- src/Main/StartUp/Project/StartUp.csproj | 1 + ...Develop.exe.config => app.template.config} | 16 +++++++--- src/Tools/UpdateAssemblyInfo/Main.cs | 29 +++++++++++++++++-- 3 files changed, 39 insertions(+), 7 deletions(-) rename src/Main/StartUp/Project/{SharpDevelop.exe.config => app.template.config} (75%) diff --git a/src/Main/StartUp/Project/StartUp.csproj b/src/Main/StartUp/Project/StartUp.csproj index 1135c9f0a4..2cbaded8da 100644 --- a/src/Main/StartUp/Project/StartUp.csproj +++ b/src/Main/StartUp/Project/StartUp.csproj @@ -73,6 +73,7 @@ Configuration\GlobalAssemblyInfo.template + \ No newline at end of file diff --git a/src/Main/StartUp/Project/SharpDevelop.exe.config b/src/Main/StartUp/Project/app.template.config similarity index 75% rename from src/Main/StartUp/Project/SharpDevelop.exe.config rename to src/Main/StartUp/Project/app.template.config index 7df7a9efc2..e0962764a1 100644 --- a/src/Main/StartUp/Project/SharpDevelop.exe.config +++ b/src/Main/StartUp/Project/app.template.config @@ -3,22 +3,30 @@
+ - + - + - + - + diff --git a/src/Tools/UpdateAssemblyInfo/Main.cs b/src/Tools/UpdateAssemblyInfo/Main.cs index 0497a33582..43d0d68425 100644 --- a/src/Tools/UpdateAssemblyInfo/Main.cs +++ b/src/Tools/UpdateAssemblyInfo/Main.cs @@ -17,10 +17,10 @@ namespace UpdateAssemblyInfo // Updates the version numbers in the assembly information. class MainClass { - static Regex AssemblyVersion = new Regex(@"AssemblyVersion\(.*\)]"); - static Regex BindingRedirect = new Regex(@""); const string templateFile = "Main/GlobalAssemblyInfo.template"; const string globalAssemblyInfo = "Main/GlobalAssemblyInfo.cs"; + const string configTemplateFile = "Main/StartUp/Project/app.template.config"; + const string configFile = "Main/StartUp/Project/SharpDevelop.exe.config"; public static int Main(string[] args) { @@ -38,7 +38,7 @@ namespace UpdateAssemblyInfo RetrieveRevisionNumber(); string versionNumber = GetMajorVersion() + "." + revisionNumber; UpdateStartup(); - SetVersionInfo("Main/StartUp/Project/SharpDevelop.exe.config", BindingRedirect, ""); + UpdateRedirectionConfig(versionNumber); return 0; } catch (Exception ex) { Console.WriteLine(ex); @@ -67,6 +67,29 @@ namespace UpdateAssemblyInfo } } + static Regex BindingRedirect = new Regex(@""); + + static void UpdateRedirectionConfig(string fullVersionNumber) + { + string content; + using (StreamReader r = new StreamReader(configTemplateFile)) { + content = r.ReadToEnd(); + } + content = content.Replace("$INSERTVERSION$", fullVersionNumber); + if (File.Exists(configFile)) { + using (StreamReader r = new StreamReader(configFile)) { + if (r.ReadToEnd() == content) { + // nothing changed, do not overwrite file to prevent recompilation + // every time. + return; + } + } + } + using (StreamWriter w = new StreamWriter(configFile, false, Encoding.UTF8)) { + w.Write(content); + } + } + static string GetMajorVersion() { string version = "?";