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"?> <?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> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DllExporter</RootNamespace> <RootNamespace>DllExporter</RootNamespace>
<AssemblyName>DllExporter</AssemblyName> <AssemblyName>DllExporter</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<PublishUrl>publish\</PublishUrl> <PublishUrl>publish\</PublishUrl>
<Install>true</Install> <Install>true</Install>
@ -71,7 +71,7 @@
<NoWarn>1607</NoWarn> <NoWarn>1607</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.Build.Utilities" /> <Reference Include="Microsoft.Build.Utilities.v4.0" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />

View File

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