Skip to content

Commit aea7e79

Browse files
[build] set file extension for common ToolExe values (#8267)
Running the `dotnet-local.cmd -t:Install` target with a local xamarin-android build on Windows, I got the error: AndroidAdb Errors Xamarin.Android.Common.targets(2641,3): error MSB6004: The specified task executable location "D:\android-toolchain\sdk\platform-tools\adb" is invalid. This appears to only happen with a local of xamarin/xamarin-android because it specifies `$(AdbToolExe)`=adb in `Configuration.props`. It appears that most of our tasks just use the pattern: partial class ToolTaskSubclass : /* eventually… */ ToolTask { protected override string GenerateFullPathToTool () { return Path.Combine (ToolPath, ToolExe); } } Where if `ToolExe` was completely blank, it would fall back to: partial class ToolTaskSubclass { protected override string ToolName => OS.IsWindows ? "adb.exe" : "adb"; } Searching the web: * <https://grep.app/search?current=2&q=ToolExe&words=true&filter[lang][0]=C%23&filter[lang][1]=XML> It seems most other tasks use `ToolExe` as-is, if it is passed in. Where most of the time the default value is blank. I think the simple fix here is to specify the file extension in `Configuration.props` for any of our `$(*ToolExe)` values. I also removed `$(AndroidToolExe)` because it is unused and may not event exist anymore in the Android SDK.
1 parent 786a1fd commit aea7e79

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Configuration.props

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,22 @@
180180
</PropertyGroup>
181181
<PropertyGroup>
182182
<AdbToolPath Condition=" '$(AdbToolPath)' == '' ">$(AndroidSdkFullPath)\platform-tools\</AdbToolPath>
183-
<AdbToolExe Condition=" '$(AdbToolExe)' == '' ">adb</AdbToolExe>
183+
<AdbToolExe Condition=" '$(AdbToolExe)' == '' and '$(HostOS)' != 'Windows' ">adb</AdbToolExe>
184+
<AdbToolExe Condition=" '$(AdbToolExe)' == '' and '$(HostOS)' == 'Windows' ">adb.exe</AdbToolExe>
184185
<AvdManagerHome Condition=" '$(AvdManagerHome)' == '' ">$(AndroidToolchainDirectory)</AvdManagerHome>
185-
<AvdManagerToolExe Condition=" '$(AvdManagerToolExe)' == '' ">avdmanager</AvdManagerToolExe>
186+
<AvdManagerToolExe Condition=" '$(AvdManagerToolExe)' == '' and '$(HostOS)' != 'Windows' ">avdmanager</AvdManagerToolExe>
187+
<AvdManagerToolExe Condition=" '$(AvdManagerToolExe)' == '' and '$(HostOS)' == 'Windows' ">avdmanager.bat</AvdManagerToolExe>
186188
<AndroidToolPath Condition=" '$(AndroidToolPath)' == '' ">$(AndroidSdkFullPath)\tools</AndroidToolPath>
187189
<AndroidToolsBinPath Condition=" '$(AndroidToolsBinPath)' == '' ">$(AndroidToolPath)\bin</AndroidToolsBinPath>
188-
<AndroidToolExe Condition=" '$(AndroidToolExe)' == '' ">android</AndroidToolExe>
189190
<CommandLineToolsFolder Condition=" '$(CommandLineToolsFolder)' == '' ">7.0</CommandLineToolsFolder>
190191
<CommandLineToolsVersion Condition=" '$(CommandLineToolsVersion)' == '' ">8512546_latest</CommandLineToolsVersion>
191192
<CommandLineToolsBinPath Condition=" '$(CommandLineToolsBinPath)' == '' ">$(AndroidSdkFullPath)\cmdline-tools\$(CommandLineToolsFolder)\bin</CommandLineToolsBinPath>
192193
<!-- Version numbers and PkgVersion are found in https://dl-ssl.google.com/android/repository/repository2-3.xml -->
193194
<EmulatorVersion Condition=" '$(EmulatorVersion)' == '' ">9364964</EmulatorVersion>
194195
<EmulatorPkgRevision Condition=" '$(EmulatorPkgRevision)' == '' ">32.1.9</EmulatorPkgRevision>
195196
<EmulatorToolPath Condition=" '$(EmulatorToolPath)' == '' ">$(AndroidSdkFullPath)\emulator</EmulatorToolPath>
196-
<EmulatorToolExe Condition=" '$(EmulatorToolExe)' == '' ">emulator</EmulatorToolExe>
197+
<EmulatorToolExe Condition=" '$(EmulatorToolExe)' == '' and '$(HostOS)' != 'Windows' ">emulator</EmulatorToolExe>
198+
<EmulatorToolExe Condition=" '$(EmulatorToolExe)' == '' and '$(HostOS)' == 'Windows' ">emulator.exe</EmulatorToolExe>
197199
<NdkBuildPath Condition=" '$(NdkBuildPath)' == '' And '$(HostOS)' != 'Windows' ">$(AndroidNdkDirectory)\ndk-build</NdkBuildPath>
198200
<NdkBuildPath Condition=" '$(NdkBuildPath)' == '' And '$(HostOS)' == 'Windows' ">$(AndroidNdkDirectory)\ndk-build.cmd</NdkBuildPath>
199201
<BundleToolJarPath Condition=" '$(BundleToolJarPath)' == '' ">$(MicrosoftAndroidSdkOutDir)bundletool.jar</BundleToolJarPath>

0 commit comments

Comments
 (0)