DllExporter: Use correct ilasm.exe depending on target architecture

This commit is contained in:
Birunthan Mohanathas 2014-01-17 21:21:16 +02:00
parent d952ceca44
commit 580d6de303
2 changed files with 19 additions and 8 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DllExporter</RootNamespace>
<AssemblyName>DllExporter</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
@ -71,7 +71,7 @@
<NoWarn>1607</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Build.Utilities" />
<Reference Include="Microsoft.Build.Utilities.v4.0" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />

View File

@ -36,8 +36,11 @@ namespace DllExporter
string targetIlName = targetDllName + ".il";
string targetResName = targetDllName + ".res";
string ilasmPath = ToolLocationHelper.GetPathToDotNetFrameworkFile("ilasm.exe", TargetDotNetFrameworkVersion.Version20);
if (!File.Exists(ilasmPath))
bool is64 = platformTarget.ToLower().Equals("x64");
bool isDebug = configurationName.ToLower().Equals("debug");
string ilasmPath = FindIlasmPath(is64);
if (ilasmPath == null)
{
Console.WriteLine("DllExporter error: ilasm.exe not found");
return 1;
@ -52,9 +55,6 @@ namespace DllExporter
Directory.SetCurrentDirectory(targetDirectory);
bool is64 = platformTarget.ToLower().Equals("x64");
bool isDebug = configurationName.ToLower().Equals("debug");
// Disassemble
Process ildasmProc = new Process();
string ildasmArgs = string.Format(
@ -171,6 +171,17 @@ namespace DllExporter
return 0;
}
/// <summary>
/// Finds path to ilasm.exe.
/// </summary>
private static string FindIlasmPath(bool x64)
{
var arch = x64 ? DotNetFrameworkArchitecture.Bitness64 : DotNetFrameworkArchitecture.Bitness32;
var path = ToolLocationHelper.GetPathToDotNetFrameworkFile(
"ilasm.exe", TargetDotNetFrameworkVersion.Version20, arch);
return File.Exists(path) ? path : null;
}
/// <summary>
/// Finds path to ildasm.exe.
/// </summary>