Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add Docs
  • Loading branch information
dellis1972 committed Nov 7, 2023
commit ca5887729eaabd6fe8e6ca2c58afb01176c5b78f
28 changes: 28 additions & 0 deletions Documentation/guides/building-apps/build-items.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,36 @@ This is so MSBuild does not try to interpret them as actual file wildcards.
NOTE: `*`, `?` and `.` will be replaced in the `BuildApk` task with the
appropriate RegEx expressions.

If the default file glob is too restrictive you can remove it by adding the
following to your csproj

```
<ItemGroup>
<AndroidPackagingOptionsExclude Remove="$([MSBuild]::Escape('*.kotlin_*')" />
</ItemGroup>
```

Added in Xamarin.Android 13.1 and .NET 7.

## AndroidPackagingOptionsInclude

A set of file glob compatible items which will allow for items to be
included from the final package. The default values are as follows

```
<ItemGroup>
<AndroidPackagingOptionsInclude Include="$([MSBuild]::Escape('*reflect.kotlin_builtins')" />
</ItemGroup>
```
Items can use file blob characters for wildcards such as `*` and `?`.
However these Items MUST use URL encoding or '$([MSBuild]::Escape(''))'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph confuses me: it appears to be saying that wildcards such as * and ? "MUST use URL encoding", but the examples here don't use URL encoding, so…???

Or are you trying to say that if you want to specify a regex instead of a glob, you need to URL encode?

This doesn't make sense either, because we always treat the value as a fileglob: https://github.com/xamarin/xamarin-android/blob/57337eda1f0d6b8533b3e3a98eb015b037f8ac5c/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs#L347-L363

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The URL encoding or MSBuild::Escape is needed because if you just did

<AndroidPackagingOptionsExclude Include="*.kotlin_*" />

The MSBuild Parsers would try to find files on disk called '.kotlin_' put those in the ItemGroup. So the values passed into BuildApk would be empty. Its the line below that paragraph that gives the explanation as to why it needs to be URL encoded.

This is so MSBuild does not try to interpret them as actual file wildcards.

NOTE: `*`, `?` and `.` will be replaced in the `BuildApk` task with the
appropriate RegEx expressions.

Added in .NET 9.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this fixes an issue, is there any chance we'd take this to .NET 8 servicing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't fix an issue, it is a new feature. So my guess is that won't qualify for backporting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I thought it might fix: #8456

If we have a way to include/exclude more or less files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does fix #8456 in that it moves the the ItemGroup to AutoImport.props, but the new ItemGroup is not required to fix that issue.


## AndroidResource

All files with an *AndroidResource* build action are compiled into
Expand Down