-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
82 changed files
with
2,016 additions
and
1,101 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
Param( | ||
[Parameter(Position=0)] | ||
[alias("nv")] | ||
[ValidateSet('Y','N')] | ||
[System.String]$NewVersionUpdate | ||
) | ||
|
||
Add-Type -A 'System.IO.Compression.FileSystem' | ||
$OldVersion = Get-Content src\CurrentVersion.info | ||
|
||
Write-Host "Current Version Number Is: $OldVersion" | ||
|
||
if($NewVersionUpdate.toLower() -eq "y") | ||
{ | ||
$NewVersion = Read-Host "Enter New Version Number" | ||
if($NewVersion -eq "") | ||
{ | ||
$NewVersion = $OldVersion | ||
} | ||
try | ||
{ | ||
New-Item src\CurrentVersion.info -type file -force -value $NewVersion | ||
Get-ChildItem -Path "src" -Include AssemblyInfo.cs -Recurse | Foreach-Object { | ||
$newFile = Get-Content $_ -encoding "UTF8" | Foreach-Object { | ||
if ($_.StartsWith("[assembly: AssemblyVersion")) { | ||
'[assembly: AssemblyVersion("' + $NewVersion + '")]' | ||
} else { | ||
if ($_.StartsWith("[assembly: AssemblyFileVersion")) { | ||
'[assembly: AssemblyFileVersion("' + $NewVersion + '")]' | ||
} else { | ||
$_ | ||
} | ||
} | ||
} | ||
|
||
$newFile | set-Content $_ -encoding "UTF8" | ||
} | ||
|
||
Get-ChildItem -Path "src" -Include "*.csproj" -Recurse | Foreach-Object { | ||
$newFile = Get-Content $_ -encoding "UTF8" | Foreach-Object { | ||
if ($_.StartsWith(" <MinimumRequiredVersion>")) { | ||
" <MinimumRequiredVersion>$NewVersion</MinimumRequiredVersion>" | ||
} else { | ||
if ($_.StartsWith(" <ApplicationVersion>")) { | ||
" <ApplicationVersion>$NewVersion</ApplicationVersion>" | ||
} else { | ||
$_ | ||
} | ||
} | ||
} | ||
|
||
$newFile | set-Content $_ -encoding "UTF8" | ||
} | ||
|
||
$newFile = Get-Content F:\GIT\Gallifrey\src\Gallifrey.UI.Modern\ChangeLog.xml -encoding "UTF8" | Foreach-Object { | ||
if ($_.Contains(' Name="Pre-Release"')) { | ||
' <Version Number="' + $NewVersion + '" Name="Pre-Release">' | ||
} else { | ||
$_ | ||
} | ||
} | ||
|
||
$newFile | set-Content F:\GIT\Gallifrey\src\Gallifrey.UI.Modern\ChangeLog.xml -encoding "UTF8" | ||
} | ||
Catch | ||
{ | ||
Write-Host "Error Updating Versions, Will Not Build" | ||
Break | ||
} | ||
} | ||
|
||
Write-Host "Restoring Packages" | ||
if(Test-Path "Output") | ||
{ | ||
Remove-Item "Output\*" -recurse | ||
} | ||
.paket\paket.bootstrapper.exe | ||
.paket\paket.exe restore | ||
if(-Not ($ENV:PATH -like "*MSBuild*")) | ||
{ | ||
if(Test-Path "${Env:ProgramFiles(x86)}\MSBuild\14.0\bin") | ||
{ | ||
$ENV:Path = $ENV:Path + ";${Env:ProgramFiles(x86)}\MSBuild\14.0\bin" | ||
} | ||
if(Test-Path "${Env:ProgramFiles(x86)}\MSBuild\14.0\bin") | ||
{ | ||
$ENV:Path = $ENV:Path + ";${Env:ProgramFiles(x86)}\MSBuild\14.0\bin" | ||
} | ||
} | ||
|
||
Write-Host "Doing Build" | ||
msbuild.exe src\Gallifrey.sln /target:Clean,Rebuild,publish /property:Configuration=Release | ||
|
||
Write-Host "Copy Published Items" | ||
Copy-Item src\Gallifrey.UI.Modern.Alpha\bin\Release\app.publish\ Output\alpha -recurse | ||
Copy-Item src\Gallifrey.UI.Modern.Beta\bin\Release\app.publish\ Output\beta -recurse | ||
Copy-Item src\Gallifrey.UI.Modern.Stable\bin\Release\app.publish\ Output\stable -recurse | ||
|
||
Write-Host "Create App Zips" | ||
[IO.Compression.ZipFile]::CreateFromDirectory('Output\alpha', 'Output\alpha.zip') | ||
[IO.Compression.ZipFile]::CreateFromDirectory('Output\beta', 'Output\beta.zip') | ||
[IO.Compression.ZipFile]::CreateFromDirectory('Output\stable', 'Output\stable.zip') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Param( | ||
[Parameter(Position=0)] | ||
[alias("t")] | ||
[ValidateSet('alpha','beta','stable')] | ||
[System.String]$ReleaseType | ||
) | ||
|
||
if($ReleaseType -eq "") | ||
{ | ||
Write-Host "No Release Type Entered" | ||
} | ||
else | ||
{ | ||
Write-Host "Publishing $ReleaseType To Releases Repo" | ||
Copy-Item Output\$ReleaseType\ ..\Gallifrey.Releases\download\modern\ -recurse -force | ||
Write-Host "Published $ReleaseType" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
<Query Kind="Program"> | ||
<Reference><RuntimeDirectory>\System.Security.dll</Reference> | ||
<Namespace>System.Security.Cryptography</Namespace> | ||
</Query> | ||
|
||
string path = @"F:\GIT\Gallifrey.Releases\download\PremiumInstanceIds"; | ||
|
||
void Main() | ||
{ | ||
var running = true; | ||
while(running) | ||
{ | ||
Console.WriteLine("Enter Command (Show/Add/Remove/Done)"); | ||
var command = Console.ReadLine(); | ||
Util.ClearResults(); | ||
switch (command.ToLower()) | ||
{ | ||
case "show": | ||
ShowFileContent(); | ||
break; | ||
case "add": | ||
DoAdd(); | ||
break; | ||
case "remove": | ||
DoRemove(); | ||
break; | ||
case "done": | ||
running = false; | ||
break; | ||
default: | ||
Console.WriteLine("Unknown Function {0}", command); | ||
break; | ||
} | ||
Console.WriteLine(""); | ||
Console.WriteLine(""); | ||
} | ||
|
||
} | ||
|
||
private void ShowFileContent() | ||
{ | ||
DecryptFile(); | ||
var data = File.ReadAllText(path); | ||
EncryptFile(); | ||
Console.WriteLine(data); | ||
} | ||
|
||
private void DoAdd() | ||
{ | ||
Console.WriteLine("Enter InstanceId To Add"); | ||
var instanceId = Console.ReadLine(); | ||
Console.WriteLine("Enter Details (Name/Reason)"); | ||
var detail = Console.ReadLine(); | ||
var infoToAdd = string.Format("{0} - {1}",instanceId,detail); | ||
DecryptFile(); | ||
var lines = File.ReadAllLines(path).ToList(); | ||
lines.Add(infoToAdd); | ||
File.WriteAllLines(path, lines); | ||
EncryptFile(); | ||
Console.WriteLine("Added: {0}", infoToAdd); | ||
} | ||
|
||
private void DoRemove() | ||
{ | ||
Console.WriteLine("Enter InstanceId To Remove"); | ||
var instanceId = Console.ReadLine(); | ||
DecryptFile(); | ||
var lines = new List<string>(); | ||
var removed = false; | ||
foreach (string line in File.ReadAllLines(path)) | ||
{ | ||
if(!line.StartsWith(instanceId)) | ||
{ | ||
lines.Add(line); | ||
} | ||
else | ||
{ | ||
removed = true; | ||
} | ||
} | ||
File.WriteAllLines(path, lines); | ||
EncryptFile(); | ||
if(removed) | ||
{ | ||
Console.WriteLine("Removed: {0}", instanceId); | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Unable to locate: {0}", instanceId); | ||
} | ||
} | ||
|
||
private void DecryptFile() | ||
{ | ||
File.WriteAllText(path, DataEncryption.Decrypt(File.ReadAllText(path))); | ||
} | ||
|
||
private void EncryptFile() | ||
{ | ||
File.WriteAllText(path, DataEncryption.Encrypt(File.ReadAllText(path))); | ||
} | ||
|
||
internal static class DataEncryption | ||
{ | ||
//TODO: Maybe these shouldn't be stored in plain code? | ||
//TODO: Though, this is to make hacking the app settings a pain, rather than pure security. | ||
private const string PassPhrase = "WOq2kKSbvHTcKp9e"; | ||
private const string InitVector = "pId6i1bN1aCVTaHN"; | ||
private const int Keysize = 256; | ||
|
||
internal static string Encrypt(string plainText) | ||
{ | ||
var initVectorBytes = Encoding.UTF8.GetBytes(InitVector); | ||
var plainTextBytes = Encoding.UTF8.GetBytes(plainText); | ||
var password = new PasswordDeriveBytes(PassPhrase, null); | ||
var keyBytes = password.GetBytes(Keysize / 8); | ||
var symmetricKey = new RijndaelManaged { Mode = CipherMode.CBC }; | ||
var encryptor = symmetricKey.CreateEncryptor(keyBytes, initVectorBytes); | ||
|
||
using (var memoryStream = new MemoryStream()) | ||
{ | ||
using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write)) | ||
{ | ||
cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length); | ||
cryptoStream.FlushFinalBlock(); | ||
var cipherTextBytes = memoryStream.ToArray(); | ||
return Convert.ToBase64String(cipherTextBytes); | ||
} | ||
} | ||
} | ||
|
||
internal static string Decrypt(string cipherText) | ||
{ | ||
var initVectorBytes = Encoding.ASCII.GetBytes(InitVector); | ||
var cipherTextBytes = Convert.FromBase64String(cipherText); | ||
var password = new PasswordDeriveBytes(PassPhrase, null); | ||
var keyBytes = password.GetBytes(Keysize / 8); | ||
var symmetricKey = new RijndaelManaged { Mode = CipherMode.CBC }; | ||
var decryptor = symmetricKey.CreateDecryptor(keyBytes, initVectorBytes); | ||
|
||
using (var memoryStream = new MemoryStream(cipherTextBytes)) | ||
{ | ||
using (var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read)) | ||
{ | ||
var plainTextBytes = new byte[cipherTextBytes.Length]; | ||
var decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length); | ||
|
||
return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount); | ||
} | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.2.0.0 |
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
Oops, something went wrong.