You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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.
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.
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.
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?
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.
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.
@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):
Applying a similar pattern to Microsoft.Common.props file I saw here:
<PropertyGroup>
<ImportDirectoryBuildPropsCondition="'$(ImportDirectoryBuildProps)' == ''">true</ImportDirectoryBuildProps>
</PropertyGroup>
<ImportProject="$(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.
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.
Activity
mrlacey commentedon May 9, 2022
The
MSB4011warnings 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.michael-hawker commentedon May 10, 2022
@mrlacey did you want to add the suppression then and then investigate any of the remaining warnings?
mrlacey commentedon May 11, 2022
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.
michael-hawker commentedon May 11, 2022
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.
mrlacey commentedon Jun 7, 2022
Removing my assignment as future work on this is unscheduled and to allow for someone else to look at it if they wish.
michael-hawker commentedon Jun 8, 2022
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.
mrlacey commentedon Jun 8, 2022
Some of the dependency issues are due to the use of
Directory.Build.propsfiles 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?
Arlodotexe commentedon Jun 23, 2022
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.propsautomatically.mrlacey commentedon Jun 24, 2022
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.
michael-hawker commentedon Jun 30, 2022
@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.Extrason them (which would then help them behave properly and pull in theDirectory.Build.propsfile), 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 likeAssemblyInfo.cs.You can see that gets us the new project display in VS and finds the other props files at least (from

llama/sdkextrasbranch):Compared to the old style:

michael-hawker commentedon Jul 1, 2022
Applying a similar pattern to
Microsoft.Common.propsfile I saw here: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.
michael-hawker commentedon Jul 15, 2022
#198 resolved most of our MSB4011 warnings, and probably means #181 is obsolete now.
Looks like most warnings are now:
michael-hawker commentedon Sep 8, 2022
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