Skip to content

Add dnx scripts #49461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 19, 2025
Merged

Add dnx scripts #49461

merged 3 commits into from
Jun 19, 2025

Conversation

dsplaisted
Copy link
Member

No description provided.

@Copilot Copilot AI review requested due to automatic review settings June 17, 2025 20:27
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds dnx scripts to the redistributable layout and installer targets, facilitating cross-platform support for executing dnx commands.

  • Removed deletion of certain runtime configuration files in the GenerateLayout.targets file
  • Introduced a new LayoutDnxScript target and copy actions in GenerateInstallerLayout.targets, including marking the dnx script as executable
  • Added new script files (dnx.cmd and dnx) to support Windows and non-Windows environments

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/Layout/redist/targets/GenerateLayout.targets Removed deletion of runtime configuration files
src/Layout/redist/targets/GenerateInstallerLayout.targets Added LayoutDnxScript target to copy and fix permissions for dnx scripts
src/Layout/redist/dnx.cmd Added Windows-specific batch script to run dnx commands
src/Layout/redist/dnx Added Unix shell script to run dnx commands
Comments suppressed due to low confidence (1)

src/Layout/redist/targets/GenerateInstallerLayout.targets:75

  • The chmod command (chmod 644) does not set the executable bit on Unix systems; please change this to chmod +x or chmod 755 to ensure the dnx script is executable.
    <Exec Command="chmod 644 &quot;$(RedistInstallerLayoutPath)/dnx&quot;" Condition="!$([MSBuild]::IsOSPlatform('Windows'))" />

Comment on lines +67 to +76
<Target Name="LayoutDnxScript">
<PropertyGroup>
<DnxScriptSource Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">dnx.cmd</DnxScriptSource>
<DnxScriptSource Condition="!$([MSBuild]::IsOSPlatform('WINDOWS'))">dnx</DnxScriptSource>
</PropertyGroup>
<Copy SourceFiles="$(DnxScriptSource)" DestinationFolder="$(RedistInstallerLayoutPath)" />

<!-- Mark script as executable -->
<Exec Command="chmod 644 &quot;$(RedistInstallerLayoutPath)/dnx&quot;" Condition="!$([MSBuild]::IsOSPlatform('Windows'))" />
</Target>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a cross-compilation mechanism for generating the installer layouts? Feels like these conditions should be something more like '$(TargetOS)' != 'Windows' or something along those lines (properties may not exist and are illustrative only).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure that's not at all possible currently. I looked a bit and didn't find anything really, and I did find a few similar cases that used the current OS. I know there is some target RID logic so you can choose whether you are targeting linux-x64 or something more specific for example, but I think there's no way to compile across Windows and non-Windows.

@joeloff
Copy link
Member

joeloff commented Jun 17, 2025

ComponentIDs for Windows are good:

image

@baronfel
Copy link
Member

I found two problems when testing on linux:

  • the dnx script needs to be marked with the executable bit (I had to chmod +x it)
  • this seems to conflict with the feature the @dotnet/run-file folks have done recently to do more file running. we need to reconcile them:
>dnx fsautocomplete
Restore complete (4.8s)
You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
  dnx failed with 7 error(s) (1.7s)
    /home/chethusk/dotnet-dev/dnx(2,13): error CS1002: ; expected
    /home/chethusk/dotnet-dev/dnx(2,13): error CS1056: Unexpected character '$'
    /home/chethusk/dotnet-dev/dnx(2,15): error CS1002: ; expected
    /home/chethusk/dotnet-dev/dnx(2,26): error CS1002: ; expected
    /home/chethusk/dotnet-dev/dnx(2,30): error CS1001: Identifier expected
    /home/chethusk/dotnet-dev/dnx(2,30): error CS1003: Syntax error, ',' expected
    /home/chethusk/dotnet-dev/dnx(2,34): error CS1002: ; expected

The build failed. Fix the build errors and run again.

@baronfel
Copy link
Member

Pushed up a commit that sets the executable bit on the dnx script.

@baronfel
Copy link
Member

Ok I'm slightly wrong on the run-file conflict. What had happened was, I ran dnx from the directory I had extracted the SDK build into. This meant that when dnx ran the dotnet dnx command, the "does the second argument point to a file that exists in CWD" check that the @dotnet/run-file team added passed, so the dnx script itself was passed to dotnet run as dotnet run dnx, which then triggered the single-file compilation.

As soon as I moved out of that directory and set up my PATH as one would normally do, dnx worked great:

chethusk@Chet-Desktop:~$ ~/dotnet-dev/dnx fsautocomplete@0.78.1 -- --help
Tool package fsautocomplete@0.78.1 will be downloaded from source https://api.nuget.org/v3/index.json.
Proceed? [y/n] (y): y
Description:
  An F# LSP server implementation

Usage:
  fsautocomplete [options] [[--] <additional arguments>...]]

Options:
  -v, --debug, --verbose                                       Enable verbose logging. This is equivalent to --log-level debug.
  --attach-debugger                                            Launch the system debugger and break immediately
  -l, --log-file, --logfile <log-file>                         Send log output to specified file.
  --filter, --log-filter <log-filter>                          Filter logs by category. The category can be seen in the logs inside []. For example: [Compiler].
  --attachdebugger, --wait-for-debugger                        Stop execution on startup until an external debugger to attach to this process
  --project-graph-enabled                                      Enable MSBuild Graph workspace loading. Should be faster than the default, but is experimental.
  --adaptive-lsp-server-enabled                                Enable LSP Server based on FSharp.Data.Adaptive. Should be more stable, but is experimental.
  --log-level <Debug|Error|Fatal|Information|Verbose|Warning>  Set the log verbosity to a specific level.
  --state-directory <state-directory>                          Set the directory to store the state of the server. This should be a per-workspace location, not a
                                                               shared-workspace location. [default: /home/chethusk]
  --otel-exporter-enabled                                      Enabled OpenTelemetry exporter. See https://opentelemetry.io/docs/reference/specification/protocol/exporter/ for
                                                               environment variables to configure for the exporter.
  --use-fcs-transparent-compiler                               Use Transparent Compiler in FSharp.Compiler.Services. Should have better performance characteristics, but is
                                                               experimental. See https://github.com/dotnet/fsharp/pull/15179 for more details.
  --version                                                    Show version information
  -?, -h, --help                                               Show help and usage information

Additional Arguments:
  Arguments passed to the application that is being run.

@baronfel baronfel enabled auto-merge (squash) June 19, 2025 02:11
@baronfel
Copy link
Member

/backport to release/10.0.1xx-preview6

Copy link
Contributor

Started backporting to release/10.0.1xx-preview6: https://github.com/dotnet/sdk/actions/runs/15748884118

@baronfel baronfel merged commit 62b79b9 into dotnet:main Jun 19, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants