xamarin-macios
xamarin-macios copied to clipboard
Warning when referencing a project with GenerateDocumentationFile true
Migrated from https://github.com/dotnet/maui/issues/7272
Steps to Reproduce
- Create solution with an iOS app that references a .NET 6 class library:
mkdir IosTest
cd IosTest
dotnet new sln
dotnet new ios -n MyTestApp
dotnet new classlib -n MyClassLib
dotnet sln add MyTestApp MyClassLib
dotnet add MyTestApp/MyTestApp.csproj reference MyClassLib/MyClassLib.csproj
- Edit
MyClassLib/Class1.csand add an XML summary comment to the class:
namespace MyClassLib;
/// <summary>
/// Test Class
/// </summary>
public class Class1
{
}
- Edit
MyClassLib.csprojand add the following to the<PropertyGroup>element to enable generating the documentation file:
<GenerateDocumentationFile>true</GenerateDocumentationFile>
dotnet buildon the solution
Expected Behavior
It should build without warnings
Actual Behavior
The following warning is shown:
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.447/targets/Xamarin.Shared.Sdk.targets(1444,3): warning : The file '/Users/matt/IosTest/MyClassLib/bin/Debug/net6.0/MyClassLib.xml' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle. [/Users/matt/IosTest/MyTestApp/MyTestApp.csproj]
Environment
Version information
Output of dotnet --info:
.NET SDK (reflecting any global.json):
Version: 6.0.400
Commit: 7771abd614
Runtime Environment:
OS Name: Mac OS X
OS Version: 12.5
OS Platform: Darwin
RID: osx.12-arm64
Base Path: /usr/local/share/dotnet/sdk/6.0.400/
global.json file:
Not found
Host:
Version: 6.0.8
Architecture: arm64
Commit: 55fb7ef977
.NET SDKs installed:
6.0.400 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Build Logs
Example Project
Workaround
Adding the following target to MyTestApp.csproj removes the warning.
<Target Name="_SetPublishFolderTypeNoneOnDocFileItems" BeforeTargets="_ComputePublishLocation">
<ItemGroup>
<ResolvedFileToPublish
Update="@(ResolvedFileToPublish)"
Condition="'%(ResolvedFileToPublish.Extension)' == '.xml' And '%(ResolvedFileToPublish.PublishFolderType)' == ''"
PublishFolderType="None" />
</ItemGroup>
</Target>
Note: Also occurs for Mac Catalyst, but not for Android.
This is related to #14939, but the solution would be:
to amend our logic that figures out what to do with files in ResolvedFileToPublish (main/dotnet/BundleContents.md), to say something like: "If an xml file matches the filename of any assembly, then treat that xml file as PublishFolderType=None"
ComputeBundleLocation task should ignore FinalDocFile items.