Install Windows Version Of Mono To Run Net Executables Files App
Updated for Fall Creators Update.
If you're running Creators Update or Anniversary Update, jump to the Creators/Anniversary Update section.
The Windows Subsystem for Linux (WSL) is continuously improving integration between Windows and Linux. You can:
- Invoke Windows binaries from the Linux console.
- Invoke Linux binaries from a Windows console.
- Windows Insiders Builds 17063+ Share environment variables between Linux and Windows.
This delivers a seamless experience between Windows and WSL. Technical details are on the WSL blog.
Run Linux tools from a Windows command line
Run Linux binaries from the Windows Command Prompt (CMD or PowerShell) using wsl.exe <command>
.
Binaries invoked in this way:
- Use the same working directory as the current CMD or PowerShell prompt.
- Run as the WSL default user.
- Have the same Windows administrative rights as the calling process and terminal.
For example:
The Linux command following wsl.exe
is handled like any command run in WSL. Things such as sudo, piping, and file redirection work.
Example using sudo:
Examples mixing WSL and Windows commands:
The commands passed into wsl.exe
are forwarded to the WSL process without modification. File paths must be specified in the WSL format.
Example with paths:
Run Windows tools from WSL
WSL can invoke Windows binaries directly from the WSL command line using [binary name].exe
. For example, notepad.exe
. To make Windows executables easier to run, Windows path is included in the Linux $PATH
in Fall Creators Update.
Applications run this way have the following properties:
- Retain the working directory as the WSL command prompt (for the most part -- exceptions are explained below).
- Have the same permission rights as the WSL process.
- Run as the active Windows user.
- Appear in the Windows Task Manager as if directly executed from the CMD prompt.
Example:
Windows executables run in WSL are handled similarly to native Linux executables -- piping, redirects, and even backgrounding work as expected.
Examples using pipes:
Example using mixed Windows and WSL commands:
Windows binaries must include the file extension, match the file case, and be executable. Non-executables including batch scripts. CMD native commands like dir
can be run with cmd.exe /C
command.
Examples:
Parameters are passed to the Windows binary unmodified.
As an example, the following commands will open C:tempfoo.txt
in notepad.exe
:
Modifying files located on VolFs (files not under /mnt/<x>
) with a Windows application in WSL is not supported.
By default, WSL tries to keep the working directory of the Windows binary as the current WSL directory, but will fall back on the instance creation directory if the working directory is on VolFs.
As an example; wsl.exe
is initially launched from C:temp
and the current WSL directory is changed to the user’s home. When notepad.exe
is called from the user’s home directory, WSL automatically reverts to C:temp
as the notepad.exe working directory:
Share environment variables between Windows and WSL
Available in Windows Insider builds 17063 and later.
Prior to 17063, only Windows environment variable that WSL could access was PATH
(so you could launch Win32 executables from under WSL).
Starting in 17063, WSL and Windows share WSLENV
, a special environment variable created to bridge Windows and Linux distros running on WSL.
Properties of WSLENV
:
- It is shared; it exists in both Windows and WSL environments.
- It is a list of environment variables to share between Windows and WSL.
- It can format environment variables to work well in Windows and WSL.
There are four flags available in WSLENV
to influence how that environment variable is translated.
WSLENV
flags:
/p
- translates the path between WSL/Linux style paths and Win32 paths./l
- indicates the environment variable is a list of paths./u
- indicates that this environment variable should only be included when running WSL from Win32./w
- indicates that this environment variable should only be included when running Win32 from WSL.
Flags can be combined as needed.
Disable Interop
Users may disable the ability to run Windows binaries for a single WSL session by running the following command as root:
To reenable Windows binaries either exit all WSL sessions and re-run bash.exe or run the following command as root:
Disabling interop will not persist between WSL sessions -- interop will be enabled again when a new session is launched.
Creators Update and Anniversary Update
While the interop experience pre-Fall Creators Update is similar to more recent interop experiences, there are a handful of major differences.
To summarize:
bash.exe
has been deprecated and replaced withwsl.exe
.-c
option for running a single command isn't needed withwsl.exe
.- Windows path is included in the WSL
$PATH
The process for disabling interop is unchanged.
Invoking WSL from the Windows Command Line
Linux binaries can be invoked from the Windows Command Prompt or from PowerShell. Binaries invoked in this way have the following properties:
- Use the same working directory as the CMD or PowerShell prompt.
- Run as the WSL default user.
- Have the same Windows administrative rights as the calling process and terminal.
Example:
Linux commands called in this way are handled like any other Windows application. Things such as input, piping, and file redirection work as expected.
Examples:
The WSL commands passed into bash -c
are forwarded to the WSL process without modification. File paths must be specified in the WSL format and care must be taken to escape relevant characters. Example:
Invoking Windows binaries from WSL
The Windows Subsystem for Linux can invoke Windows binaries directly from the WSL command line. Applications run this way have the following properties:
- Retain the working directory as the WSL command prompt except in the scenario explained below.
- Have the same permission rights as the
bash.exe
process. - Run as the active Windows user.
- Appear in the Windows Task Manager as if directly executed from the CMD prompt.
Example:
In WSL, these executables are handled similar to native Linux executables. This means adding directories to the Linux path and piping between commands works as expected. Examples:
The Windows binary must include the file extension, match the file case, and be executable. Non-executables including batch scripts and command like dir
can be run with /mnt/c/Windows/System32/cmd.exe /C
command.
Examples:
Parameters are passed to the Windows binary unmodified.
As an example, the following commands will open C:tempfoo.txt
in notepad.exe
:
Modifying files located on VolFs (files not under /mnt/<x>
) with a Windows application is not supported. By default, WSL attempts to keep the working directory of the Windows binary as the current WSL directory, but will fall back on the instance creation directory if the working directory is on VolFs.
As an example; bash.exe
is initially launched from C:temp
and the current WSL directory is changed to the user’s home. When notepad.exe
is called from the user’s home directory, WSL automatically reverts to C:temp
as the notepad.exe working directory:
- понедельник 24 февраля
- 85