xamarin-macios icon indicating copy to clipboard operation
xamarin-macios copied to clipboard

Setting AppBundleDir to a custom value results in error MSB4044: The "SpotlightIndexer" task was not given a value for the required parameter "Input".

Open rolfbjarne opened this issue 2 years ago • 7 comments

Repro: https://gist.github.com/rolfbjarne/68af146bb629e732e32e47125e7eb818

Result:

error MSB4044: The "SpotlightIndexer" task was not given a value for the required parameter "Input".

Binlog: build-2022-05-12-175855.binlog.zip

This is most likely the problem:

https://github.com/xamarin/xamarin-macios/blob/06041ab37f153c4e14f0e4a6036e8062a6d72d74/msbuild/Xamarin.Shared/Xamarin.Shared.targets#L2648-L2652

we don't set _AppContainerDir when AppBundleDir is set.

Workaround: set _AppContainerDir yourself. This should be the parent directory of AppBundleDir.

<PropertyGroup>
    <_AppContainerDir>$([System.IO.Path]::GetDirectoryName($(AppBundleDir)))</_AppContainerDir>
</PropertyGroup>

The fix should be fairly simple: compute _AppContainerDir even if AppBundleDir is set.

rolfbjarne avatar May 12 '22 16:05 rolfbjarne

Yup, this workaround fixed it, thanks!

sandyarmstrong avatar May 12 '22 16:05 sandyarmstrong

This is what I get with the workaround added: Am I missing something?

error: cannot parse the debug map for '/dir/remove/for-public-post/$([System.IO.Path]::GetDirectoryName($(AppBundleDir)).app/AppName': No such file or directory

jtorvald avatar Jun 30 '22 15:06 jtorvald

@jtorvald looks like there's a missing parenthesis at the end, try this:

<PropertyGroup>
    <_AppContainerDir>$([System.IO.Path]::GetDirectoryName($(AppBundleDir)))/</_AppContainerDir>
</PropertyGroup>

rolfbjarne avatar Jun 30 '22 21:06 rolfbjarne

Thanks @rolfbjarne, the error parse error goes away, but still have the:

error MSB4044: The "SpotlightIndexer" task was not given a value for the required parameter "Input".

does that property need to be in the .csproj? Or in the .targets? I've it in the .csproj outside of the device condition but also tried within the one for Debug|iPhone for example and I keep getting this spotlight error.

jtorvald avatar Jun 30 '22 23:06 jtorvald

@jtorvald can you create a binlog as described here and upload it: https://github.com/xamarin/xamarin-macios/wiki/Diagnosis#build-logs?

rolfbjarne avatar Jul 01 '22 07:07 rolfbjarne

@rolfbjarne thanks for your reply. I will investigate it again next month and try to cleanup the project file. It's an old project (2012) with many updates, upgrades and other patch fixes for problems. Maybe it's good to set it up from scratch and try again.

jtorvald avatar Jul 01 '22 08:07 jtorvald

@rolfbjarne can it be because there is no trailing slash at the end of the OutputPath? I finally managed to get it compile and distribute again with adding this to the specific build configuration:

    <AppBundleName>MyAppName</AppBundleName>
    <AppBundleDir>$(OutputPath)/$(AppBundleName).app</AppBundleDir>
    <_AppContainerDir>$([System.IO.Path]::GetDirectoryName($(AppBundleDir)))/</_AppContainerDir>

During debugging and trying different things I noticed that the build failed because somewhere in the debug output there was the directory bin/iPhone/DebugAppName.app. When I added a trailing slash in the _AppContainerDir it fixed the issue. Then I realized it was maybe the contents of the OutputPath that caused the issue.

When I remove the three properties and added a trailing slash to the OutputPath: <OutputPath>bin\iPhone\Debug\</OutputPath> the build works.

So I get the feeling that there is some path-parts being glued without a separator.

jtorvald avatar Aug 09 '22 11:08 jtorvald

Ah yes, _AppContainerDir is supposed to have a trailing separator. I've updated the workaround.

rolfbjarne avatar Aug 19 '22 13:08 rolfbjarne