Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning in MAUI when referencing a project with GenerateDocumentationFile true #7272

Closed
mattjohnsonpint opened this issue May 17, 2022 · 5 comments
Labels
area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@mattjohnsonpint
Copy link
Contributor

mattjohnsonpint commented May 17, 2022

Description

If you create a project reference from a MAUI project to a class library, and that project is generating XML documentation files, you get the following build warnings - two for each reference (one for iOS, one for maccatalyst):

Xamarin.Shared.Sdk.targets(1439, 3): The file '/Users/matt/Code/MyMauiApp/ClassLibrary1/bin/Debug/net6.0/ClassLibrary1.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.
Xamarin.Shared.Sdk.targets(1439, 3): The file '/Users/matt/Code/MyMauiApp/ClassLibrary1/bin/Debug/net6.0/ClassLibrary1.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.

Steps to Reproduce

  1. Create a new MAUI app (dotnet new maui, etc.)
  2. Add a class library project to the same solution
  3. Put some XML summary comments on the public members in that class library project.
  4. Set <GenerateDocumentationFile>true</GenerateDocumentationFile> (per this) in the csproj for the class library project
  5. Reference the class library project from the MAUI app.
  6. Compile and see the warnings

Version with bug

Release Candidate 3 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS

Affected platform versions

any

Did you find any workaround?

I think this may be related or similar to xamarin/xamarin-macios#14939, but the workaround there did not work for me, and I'm not sure if this is MAUI specific or not.

Relevant log output

No response

@mattjohnsonpint mattjohnsonpint added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels May 17, 2022
@Eilon Eilon added the area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer label May 18, 2022
@VincentBu
Copy link

repro with vs main build(32522.39.main)
image

@VincentBu VincentBu added s/verified Verified / Reproducible Issue ready for Engineering Triage and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels May 23, 2022
@mattjohnsonpint
Copy link
Contributor Author

mattjohnsonpint commented May 24, 2022

I've created a workaround. Add this to the .csproj of the app (or place in a custom .targets file, etc.):

  <!-- Workaround for https://github.com/dotnet/maui/issues/7272 -->
  <Target Name="_SetPublishFolderTypeNoneOnDocFileItems" BeforeTargets="_ComputePublishLocation">
    <ItemGroup>
      <ResolvedFileToPublish Update="@(DocFileItem)" PublishFolderType="None" />
    </ItemGroup>
  </Target>

That will set the PublishFolderType metadata to None on all DocFileItem items (the generated XML doc files), and prevent the warning. (ResolvedFileToPublish is the list that the ComputeBundleLocation task uses, within the _ComputePublishLocation target, so updating it before that runs takes care of this.)

I believe something like this should be done somewhere in Xamarin.Shared.Sdk.targets for a permanent fix, but perhaps somewhere else is more appropriate.

@mattjohnsonpint
Copy link
Contributor Author

mattjohnsonpint commented Jun 10, 2022

Just an update, My workaround above did remove the warning, but it also broke everything because I was mistaken in thinking @(DocFileItem) will still be available. It's not. Here's one that actually works.

  <!-- Workaround for https://github.com/dotnet/maui/issues/7272 -->
  <Target Name="_SetPublishFolderTypeNoneOnDocFileItems" BeforeTargets="_ComputePublishLocation">
    <ItemGroup>
      <ResolvedFileToPublish
        Update="@(ResolvedFileToPublish)"
        Condition="'%(ResolvedFileToPublish.Extension)' == '.xml' And '%(ResolvedFileToPublish.PublishFolderType)' == ''"
        PublishFolderType="None" />
    </ItemGroup>
  </Target>

Though, it does presume that any .xml file that doesn't have a PublishFolderType set already must have it set to None. Is there a better way to know if a file was a generated doc file, at this point in the build process?

@mattjohnsonpint
Copy link
Contributor Author

FYI, this happens not just on MAUI, but also with an app made via dotnet new ios. Should I close this and open a new issue on https://github.com/xamarin/xamarin-macios?

@jfversluis
Copy link
Member

If it also happens on iOS without .NET MAUI involved then yes please move it there. Thanks!

@jfversluis jfversluis closed this as not planned Won't fix, can't repro, duplicate, stale Aug 26, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants