mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-21 18:52:36 +01:00
Make sure AssemblyInfo.cs exists when starting from scratch II
This commit is contained in:
parent
db350534cb
commit
7037fef9e9
1
.gitignore
vendored
1
.gitignore
vendored
@ -25,3 +25,4 @@ SubtitleEdit-*-setup.exe
|
|||||||
/src/.nuget/NuGet.exe
|
/src/.nuget/NuGet.exe
|
||||||
/src/.nuget/NuGet.Config
|
/src/.nuget/NuGet.Config
|
||||||
/src/packages/
|
/src/packages/
|
||||||
|
/libse/Properties/AssemblyInfo.cs
|
||||||
|
@ -12,7 +12,7 @@ namespace UpdateAssemblyInfo
|
|||||||
public string Version { get; set; }
|
public string Version { get; set; }
|
||||||
public string RevisionGuid { get; set; }
|
public string RevisionGuid { get; set; }
|
||||||
public string BuildNumber { get; set; }
|
public string BuildNumber { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UpdateAssemblyInfo(string templateFileName, VersionInfo versionInfo)
|
private static void UpdateAssemblyInfo(string templateFileName, VersionInfo versionInfo)
|
||||||
{
|
{
|
||||||
@ -44,7 +44,7 @@ namespace UpdateAssemblyInfo
|
|||||||
original = original.Substring(0, begin) + versionInfo.Version + original.Remove(0, end);
|
original = original.Substring(0, begin) + versionInfo.Version + original.Remove(0, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (l.StartsWith("[assembly: AssemblyDescription", StringComparison.Ordinal) ||
|
else if (l.StartsWith("[assembly: AssemblyDescription", StringComparison.Ordinal) ||
|
||||||
l.StartsWith("[assembly:AssemblyDescription", StringComparison.Ordinal))
|
l.StartsWith("[assembly:AssemblyDescription", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
@ -71,46 +71,46 @@ namespace UpdateAssemblyInfo
|
|||||||
|
|
||||||
private static VersionInfo GetOldVersionNumber(string subtitleEditTemplateFileName)
|
private static VersionInfo GetOldVersionNumber(string subtitleEditTemplateFileName)
|
||||||
{
|
{
|
||||||
var version = new VersionInfo { Version = "1.0.0.0", RevisionGuid = "0" };
|
var version = new VersionInfo { Version = "1.0.0.0", RevisionGuid = "0", BuildNumber = "0" };
|
||||||
var lines = File.ReadAllLines(subtitleEditTemplateFileName.Replace(".template", string.Empty));
|
var oldFileName = subtitleEditTemplateFileName.Replace(".template", string.Empty);
|
||||||
foreach (var line in lines)
|
if (File.Exists(oldFileName))
|
||||||
{
|
{
|
||||||
var l = line.Trim();
|
var lines = File.ReadAllLines(oldFileName);
|
||||||
while (l.Contains(" "))
|
foreach (var line in lines)
|
||||||
{
|
{
|
||||||
l = l.Replace(" ", " ");
|
var l = line.Trim();
|
||||||
}
|
while (l.Contains(" "))
|
||||||
if (l.StartsWith("[assembly: AssemblyVersion", StringComparison.Ordinal) ||
|
|
||||||
l.StartsWith("[assembly:AssemblyVersion", StringComparison.Ordinal) ||
|
|
||||||
l.StartsWith("[assembly: AssemblyFileVersion", StringComparison.Ordinal) ||
|
|
||||||
l.StartsWith("[assembly:AssemblyFileVersion", StringComparison.Ordinal))
|
|
||||||
{
|
|
||||||
int begin = l.IndexOf('"');
|
|
||||||
int end = l.LastIndexOf('"');
|
|
||||||
if (end > begin && begin > 0)
|
|
||||||
{
|
{
|
||||||
begin++;
|
l = l.Replace(" ", " ");
|
||||||
version.Version = l.Substring(begin, end - begin);
|
|
||||||
version.BuildNumber = version.Version.Substring(version.Version.LastIndexOf('.') + 1);
|
|
||||||
}
|
}
|
||||||
}
|
if (l.StartsWith("[assembly: AssemblyVersion", StringComparison.Ordinal) ||
|
||||||
else if (l.StartsWith("[assembly: AssemblyDescription", StringComparison.Ordinal) ||
|
l.StartsWith("[assembly:AssemblyVersion", StringComparison.Ordinal) ||
|
||||||
l.StartsWith("[assembly:AssemblyDescription", StringComparison.Ordinal))
|
l.StartsWith("[assembly: AssemblyFileVersion", StringComparison.Ordinal) ||
|
||||||
{
|
l.StartsWith("[assembly:AssemblyFileVersion", StringComparison.Ordinal))
|
||||||
int begin = l.IndexOf("\"", StringComparison.Ordinal);
|
|
||||||
int end = l.LastIndexOf("\"", StringComparison.Ordinal);
|
|
||||||
if (end > begin && begin > 0)
|
|
||||||
{
|
{
|
||||||
begin++;
|
int begin = l.IndexOf('"');
|
||||||
version.RevisionGuid = l.Substring(begin, end - begin);
|
int end = l.LastIndexOf('"');
|
||||||
|
if (end > begin && begin > 0)
|
||||||
|
{
|
||||||
|
begin++;
|
||||||
|
version.Version = l.Substring(begin, end - begin);
|
||||||
|
version.BuildNumber = version.Version.Substring(version.Version.LastIndexOf('.') + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (l.StartsWith("[assembly: AssemblyDescription", StringComparison.Ordinal) ||
|
||||||
|
l.StartsWith("[assembly:AssemblyDescription", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
int begin = l.IndexOf("\"", StringComparison.Ordinal);
|
||||||
|
int end = l.LastIndexOf("\"", StringComparison.Ordinal);
|
||||||
|
if (end > begin && begin > 0)
|
||||||
|
{
|
||||||
|
begin++;
|
||||||
|
version.RevisionGuid = l.Substring(begin, end - begin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (string.IsNullOrWhiteSpace(version.Version))
|
return version;
|
||||||
{
|
|
||||||
Console.WriteLine("WARNING: Could not find version number - will use 1.0.0");
|
|
||||||
}
|
|
||||||
return version;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static VersionInfo GetNewVersion()
|
private static VersionInfo GetNewVersion()
|
||||||
|
Loading…
Reference in New Issue
Block a user