Browse Source

Surface decompiler version in both console and ps cmdlets (intended for user error reporting)

pull/1012/head
Christoph Wille 8 years ago
parent
commit
7a87e553b6
  1. 2
      ICSharpCode.Decompiler.Console/Program.cs
  2. 3
      ICSharpCode.Decompiler.Console/Publish.cmd
  3. 3
      ICSharpCode.Decompiler.PowerShell/Demo.ps1
  4. 16
      ICSharpCode.Decompiler.PowerShell/GetDecompilerVersion.cs

2
ICSharpCode.Decompiler.Console/Program.cs

@ -17,6 +17,7 @@ namespace ICSharpCode.Decompiler.Console @@ -17,6 +17,7 @@ namespace ICSharpCode.Decompiler.Console
// Older cmd line clients (for options reference): https://github.com/aerror2/ILSpy-For-MacOSX and https://github.com/andreif/ILSpyMono
var app = new CommandLineApplication();
app.LongVersionGetter = () => "ilspycmd " + typeof(FullTypeName).Assembly.GetName().Version.ToString();
app.HelpOption("-h|--help");
var inputAssemblyFileName = app.Argument("Assembly filename name", "The assembly that is being decompiled. This argument is mandatory.");
var projectOption = app.Option("-p|--project", "Decompile assembly as compilable project. This requires the output directory option.", CommandOptionType.NoValue);
@ -31,6 +32,7 @@ namespace ICSharpCode.Decompiler.Console @@ -31,6 +32,7 @@ namespace ICSharpCode.Decompiler.Console
// HACK : the CommandLineUtils package does not allow us to specify an argument as mandatory.
// Therefore we're implementing it as simple as possible.
if (inputAssemblyFileName.Value == null) {
app.ShowVersion();
app.ShowHint();
return -1;
}

3
ICSharpCode.Decompiler.Console/Publish.cmd

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
dotnet publish -c release -r win7-x64
dotnet publish -c release -r osx-x64
dotnet publish -c release -r linux-x64

3
ICSharpCode.Decompiler.PowerShell/Demo.ps1

@ -7,6 +7,9 @@ if ([string]::IsNullOrEmpty($basePath)) @@ -7,6 +7,9 @@ if ([string]::IsNullOrEmpty($basePath))
$modulePath = $basePath + '\bin\Debug\netstandard2.0\ICSharpCode.Decompiler.Powershell.dll'
Import-Module $modulePath
$version = Get-DecompilerVersion
Write-Output $version
$decompiler = Get-Decompiler $modulePath
$classes = Get-DecompiledTypes $decompiler -Types class

16
ICSharpCode.Decompiler.PowerShell/GetDecompilerVersion.cs

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
using System;
using System.Management.Automation;
using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.PowerShell
{
[Cmdlet(VerbsCommon.Get, "DecompilerVersion")]
[OutputType(typeof(string))]
public class GetDecompilerVersion : PSCmdlet
{
protected override void ProcessRecord()
{
WriteObject(typeof(FullTypeName).Assembly.GetName().Version.ToString());
}
}
}
Loading…
Cancel
Save