Native.NET 1.0.1.5

dotnet add package Native.NET --version 1.0.1.5
NuGet\Install-Package Native.NET -Version 1.0.1.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Native.NET" Version="1.0.1.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Native.NET --version 1.0.1.5
#r "nuget: Native.NET, 1.0.1.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Native.NET as a Cake Addin
#addin nuget:?package=Native.NET&version=1.0.1.5

// Install Native.NET as a Cake Tool
#tool nuget:?package=Native.NET&version=1.0.1.5

Generates a processor specific Native Image for an executable and all dependencies and stores them in the cache.

Generating a Native Image can improve performance and load times at the cost of disk space.

Example

static GenerateNative GenerateNative { get; set; } = new GenerateNative();
await GenerateNative.Compile64("INFINITY.exe").ConfigureAwait(false);
GenerateNative = null;

Inline Entire Library

You can inline this with an Action if you want, then you don't need the library, this is actually the preferred method.

/// <summary>
/// Compile Native Image with NGen if it is available
/// </summary>
internal static Action CompileNgen64 = () =>
{
    Process process;

    int MAX_WAIT_TIME = 10000;
    string NET_FRAMEWORK_SETUP = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full";
    string SDK_INSTALL_PATH = "InstallPath";
    string INSTALL = " install ";
    string NGEN = "ngen.exe";
    string NGEN_NOT_INSTALLED = "NGen is not installed so you can't run this, Install .NET and try again";
    string LIKELY_PATH_TO_DOTNET = Environment.ExpandEnvironmentVariables("%WINDIR%\\Microsoft.NET\\Framework64\\v4.0.30319\\");

    string dotNetInstallPath;
    string executablePath = Directory.GetCurrentDirectory();

    bool b = Directory.Exists(LIKELY_PATH_TO_DOTNET);

    if (b)
    {
        dotNetInstallPath = LIKELY_PATH_TO_DOTNET;
    }
    else // Remove this section if you don't want to access the registry
    {
        RegistryKey localMachineX64View = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);

        RegistryKey dotNetFrameworkSetup = localMachineX64View.OpenSubKey(NET_FRAMEWORK_SETUP);

        dotNetInstallPath = (string)dotNetFrameworkSetup.GetValue(SDK_INSTALL_PATH);
    }  // Remove this section if you don't want to access the registry

    if (dotNetInstallPath != null)
    {
        string FULL_NGEN_PATH = dotNetInstallPath + NGEN;

        bool nGenExists = File.Exists(FULL_NGEN_PATH);

        if (nGenExists)
        {
            var runCommand = new ProcessStartInfo
            {
                WorkingDirectory = Environment.CurrentDirectory,
                FileName = FULL_NGEN_PATH,
                Verb = "runas",
                Arguments = INSTALL + Assembly.GetExecutingAssembly().Location,
                WindowStyle = ProcessWindowStyle.Hidden,
                CreateNoWindow = true,
                UseShellExecute = true,
            };

            process = Process.Start(runCommand);

            process.WaitForExit(MAX_WAIT_TIME);

            return;
        }
        else
        {
            Console.WriteLine(NGEN_NOT_INSTALLED);
        }
    }
};

NGen

native

Copyright S Christison ©2023

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1.5 85 4/11/2024
1.0.1.4 236 6/15/2023