Skip to content

Commit ba9a65f

Browse files
committed
Improve how we invoke help > markdown
Running with `dotnet run` started introducing control characters in the output (presumably from progress or other reporting?), so we instead just invoke directly the resulting tool, which should also make it faster.
1 parent 2e67eab commit ba9a65f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/Cli/Cli.csproj

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,30 @@
3939
<ProjectProperty Include="PackageVersion" />
4040
</ItemGroup>
4141

42-
<Target Name="RenderHelp" AfterTargets="Build" Condition="$(DesignTimeBuild) != 'true'">
42+
<Target Name="RenderHelp" AfterTargets="Build" Condition="$(DesignTimeBuild) != 'true' and '$(OS)' == 'Windows_NT'">
43+
<PropertyGroup>
44+
<Cli>$(TargetDir)$(TargetName).exe</Cli>
45+
<HelpCommand>"$(Cli)" --help --tos --unattended</HelpCommand>
46+
<SyncCommand>"$(Cli)" sync --help --unattended</SyncCommand>
47+
</PropertyGroup>
48+
4349
<WriteLinesToFile Lines="```shell" Overwrite="true" Encoding="UTF-8" File="help.md" />
44-
<Exec Command="dotnet run --no-build -c:$(Configuration) -- --help --tos --unattended &gt;&gt; help.md" StdOutEncoding="UTF-8"
45-
EnvironmentVariables="NO_COLOR=true" ContinueOnError="true">
50+
51+
<Exec Command="$(HelpCommand) &gt;&gt; help.md" StdOutEncoding="UTF-8" EnvironmentVariables="NO_COLOR=true" ContinueOnError="true">
4652
<Output TaskParameter="ExitCode" PropertyName="MSBuildLastExitCode" />
4753
</Exec>
4854
<!-- Run again if it failed, but without the output redirect, for troubleshooting via build logs -->
49-
<Exec Condition="$(MSBuildLastExitCode) != '0'"
50-
Command="dotnet run --no-build -c:$(Configuration) -- --help --tos --unattended" StdOutEncoding="UTF-8"
51-
EnvironmentVariables="NO_COLOR=true" />
55+
<Exec Condition="$(MSBuildLastExitCode) != '0'" Command="$(HelpCommand)" StdOutEncoding="UTF-8" EnvironmentVariables="NO_COLOR=true" />
5256
<Error Text="Failed to get help output." Condition="'$(MSBuildLastExitCode)' != '0'" />
57+
5358
<WriteLinesToFile Lines="```" Overwrite="false" Encoding="UTF-8" File="help.md" />
5459

5560
<WriteLinesToFile Lines="```shell" Overwrite="true" Encoding="UTF-8" File="sync.md" />
56-
<Exec Command="dotnet run --no-build -c:$(Configuration) -- sync --help --unattended &gt;&gt; sync.md" StdOutEncoding="UTF-8"
57-
EnvironmentVariables="NO_COLOR=true" ContinueOnError="true">
61+
<Exec Command="$(SyncCommand) &gt;&gt; sync.md" StdOutEncoding="UTF-8" EnvironmentVariables="NO_COLOR=true" ContinueOnError="true">
5862
<Output TaskParameter="ExitCode" PropertyName="MSBuildLastExitCode" />
5963
</Exec>
6064
<!-- Run again if it failed, but without the output redirect, for troubleshooting via build logs -->
61-
<Exec Condition="$(MSBuildLastExitCode) != '0'"
62-
Command="dotnet run --no-build -c:$(Configuration) -- sync --help --unattended" StdOutEncoding="UTF-8"
63-
EnvironmentVariables="NO_COLOR=true" />
65+
<Exec Condition="$(MSBuildLastExitCode) != '0'" Command="$(SyncCommand)" StdOutEncoding="UTF-8" EnvironmentVariables="NO_COLOR=true" />
6466
<Error Text="Failed to get help output." Condition="'$(MSBuildLastExitCode)' != '0'" />
6567
<WriteLinesToFile Lines="```" Overwrite="false" Encoding="UTF-8" File="sync.md" />
6668
</Target>

0 commit comments

Comments
 (0)