Skip to content

Commit

Permalink
Fix Windows build?
Browse files Browse the repository at this point in the history
By convention (and often enforced requirement), `$(OutputPath)` ends
with `\`, which means that quoting it for use with `<Exec/>`:

    <Exec Command="whatever &quot;$(OutputPath)&quot;" />

will often result in an *invalid* command, because the `\` escapes the quote!

    whatever "C:\path\to\output\" # ruh roh!

The fix is to instead use `$(OutputPath.OutputPath.TrimEnd('\')`,
which ensures that the path does *not* end in `\`, preventing
the unintentional escape usage:

    whatever "C:\path\to\output" # yay!
  • Loading branch information
jonpryor committed Feb 19, 2025
1 parent 9f8b79e commit cacdf4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/native/native-mono.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Import Project="..\..\Configuration.props" />

<PropertyGroup>
<OutputPath>$(NativeRuntimeOutputRootDir)mono</OutputPath>
<OutputPath>$(NativeRuntimeOutputRootDir)mono\</OutputPath>
<CMakeRuntimeFlavor>MonoVM</CMakeRuntimeFlavor>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/native/native.targets
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<ItemGroup>
<_ConfigureArchiveDSOStubCommands Include="@(AndroidSupportedTargetJitAbi)">
<Command>$(CmakePath)</Command>
<Arguments>-DOUTPUT_PATH="$(OutputPath)" -DRUNTIME_FLAVOR="$(CMakeRuntimeFlavor)" --preset default-release-%(AndroidSupportedTargetJitAbi.Identity) -DBUILD_ARCHIVE_DSO_STUB=ON -DSTRIP_DEBUG=ON "$(MSBuildThisFileDirectory)"</Arguments>
<Arguments>-DOUTPUT_PATH="$(OutputPath.TrimEnd('\')" -DRUNTIME_FLAVOR="$(CMakeRuntimeFlavor)" --preset default-release-%(AndroidSupportedTargetJitAbi.Identity) -DBUILD_ARCHIVE_DSO_STUB=ON -DSTRIP_DEBUG=ON "$(MSBuildThisFileDirectory)"</Arguments>
<WorkingDirectory>$(FlavorIntermediateOutputPath)%(AndroidSupportedTargetJitAbi.AndroidRID)-archive-dso-stub</WorkingDirectory>
</_ConfigureArchiveDSOStubCommands>
</ItemGroup>
Expand All @@ -113,7 +113,7 @@
<_NoInline Condition=" '$(DoNotInlineMonodroid)' == 'true' ">-DDONT_INLINE=ON</_NoInline>
<_NoStrip Condition=" '$(DoNotStripMonodroid)' == 'true' ">-DSTRIP_DEBUG=OFF</_NoStrip>

<_CmakeAndroidFlags>-DOUTPUT_PATH="$(OutputPath)" -DRUNTIME_FLAVOR="$(CMakeRuntimeFlavor)" $(_NoInline) $(_NoStrip) "$(MSBuildThisFileDirectory)"</_CmakeAndroidFlags>
<_CmakeAndroidFlags>-DOUTPUT_PATH="$(OutputPath.TrimEnd('\')" -DRUNTIME_FLAVOR="$(CMakeRuntimeFlavor)" $(_NoInline) $(_NoStrip) "$(MSBuildThisFileDirectory)"</_CmakeAndroidFlags>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit cacdf4d

Please sign in to comment.