Skip to content

Commit

Permalink
Add build scripts and fix errors on win/osx
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreye committed Aug 6, 2018
1 parent 638fbcd commit faadac7
Show file tree
Hide file tree
Showing 11 changed files with 549 additions and 47 deletions.
1 change: 0 additions & 1 deletion AvaloniaILSpy.Controls/AvaloniaILSpy.Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<None Include="license.txt" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="4.5.0" />
<PackageReference Include="Avalonia" Version="0.6.2-build5873-beta" />
</ItemGroup>
<ItemGroup>
Expand Down
84 changes: 51 additions & 33 deletions AvaloniaILSpy.Controls/Consts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,65 @@ public static class SystemParameters

public static class SystemColors
{
public static IBrush ControlTextBrush { get; } = System.Drawing.SystemBrushes.ControlText.ToAvaloniaBrush();
public static IBrush ControlDarkBrush { get; } = System.Drawing.SystemBrushes.ControlDark.ToAvaloniaBrush();
public static IBrush HighlightBrush { get; } = System.Drawing.SystemBrushes.HighlightText.ToAvaloniaBrush();
public static IBrush HighlightTextBrush { get; } = System.Drawing.SystemBrushes.HighlightText.ToAvaloniaBrush();
public static IBrush WindowTextBrush { get; } = System.Drawing.SystemBrushes.WindowText.ToAvaloniaBrush();
public static IBrush WindowBrush { get; } = System.Drawing.SystemBrushes.Window.ToAvaloniaBrush();
public static IBrush GrayTextBrush { get; } = System.Drawing.SystemBrushes.GrayText.ToAvaloniaBrush();
public static IBrush InfoTextBrush { get; } = System.Drawing.SystemBrushes.InfoText.ToAvaloniaBrush();
public static IBrush InfoBrush { get; } = System.Drawing.SystemBrushes.Info.ToAvaloniaBrush();
public static IBrush InactiveCaptionBrush { get; } = System.Drawing.SystemBrushes.InactiveCaption.ToAvaloniaBrush();
public static IBrush InactiveCaptionTextBrush { get; } = System.Drawing.SystemBrushes.InactiveCaptionText.ToAvaloniaBrush();
public static IBrush ControlTextBrush {get;} = new ImmutableSolidColorBrush(Color.FromUInt32(0xFF000000));
public static IBrush ControlDarkBrush {get;} = new ImmutableSolidColorBrush(Color.FromUInt32(0xFFA0A0A0));
public static IBrush HighlightBrush {get;} = new ImmutableSolidColorBrush(Color.FromUInt32(0xFFFFFFFF));
public static IBrush HighlightTextBrush {get;} = new ImmutableSolidColorBrush(Color.FromUInt32(0xFFFFFFFF));
public static IBrush WindowTextBrush {get;} = new ImmutableSolidColorBrush(Color.FromUInt32(0xFF000000));
public static IBrush WindowBrush {get;} = new ImmutableSolidColorBrush(Color.FromUInt32(0xFFFFFFFF));
public static IBrush GrayTextBrush {get;} = new ImmutableSolidColorBrush(Color.FromUInt32(0xFF6D6D6D));
public static IBrush InfoTextBrush {get;} = new ImmutableSolidColorBrush(Color.FromUInt32(0xFF000000));
public static IBrush InfoBrush {get;} = new ImmutableSolidColorBrush(Color.FromUInt32(0xFFFFFFE1));
public static IBrush InactiveCaptionBrush {get;} = new ImmutableSolidColorBrush(Color.FromUInt32(0xFFBFCDDB));
public static IBrush InactiveCaptionTextBrush {get;} = new ImmutableSolidColorBrush(Color.FromUInt32(0xFF000000));
public static Color ControlLightColor {get;} = Color.FromUInt32(0xFFE3E3E3);
public static Color ControlLightLightColor {get;} = Color.FromUInt32(0xFFFFFFFF);
public static Color ControlDarkColor {get;} = Color.FromUInt32(0xFFA0A0A0);
public static Color ControlDarkDarkColor {get;} = Color.FromUInt32(0xFF696969);
public static Color HighlightColor {get;} = Color.FromUInt32(0xFF3399FF);


public static Color ControlLightColor { get; } = System.Drawing.SystemColors.ControlLight.ToAvaloniaColor();
public static Color ControlLightLightColor { get; } = System.Drawing.SystemColors.ControlLightLight.ToAvaloniaColor();
public static Color ControlDarkColor { get; } = System.Drawing.SystemColors.ControlDark.ToAvaloniaColor();
public static Color ControlDarkDarkColor { get; } = System.Drawing.SystemColors.ControlDarkDark.ToAvaloniaColor();
public static Color HighlightColor { get; } = System.Drawing.SystemColors.Highlight.ToAvaloniaColor();
// /// <summary>
// /// pull out values from system.drawing
// /// </summary>
// /// <returns></returns>
// public static string[] GetColors()
// {
// string ToString(object obj)
// {
// if(obj is ISolidColorBrush b)
// {
// return $"new ImmutableSolidColorBrush(Color.FromUInt32(0x{b.Color.ToUint32().ToString("X")}));;
// }
// else if(obj is Color c)
// return $"Color.FromUInt32(0x{c.ToUint32().ToString("X")});;
// else
// return obj.ToString();
// }
// return Array.ConvertAll(typeof(SystemColors).GetProperties(), p => string.Format("{0} \{get;\} = {1}", p.Name, ToString(p.GetValue(null))));
// }

public static Color ToAvaloniaColor(this System.Drawing.Color color)
{
return new Color(color.A, color.R, color.G, color.B);
}

public static IBrush ToAvaloniaBrush(this System.Drawing.Brush brush)
{
if (brush is System.Drawing.SolidBrush solidbrush) {
return new ImmutableSolidColorBrush(solidbrush.Color.ToAvaloniaColor());
}
else if(brush is System.Drawing.TextureBrush textureBrush) {
using (var imageStream = new MemoryStream()) {
var image = textureBrush.Image;
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Bmp);
//public static IBrush ToAvaloniaBrush(this System.Drawing.Brush brush)
//{
// if (brush is System.Drawing.SolidBrush solidbrush) {
// return new ImmutableSolidColorBrush(solidbrush.Color.ToAvaloniaColor());
// }
// else if(brush is System.Drawing.TextureBrush textureBrush) {
// using (var imageStream = new MemoryStream()) {
// var image = textureBrush.Image;
// image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Bmp);

var avaloniaBitmap = new Bitmap(imageStream);
return new ImageBrush(avaloniaBitmap);
}
// var avaloniaBitmap = new Bitmap(imageStream);
// return new ImageBrush(avaloniaBitmap);
// }

} else {
throw new NotSupportedException();
}
}
// } else {
// throw new NotSupportedException();
// }
//}
}
}
2 changes: 1 addition & 1 deletion AvaloniaILSpy/AvaloniaILSpy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<TargetFramework>netcoreapp2.1</TargetFramework>

