PostBuild script
This commit is contained in:
parent
204313624e
commit
4177294250
40
PostBuild.cs
Normal file
40
PostBuild.cs
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
//Variables
|
||||||
|
string TargetDir = args[0];
|
||||||
|
string TargetFileName = args[1];
|
||||||
|
if (TargetDir.EndsWith("\\"))
|
||||||
|
TargetDir = TargetDir.Remove(TargetDir.Length - 1);
|
||||||
|
//Copy Data dir
|
||||||
|
if (File.Exists(TargetDir + ".zip"))
|
||||||
|
File.Delete(TargetDir + ".zip");
|
||||||
|
if (File.Exists(TargetDir + @"\package.zip"))
|
||||||
|
File.Delete(TargetDir + @"\package.zip");
|
||||||
|
if (Directory.Exists(TargetDir + @"\package"))
|
||||||
|
Directory.Delete(TargetDir + @"\package", true);
|
||||||
|
ZipFile.CreateFromDirectory(TargetDir, TargetDir + ".zip");
|
||||||
|
Directory.CreateDirectory(TargetDir + @"\package\Data");
|
||||||
|
ZipFile.ExtractToDirectory(TargetDir + ".zip", TargetDir + @"\package\Data");
|
||||||
|
File.Delete(TargetDir + ".zip");
|
||||||
|
//Remove useless Files
|
||||||
|
Directory.GetFiles(TargetDir + @"\package\Data")
|
||||||
|
.Where(s => new string[] { ".xml", ".pdb" }.Contains(Path.GetExtension(s)))
|
||||||
|
.ToList().ForEach(s => File.Delete(s));
|
||||||
|
//Add package scripts
|
||||||
|
string programName = Path.GetFileNameWithoutExtension(TargetFileName);
|
||||||
|
File.WriteAllText(TargetDir + @"\package\Install.bat",
|
||||||
|
"@echo off\r\necho INSTALL\r\npowershell \"$s=(New-Object -COM WScript.Shell).CreateShortcut('%appdata%\\Microsoft\\Windows\\Start Menu\\Programs\\" + programName + ".lnk');$s.TargetPath='%cd%\\" + programName + ".exe';$s.Save()\"\r\ntimeout /t 1");
|
||||||
|
File.WriteAllText(TargetDir + @"\package\Remove.bat",
|
||||||
|
"@echo off\r\necho REMOVE\r\ndel \"%appdata%\\Microsoft\\Windows\\Start Menu\\Programs\\" + programName + ".lnk\"\r\ntaskkill /f /im \"" + programName + ".exe\"\r\ntimeout /t 1");
|
||||||
|
//Package up result
|
||||||
|
ZipFile.CreateFromDirectory(TargetDir + @"\package", TargetDir + @"\package.zip");
|
||||||
|
Directory.Delete(TargetDir + @"\package", true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cashew", "cashew\cashew.csp
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B438CEFA-611B-4DD2-B1CE-EE62976A6BDE}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B438CEFA-611B-4DD2-B1CE-EE62976A6BDE}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
PostBuild.cs = PostBuild.cs
|
||||||
README.md = README.md
|
README.md = README.md
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
|
|
@ -219,8 +219,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>cd $(TargetDir)
|
<PostBuildEvent>cd $(SolutionDir)
|
||||||
if $(ConfigurationName)==Release del *.xml
|
if $(ConfigurationName)==Release C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe PostBuild.cs /r:System.IO.Compression.FileSystem.dll & PostBuild $(TargetDir) $(TargetFileName) & del PostBuild.exe</PostBuildEvent>
|
||||||
if $(ConfigurationName)==Release del *.pdb</PostBuildEvent>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
Reference in New Issue
Block a user