Skip to content

[Clean-up] Remove all extraneous warnings #99

Open

Description

@michael-hawker

We have a lot of warnings MSB4011 in the project about duplicated includes for props files.

There's also an MSB3277 about different versions of System.Collections.Immutable.

These extra warnings make it more difficult to see analyzer warnings and other style issues which may get flagged by the IDE. We should aim for having no extraneous warnings in the project so we know when we have a clean build.

Activity

  1. added
    help wanted
    good first issue
    dev loop ➰
    on May 5, 2022
  2. added this to the Future milestone on May 5, 2022
  3. mrlacey commented on May 9, 2022

    @mrlacey
    Contributor

    The MSB4011 warnings will need to be suppressed as the projects in the solution need to explicitly include some things that should get included automatically but aren't always.

  4. michael-hawker commented on May 10, 2022

    @michael-hawker
    MemberAuthor

    @mrlacey did you want to add the suppression then and then investigate any of the remaining warnings?

  5. self-assigned this
    on May 11, 2022
  6. mrlacey commented on May 11, 2022

    @mrlacey
    Contributor

    As per the details at dotnet/msbuild#4038 MSB4011 cannot be suppressed by properties, only from the command line.
    It can be suppressed in the CI server scripts but VS is always going to report these. Not sure if it's worth documenting anywhere.

  7. michael-hawker commented on May 11, 2022

    @michael-hawker
    MemberAuthor

    Nice find @mrlacey, thanks. Not sure we can work around them as we use the props for dependency management as well, so they're going to get included multiple times. I've added a comment to the linked issue.

  8. mrlacey commented on Jun 7, 2022

    @mrlacey
    Contributor

    Removing my assignment as future work on this is unscheduled and to allow for someone else to look at it if they wish.

  9. removed their assignment
    on Jun 7, 2022
  10. michael-hawker commented on Jun 8, 2022

    @michael-hawker
    MemberAuthor

    Thanks @mrlacey. I know @azchohfi was curious if we could make improvements to the props file structure here to cause these errors not to occur as well. We can pick this up later since it's all internalized from the templates (I think).

    I think we could investigate in the future using a custom property defined in MSBuild, then only import certain files if that's not defined. I think I've seen that in the SDK props files to make sure a particular props is only defined once as the property gets set by the props file, and then other imports ignore it later in the pipeline.

  11. mrlacey commented on Jun 8, 2022

    @mrlacey
    Contributor

    Some of the dependency issues are due to the use of Directory.Build.props files that are included automatically but also included explicitly by some of the other props files.
    Now I'm wondering if it's possible to just use props files that are included explicitly to avoid this issue. @Arlodotexe did you look at this when setting up the props files?

  12. Arlodotexe commented on Jun 23, 2022

    @Arlodotexe
    Member

    Now I'm wondering if it's possible to just use props files that are included explicitly to avoid this issue

    Not something I've looked into doing, but I know that some SDK style projects are always going to pull in Directory.Build.props, and some don't (I didn't keep track of which is which).

    I'm not aware of any MSBuild trickery you could do to prevent it from importing Directory.Build.props automatically.

  13. mrlacey commented on Jun 24, 2022

    @mrlacey
    Contributor

    Now I'm wondering if it's possible to just use props files that are included explicitly to avoid this issue

    Not something I've looked into doing, but I know that some SDK style projects are always going to pull in Directory.Build.props, and some don't (I didn't keep track of which is which).

    I'm not aware of any MSBuild trickery you could do to prevent it from importing Directory.Build.props automatically.

    I was thinking that changing the name of the file so that nothing imports it automatically and then when it's imported could be fully controlled.

  14. michael-hawker commented on Jun 30, 2022

    @michael-hawker
    MemberAuthor

    @Arlodotexe I have a suspicion that it's an issue for the frameworks which don't support SDK style projects (but we're using them anyway). I think we're missing the use of MSBuild.Sdk.Extras on them (which would then help them behave properly and pull in the Directory.Build.props file), but I think there's a bit more work involved to just swap them over, as then VS complains about some project configuration and duplicate files like AssemblyInfo.cs.

    You can see that gets us the new project display in VS and finds the other props files at least (from llama/sdkextras branch):
    image

    Compared to the old style:
    image

  15. michael-hawker commented on Jul 1, 2022

    @michael-hawker
    MemberAuthor

    Applying a similar pattern to Microsoft.Common.props file I saw here:

        <PropertyGroup>
            <ImportDirectoryBuildProps Condition="'$(ImportDirectoryBuildProps)' == ''">true</ImportDirectoryBuildProps>
        </PropertyGroup>
        <Import Project="$(DirectoryBuildPropsPath)" Condition="'$(ImportDirectoryBuildProps)' == 'true' and exists('$(DirectoryBuildPropsPath)')"/>

    Seems to be working. Need to do the same to our directorybuild prop workaround from the above for now and that may be it. Making some other clean-up here as well.

  16. michael-hawker commented on Jul 15, 2022

    @michael-hawker
    MemberAuthor

    #198 resolved most of our MSB4011 warnings, and probably means #181 is obsolete now.

    Looks like most warnings are now:

    • .NET Native things (new?)
    • CodeAnalysis missing in tests or something
    • Directory.build.props include (MSB4011 remaining) - think related to the note I had around non-SDK-style project runtimes needing MSBuild Extras)
  17. removed their assignment
    on Jul 17, 2022
  18. michael-hawker commented on Sep 8, 2022

    @michael-hawker
    MemberAuthor

    We got a tip from Matthew that the 4.3.0 analyzers package has an issue which is causing the warning about the Immutable package conflict. If we downgrade to 4.2, that should resolve those messages.

    See: dotnet/roslyn#63780

    and dotnet/maui#9942

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    build 🔥dev loop ➰good first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions