mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-21 18:52:36 +01:00
Add UpdateAssemblyDescription source to the repository.
This commit is contained in:
parent
2626a0bde3
commit
803c3ca2d2
6
src/UpdateAssemblyDescription/App.config
Normal file
6
src/UpdateAssemblyDescription/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
43
src/UpdateAssemblyDescription/CommandLineRunner.cs
Normal file
43
src/UpdateAssemblyDescription/CommandLineRunner.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace UpdateAssemblyDescription
|
||||
{
|
||||
public class CommandLineRunner
|
||||
{
|
||||
public string Result { get; set; }
|
||||
|
||||
public bool RunCommandAndGetOutput(string command, string arguments, string workingFolder)
|
||||
{
|
||||
var p = new Process();
|
||||
p.StartInfo.FileName = command;
|
||||
p.StartInfo.Arguments = arguments;
|
||||
p.StartInfo.WorkingDirectory = workingFolder;
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
p.StartInfo.RedirectStandardInput = true;
|
||||
p.StartInfo.RedirectStandardOutput = true;
|
||||
p.StartInfo.CreateNoWindow = true;
|
||||
p.OutputDataReceived += _mplayer_OutputDataReceived;
|
||||
|
||||
try
|
||||
{
|
||||
p.Start();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
p.BeginOutputReadLine(); // Async reading of output to prevent deadlock
|
||||
if (p.WaitForExit(9000))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void _mplayer_OutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
if (e != null && e.Data != null)
|
||||
Result = e.Data;
|
||||
}
|
||||
}
|
||||
}
|
86
src/UpdateAssemblyDescription/Program.cs
Normal file
86
src/UpdateAssemblyDescription/Program.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace UpdateAssemblyDescription
|
||||
{
|
||||
class Program
|
||||
{
|
||||
|
||||
private static string GetGitPath()
|
||||
{
|
||||
string p = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), @"Git\bin\git.exe");
|
||||
if (File.Exists(p))
|
||||
return p;
|
||||
|
||||
p = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles(x86)"), @"Git\bin\git.exe");
|
||||
if (File.Exists(p))
|
||||
return p;
|
||||
|
||||
p = @"C:\Program Files\Git\bin\git.exe";
|
||||
if (File.Exists(p))
|
||||
return p;
|
||||
|
||||
p = @"C:\Program Files (x86)\Git\bin\git.exe";
|
||||
if (File.Exists(p))
|
||||
return p;
|
||||
|
||||
p = @"C:\Git\bin\git.exe";
|
||||
if (File.Exists(p))
|
||||
return p;
|
||||
|
||||
return "git";
|
||||
}
|
||||
|
||||
private static void DoUpdateAssemblyDescription(string gitHash, string template, string target)
|
||||
{
|
||||
string templateData = File.ReadAllText(template);
|
||||
string fixedData = templateData.Replace("[GITHASH]", gitHash);
|
||||
File.WriteAllText(target, fixedData);
|
||||
}
|
||||
|
||||
static int Main(string[] args)
|
||||
{
|
||||
string errorFileName = System.Reflection.Assembly.GetEntryAssembly().Location.Replace(".exe", "_error.txt");
|
||||
|
||||
if (args.Length != 2)
|
||||
{
|
||||
Console.WriteLine("UpdateAssemblyDescription 0.9");
|
||||
Console.WriteLine("UpdateAssemblyDescription <template with [GITHASH]> <target file>");
|
||||
File.WriteAllText(errorFileName, "Wrong number of arguments: " + args.Length);
|
||||
return 1;
|
||||
}
|
||||
|
||||
string workingFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
|
||||
string template = args[0];
|
||||
string target = args[1];
|
||||
|
||||
var clr = new CommandLineRunner();
|
||||
var rc = clr.RunCommandAndGetOutput(GetGitPath(), "rev-parse --verify HEAD", workingFolder);
|
||||
if (rc)
|
||||
{
|
||||
try
|
||||
{
|
||||
DoUpdateAssemblyDescription(clr.Result, template, target);
|
||||
return 0;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
File.WriteAllText(errorFileName, e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Error running Git");
|
||||
Console.WriteLine(" - git folder: " + workingFolder);
|
||||
Console.WriteLine(" - template: " + template);
|
||||
Console.WriteLine(" - target: " + target);
|
||||
File.WriteAllText(errorFileName, " - git folder: " + workingFolder + Environment.NewLine +
|
||||
" - template: " + template + Environment.NewLine +
|
||||
" - target: " + target);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
36
src/UpdateAssemblyDescription/Properties/AssemblyInfo.cs
Normal file
36
src/UpdateAssemblyDescription/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("UpdateAssemblyDescription")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("UpdateAssemblyDescription")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("07219928-b0da-484d-a7de-b3d9470e2e57")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{DBD4656C-5F40-4067-A70B-C4460DE20F77}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>UpdateAssemblyDescription</RootNamespace>
|
||||
<AssemblyName>UpdateAssemblyDescription</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CommandLineRunner.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user