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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Layout/redist/dnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
"$(dirname "$0")/dotnet" dnx "$@"
2 changes: 2 additions & 0 deletions src/Layout/redist/dnx.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
"%~dp0dotnet.exe" dnx %*
16 changes: 16 additions & 0 deletions src/Layout/redist/targets/GenerateInstallerLayout.targets
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@
Overwrite="true" />
</Target>

<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>
Comment on lines +67 to +76
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.


<!-- Replace files from the runtime packs with symbolic links to the corresponding shared framework files (and hostfxr) to reduce the size of the runtime pack directories. -->
<Target Name="ReplaceBundledRuntimePackFilesWithSymbolicLinks" DependsOnTargets="LayoutBundledComponents"
Condition="'$(BundleRuntimePacks)' == 'true' and !$([MSBuild]::IsOSPlatform('WINDOWS'))">
Expand All @@ -81,6 +92,7 @@
LayoutManifests;
LayoutBaselineWorkloadSet;
LayoutWorkloadUserLocalMarker;
LayoutDnxScript;
CrossgenLayout;
ReplaceBundledRuntimePackFilesWithSymbolicLinks"
AfterTargets="AfterBuild" />
Expand All @@ -101,6 +113,10 @@
DestinationFiles="@(SdkOutputFile -> '$(IntermediateSdkInstallerOutputPath)sdk\$(Version)\%(RecursiveDir)%(Filename)%(Extension)')"
UseHardLinksIfPossible="true"
SkipUnchangedFiles="true" />

<!-- Copy dnx script to root dotnet folder (which will map to DOTNETHOME) -->
<Copy SourceFiles="dnx.cmd" DestinationFolder="$(IntermediateSdkInstallerOutputPath)" />

</Target>

</Project>
3 changes: 0 additions & 3 deletions src/Layout/redist/targets/GenerateLayout.targets
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,6 @@
DestinationFiles="$(OutputPath)/%(BundledTools.Identity).runtimeconfig.json"
SkipUnchangedFiles="true" />

<Delete Files="$(OutputPath)/$(TargetName).deps.json;
$(OutputPath)/$(TargetName).runtimeconfig.json" />

<Delete Files="$(OutputPath)/%(BundledToolProjects.Identity).dll;
$(OutputPath)/%(BundledToolProjects.Identity).pdb" />

Expand Down
Loading