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

Warning when referencing a project with GenerateDocumentationFile true

Open mattjohnsonpint opened this issue 3 years ago • 2 comments

Migrated from https://github.com/dotnet/maui/issues/7272

Steps to Reproduce

  1. 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 
  1. Edit MyClassLib/Class1.cs and add an XML summary comment to the class:
namespace MyClassLib;

/// <summary>
/// Test Class
/// </summary>
public class Class1
{
}
  1. Edit MyClassLib.csproj and add the following to the <PropertyGroup> element to enable generating the documentation file:
 <GenerateDocumentationFile>true</GenerateDocumentationFile>
  1. dotnet build on 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

msbuild.binlog.zip

Example Project

IosTest.zip

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>

mattjohnsonpint avatar Sep 07 '22 23:09 mattjohnsonpint

Note: Also occurs for Mac Catalyst, but not for Android.

mattjohnsonpint avatar Sep 07 '22 23:09 mattjohnsonpint

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"

rolfbjarne avatar Sep 08 '22 08:09 rolfbjarne

ComputeBundleLocation task should ignore FinalDocFile items.

Youssef1313 avatar Jan 19 '23 11:01 Youssef1313