Skip to content

Commit ad772df

Browse files
authored
[release/10.0.1xx-preview6] Add dnx support (#49488)
2 parents 5700da8 + 75b45eb commit ad772df

File tree

7 files changed

+62
-8
lines changed

7 files changed

+62
-8
lines changed

src/Cli/Microsoft.TemplateEngine.Cli/Help/HelpBuilder.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ public virtual void Write(HelpContext context)
4343
throw new ArgumentNullException(nameof(context));
4444
}
4545

46-
if (context.Command.Hidden)
47-
{
48-
return;
49-
}
50-
5146
foreach (var writeSection in GetLayout(context))
5247
{
5348
if (writeSection(context))
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.CommandLine;
5+
using Microsoft.DotNet.Cli.Commands.Tool;
6+
using Microsoft.DotNet.Cli.Commands.Tool.Execute;
7+
8+
namespace Microsoft.DotNet.Cli.Commands.Dnx;
9+
10+
internal static class DnxCommandParser
11+
{
12+
public static readonly Command Command = ConstructCommand();
13+
public static Command GetCommand()
14+
{
15+
return Command;
16+
}
17+
18+
private static Command ConstructCommand()
19+
{
20+
Command command = new("dnx", CliCommandStrings.ToolExecuteCommandDescription);
21+
command.Hidden = true;
22+
23+
foreach (var argument in ToolExecuteCommandParser.Command.Arguments)
24+
{
25+
command.Arguments.Add(argument);
26+
}
27+
28+
foreach (var option in ToolExecuteCommandParser.Command.Options)
29+
{
30+
command.Options.Add(option);
31+
}
32+
33+
command.SetAction((parseResult) => new ToolExecuteCommand(parseResult).Execute());
34+
35+
return command;
36+
}
37+
}

src/Cli/dotnet/Parser.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Microsoft.DotNet.Cli.Commands.Build;
1111
using Microsoft.DotNet.Cli.Commands.BuildServer;
1212
using Microsoft.DotNet.Cli.Commands.Clean;
13+
using Microsoft.DotNet.Cli.Commands.Dnx;
1314
using Microsoft.DotNet.Cli.Commands.Format;
1415
using Microsoft.DotNet.Cli.Commands.Fsi;
1516
using Microsoft.DotNet.Cli.Commands.Help;
@@ -66,6 +67,7 @@ public static class Parser
6667
BuildCommandParser.GetCommand(),
6768
BuildServerCommandParser.GetCommand(),
6869
CleanCommandParser.GetCommand(),
70+
DnxCommandParser.GetCommand(),
6971
FormatCommandParser.GetCommand(),
7072
CompleteCommandParser.GetCommand(),
7173
FsiCommandParser.GetCommand(),
@@ -313,12 +315,15 @@ public override void Write(HelpContext context)
313315
{
314316
var command = context.Command;
315317
var helpArgs = new string[] { "--help" };
318+
319+
// custom help overrides
316320
if (command.Equals(RootCommand))
317321
{
318322
Console.Out.WriteLine(CliUsage.HelpText);
319323
return;
320324
}
321325

326+
// argument/option cleanups specific to help
322327
foreach (var option in command.Options)
323328
{
324329
option.EnsureHelpName();

src/Layout/redist/dnx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
"$(dirname "$0")/dotnet" dnx "$@"

src/Layout/redist/dnx.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
"%~dp0dotnet.exe" dnx %*

src/Layout/redist/targets/GenerateInstallerLayout.targets

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@
6464
Overwrite="true" />
6565
</Target>
6666

67+
<Target Name="LayoutDnxScript">
68+
<PropertyGroup>
69+
<DnxScriptSource Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">dnx.cmd</DnxScriptSource>
70+
<DnxScriptSource Condition="!$([MSBuild]::IsOSPlatform('WINDOWS'))">dnx</DnxScriptSource>
71+
</PropertyGroup>
72+
<Copy SourceFiles="$(DnxScriptSource)" DestinationFolder="$(RedistInstallerLayoutPath)" />
73+
74+
<!-- Mark script as executable -->
75+
<Exec Command="chmod 755 &quot;$(RedistInstallerLayoutPath)/dnx&quot;" Condition="!$([MSBuild]::IsOSPlatform('Windows'))" />
76+
</Target>
77+
6778
<!-- 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. -->
6879
<Target Name="ReplaceBundledRuntimePackFilesWithSymbolicLinks" DependsOnTargets="LayoutBundledComponents"
6980
Condition="'$(BundleRuntimePacks)' == 'true' and !$([MSBuild]::IsOSPlatform('WINDOWS'))">
@@ -81,6 +92,7 @@
8192
LayoutManifests;
8293
LayoutBaselineWorkloadSet;
8394
LayoutWorkloadUserLocalMarker;
95+
LayoutDnxScript;
8496
CrossgenLayout;
8597
ReplaceBundledRuntimePackFilesWithSymbolicLinks"
8698
AfterTargets="AfterBuild" />
@@ -101,6 +113,10 @@
101113
DestinationFiles="@(SdkOutputFile -> '$(IntermediateSdkInstallerOutputPath)sdk\$(Version)\%(RecursiveDir)%(Filename)%(Extension)')"
102114
UseHardLinksIfPossible="true"
103115
SkipUnchangedFiles="true" />
116+
117+
<!-- Copy dnx script to root dotnet folder (which will map to DOTNETHOME) -->
118+
<Copy SourceFiles="dnx.cmd" DestinationFolder="$(IntermediateSdkInstallerOutputPath)" />
119+
104120
</Target>
105121

106122
</Project>

src/Layout/redist/targets/GenerateLayout.targets

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,6 @@
278278
DestinationFiles="$(OutputPath)/%(BundledTools.Identity).runtimeconfig.json"
279279
SkipUnchangedFiles="true" />
280280

281-
<Delete Files="$(OutputPath)/$(TargetName).deps.json;
282-
$(OutputPath)/$(TargetName).runtimeconfig.json" />
283-
284281
<Delete Files="$(OutputPath)/%(BundledToolProjects.Identity).dll;
285282
$(OutputPath)/%(BundledToolProjects.Identity).pdb" />
286283

0 commit comments

Comments
 (0)