Skip to content

Commit 167845f

Browse files
committed
Add dnx readme and don't do NativeAOT on non-Windows
1 parent 362c559 commit 167845f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Layout/dnx/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# dnx shim
2+
3+
To enable a root `dnx` command, we put a dnx shim beside the `dotnet` executable. The shim invokes `dotnet dnx` and forwards any other command-line arguments that were passed in.
4+
5+
On non-Windows operating systems, the shim is a shell script. We could do the same thing on Windows with a `dnx.cmd` script:
6+
7+
```
8+
@echo off
9+
"%~dp0dotnet.exe" dnx %*
10+
```
11+
12+
However, using this method, if you press CTRL+C to try to exit out of a running tool, the Windows command interpreter will ask you if you want to terminate the batch job:
13+
14+
> Terminate batch job (Y/N)
15+
16+
That's not an ideal experience. There doesn't seem to be a good way to avoid this on Windows using a batch/cmd file. The closest you can do is something like `start "" /b /wait "%~dp0dotnet.exe" dnx %*`. However, this detaches the launched tool process from recieving the `CTRL_C_EVENT` messages, so CTRL+C would not necessarily interrupt the process in the same way.
17+
18+
So on Windows we create a dnx.exe shim which behaves similarly to the script, but without the CTRL+C handling issue.

src/Layout/dnx/dnx.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
<PropertyGroup>
44
<TargetFramework>$(SdkTargetFramework)</TargetFramework>
55
<OutputType>Exe</OutputType>
6-
<PublishAot>true</PublishAot>
6+
<!-- We only use the shim on Windows, so skip NativeAOT compilation for other platforms -->
7+
<PublishAot Condition="$(NETCoreSdkPortableRuntimeIdentifier.StartsWith('win-'))">true</PublishAot>
8+
<!-- However, still generate AOT warnings on other platforms -->
9+
<IsAotCompatible>true</IsAotCompatible>
710
<ControlFlowGuard>Guard</ControlFlowGuard>
811
<UseSystemResourceKeys>true</UseSystemResourceKeys>
912
<SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>

0 commit comments

Comments
 (0)