Skip to content
This repository has been archived by the owner on Jan 27, 2019. It is now read-only.

Commit

Permalink
Add build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
yck1509 committed May 30, 2014
1 parent 06526b4 commit ea85b86
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ packages/
*.sln.*
gh-pages/
ConfuserEx.snk
GlobalAssemblyInfo.cs
/Build/*.zip
8 changes: 8 additions & 0 deletions Build/Build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off
%windir%\microsoft.net\framework\v4.0.30319\msbuild ..\Confuser2.sln /p:Configuration=Release "/p:Platform=Any CPU"
@IF %ERRORLEVEL% NEQ 0 GOTO err
7z a ConfuserEx_bin.zip -tzip @files.lst
@exit /B 0
:err
@PAUSE
@exit /B 1
54 changes: 54 additions & 0 deletions Build/UpdateVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Diagnostics;
using System.IO;

public static class Program {
public static int Main(string[] args) {
if (args.Length != 1) {
Console.WriteLine("invalid argument length.");
return -1;
}

string dir = args[0];
string ver = File.ReadAllText(Path.Combine(dir, "VERSION"));
string tag = null;

string gitDir = Path.Combine(dir, ".git");
if (!Directory.Exists(gitDir)) {
Console.WriteLine("git repository not found.");
}
else {
try {
var info = new ProcessStartInfo("git", "describe");
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
using (Process ps = Process.Start(info)) {
tag = ps.StandardOutput.ReadLine();
string[] infos = tag.Split('-');
if (infos.Length >= 3)
ver = ver + "." + infos[infos.Length - 2];
else
ver = ver + ".0";
ps.WaitForExit();
if (ps.ExitCode != 0) {
Console.WriteLine("error when executing git describe: " + ps.ExitCode);
}
}
}
catch {
Console.WriteLine("error when executing git describe.");
}
}
tag = tag ?? "v" + ver;

string template = Path.Combine(dir, "GlobalAssemblyInfo.Template.cs");
string output = Path.Combine(dir, "GlobalAssemblyInfo.cs");

string verInfo = File.ReadAllText(template);
verInfo = verInfo.Replace("{{VER}}", ver);
verInfo = verInfo.Replace("{{TAG}}", tag);
File.WriteAllText(output, verInfo);
Console.WriteLine("Version updated.");
return 0;
}
}
25 changes: 25 additions & 0 deletions Build/UpdateVersion.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1e74b523-aa86-42a0-8116-fff7cebfcba7}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>UpdateVersion</RootNamespace>
<AssemblyName>UpdateVersion</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>true</Optimize>
<OutputPath>.\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="UpdateVersion.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
9 changes: 9 additions & 0 deletions Build/files.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
..\Release\bin\Confuser.CLI.exe
..\Release\bin\Confuser.CLI.pdb
..\Release\bin\Confuser.Core.*
..\Release\bin\Confuser.DynCipher.*
..\Release\bin\Confuser.Protections.*
..\Release\bin\Confuser.Renamer.*
..\Release\bin\Confuser.Runtime.*
..\Release\bin\dnlib.*
..\Release\bin\System.Threading.dll
7 changes: 2 additions & 5 deletions Confuser.Core/Confuser.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,8 @@
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<!-- 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">
<MSBuild Projects="$(SolutionDir)\Build\UpdateVersion.csproj" Targets="Build" Properties="Configuration=Release" />
<Exec WorkingDirectory="$(SolutionDir)\Build" Command="UpdateVersion.exe $(SolutionDir)" Timeout="5000" />
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
3 changes: 3 additions & 0 deletions Confuser2.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Confuser.DynCipher", "Confuser.DynCipher\Confuser.DynCipher.csproj", "{E832E9B8-2158-4FC0-89A1-56C6ECC10F6B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Confuser.Runtime", "Confuser.Runtime\Confuser.Runtime.csproj", "{A45C184F-F98F-4258-A928-BFF437034791}"
ProjectSection(ProjectDependencies) = postProject
{BEB67A6E-4C54-4DE5-8C6B-2C12F44A7B92} = {BEB67A6E-4C54-4DE5-8C6B-2C12F44A7B92}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
6 changes: 3 additions & 3 deletions GlobalAssemblyInfo.cs → GlobalAssemblyInfo.Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
[assembly: AssemblyConfiguration("Release")]
#endif

[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("v0.1.0")]
[assembly: AssemblyVersion("{{VER}}")]
[assembly: AssemblyFileVersion("{{VER}}")]
[assembly: AssemblyInformationalVersion("{{TAG}}")]
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0

0 comments on commit ea85b86

Please sign in to comment.