<TieredCompilations>true</TieredCompilations>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
Expand Down
26 changes: 16 additions & 10 deletions AvaloniaILSpy/Program.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using Avalonia;
using Avalonia.Logging.Serilog;

namespace AvaloniaILSpy
{
class Program
{
static void Main(string[] args)
{
AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToDebug()
.Start<MainWindow>();
}
}
class Program
{
static void Main(string[] args)
{
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

AppBuilder.Configure<App>()
.UsePlatformDetect()
#if DEBUG
.LogToDebug()
#endif
.Start<MainWindow>();
}
}
}
2 changes: 1 addition & 1 deletion AvaloniaILSpy/TextView/DecompilerTextView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ Task<AvaloniaEditTextOutput> SaveToDiskAsync(DecompilationContext context, strin
throw ex;
#else
} catch (Exception ex) {
tcs.SetException(ex);
throw ex;
#endif
}
});
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AvaloniaILSpy [![PayPal donate button](https://img.shields.io/badge/donate-paypal-blue.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=HYERRCR8C7876&lc=US&item_name=AvaloniaILSpy&no_note=0&currency_code=USD&bn=PP-DonationsBF:btn_donate_SM.gif:NonHosted)
# AvaloniaILSpy [![appveyor](https://ci.appveyor.com/api/projects/status/github/jeffreye/AvaloniaILSpy?svg=true)](https://ci.appveyor.com/project/jeffreye/avaloniailspy) [![PayPal donate button](https://img.shields.io/badge/donate-paypal-blue.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=HYERRCR8C7876&lc=US&item_name=AvaloniaILSpy&no_note=0&currency_code=USD&bn=PP-DonationsBF:btn_donate_SM.gif:NonHosted)

This is a port of [ILSpy](https://github.com/icsharpcode/ILSpy)

Expand Down
14 changes: 14 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
os: Visual Studio 2017
install:

before_build:
- cmd: git submodule update --init --recursive

build_script:
- cmd: dotnet --info
- ps: .\build.ps1 -Platform "AnyCPU" -Configuration "Release"

test: off

artifacts:
- path: artifacts/zips/*.zip
97 changes: 97 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
var target = Argument("target", "Default");
var platform = Argument("platform", "AnyCPU");
var configuration = Argument("configuration", "Release");

var editbin = @"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x86\editbin.exe";

var artifactsDir = (DirectoryPath)Directory("./artifacts");
var zipRootDir = artifactsDir.Combine("zips");

var fileZipSuffix = ".zip";

var netCoreAppsRoot= ".";
var netCoreApp = "AvaloniaILSpy";

var buildDirs =
GetDirectories($"{netCoreAppsRoot}/**/bin/**") +
GetDirectories($"{netCoreAppsRoot}/**/obj/**") +
GetDirectories($"{netCoreAppsRoot}/artifacts/**/zip/**");

var netCoreProject = new {
Path = $"{netCoreAppsRoot}/{netCoreApp}",
Name = netCoreApp,
Framework = XmlPeek($"{netCoreAppsRoot}/{netCoreApp}/{netCoreApp}.csproj", "//*[local-name()='TargetFramework']/text()"),
Runtimes = XmlPeek($"{netCoreAppsRoot}/{netCoreApp}/{netCoreApp}.csproj", "//*[local-name()='RuntimeIdentifiers']/text()").Split(';')
};


Task("Clean")
.Does(()=>{
CleanDirectories(buildDirs);
});

Task("Restore-NetCore")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore(netCoreProject.Path);
});

Task("Build-NetCore")
.IsDependentOn("Restore-NetCore")
.Does(() =>
{
Information("Building: {0}", netCoreProject.Name);
DotNetCoreBuild(netCoreProject.Path, new DotNetCoreBuildSettings {
Configuration = configuration
});
});

Task("Publish-NetCore")
.IsDependentOn("Restore-NetCore")
.Does(() =>
{
foreach(var runtime in netCoreProject.Runtimes)
{
var outputDir = artifactsDir.Combine(runtime);

Information("Publishing: {0}, runtime: {1}", netCoreProject.Name, runtime);
DotNetCorePublish(netCoreProject.Path, new DotNetCorePublishSettings {
Framework = netCoreProject.Framework,
Configuration = configuration,
Runtime = runtime,
OutputDirectory = outputDir.FullPath
});

if (IsRunningOnWindows() && (runtime == "win7-x86" || runtime == "win7-x64"))
{
Information("Patching executable subsystem for: {0}, runtime: {1}", netCoreProject.Name, runtime);
var targetExe = outputDir.CombineWithFilePath(netCoreProject.Name + ".exe");
var exitCodeWithArgument = StartProcess(editbin, new ProcessSettings {
Arguments = "/subsystem:windows " + targetExe.FullPath
});
Information("The editbin command exit code: {0}", exitCodeWithArgument);
}
}
});

Task("Zip-NetCore")
.IsDependentOn("Publish-NetCore")
.Does(() =>
{
EnsureDirectoryExists(zipRootDir);
foreach(var runtime in netCoreProject.Runtimes)
{
var workingDir = artifactsDir.Combine(runtime);
Information("Zipping {0} artifacts to {1}", runtime, zipRootDir);
Zip(workingDir.FullPath, zipRootDir.CombineWithFilePath(netCoreProject.Name + "-" + runtime + "-" + configuration + fileZipSuffix),
GetFiles(workingDir.FullPath + "/*.*"));
}
});

Task("Default")
.IsDependentOn("Restore-NetCore")
.IsDependentOn("Publish-NetCore")
.IsDependentOn("Zip-NetCore");

RunTarget(target);
Loading

0 comments on commit faadac7

Please sign in to comment.