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

Only add placeholder pkg file if folder is empty #67647

Conversation

ViktorHofer
Copy link
Member

@ViktorHofer ViktorHofer commented Apr 6, 2022

Fixes #63413
Fixes #60870

Placeholder files are added unconditionally by the .NETStandard compat
error packaging infrastructure, even if the
buildTransitive/$(SupportedTFM) package folder isn't empty.

That hinders our libraries to package their own set of buildTransitive
props and targets files for the supported set of tfms.

This change makes sure that placeholder files are added only if no None
or Content items are declared that point to the same package folder.

Adding documentation that explains the .NETStandard compatibility
packaging infrasturcture and how to correctly package hand-authored
msbuild files next to the generated targets files.

@ViktorHofer ViktorHofer added this to the 7.0.0 milestone Apr 6, 2022
@ViktorHofer ViktorHofer self-assigned this Apr 6, 2022
@ghost
Copy link

ghost commented Apr 6, 2022

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #63413

Placeholder files are added unconditionally by the .NETStandard compat
error packaging infrastructure, even if the
buildTransitive/$(SupportedTFM) package folder isn't empty.

That hinders our libraries to package their own set of buildTransitive
props and targets files for the supported set of tfms.

This change makes sure that placeholder files are added only if no None
or Content items are declared that point to the same package folder.

Adding documentation that explains the .NETStandard compatibility
packaging infrasturcture and how to correctly package hand-authored
msbuild files next to the generated targets files.

Author: ViktorHofer
Assignees: ViktorHofer
Labels:

area-Infrastructure-libraries

Milestone: 7.0.0

eng/packaging.targets Outdated Show resolved Hide resolved
eng/packaging.targets Outdated Show resolved Hide resolved
@ViktorHofer
Copy link
Member Author

@eerhardt any objections if I fix #60870 as well to actually test if that works together?

@eerhardt
Copy link
Member

eerhardt commented Apr 6, 2022

any objections if I fix #60870 as well to actually test if that works together?

No objections from me. I was going to do it after your change. But if you want to take it here, that's totally fine with me.

@ViktorHofer ViktorHofer force-pushed the PkgMSBuildPropsTargetsNETStandardCompatInfra branch from 09ac364 to 2bfcb48 Compare April 6, 2022 20:02
@ViktorHofer
Copy link
Member Author

@eerhardt the change is ready to be reviewed.

BeforePack must be used. Setting both to ensure that we are always running before other targets. -->
<PackDependsOn>AddNETStandardCompatErrorFileForPackaging;IncludeAnalyzersInPackage;$(PackDependsOn)</PackDependsOn>
<BeforePack>AddNETStandardCompatErrorFileForPackaging;IncludeAnalyzersInPackage;$(BeforePack)</BeforePack>
<BeforePack>$(BeforePack);IncludeAnalyzersInPackage;AddNETStandardCompatErrorFileForPackaging</BeforePack>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PackDependsOn doesn't work anymore with the sequencing that we depend on. The BeforePack hook is fine as we don't rely on NuGet.Build.Tasks.Pack as an OOB nuget package anymore.

@ViktorHofer ViktorHofer force-pushed the PkgMSBuildPropsTargetsNETStandardCompatInfra branch from 2bfcb48 to 4d69282 Compare April 6, 2022 20:16
Comment on lines +71 to +84
<ItemGroup>
<None Include="$(PlaceholderFile)"
Pack="true"
PackagePath="$(BuildOutputTargetFolder)\$(NetFrameworkMinimum)\"
Condition="'$(AddNETFrameworkPlaceholderFileToPackage)' == 'true'" />
<None Include="$(PlaceholderFile)"
Pack="true"
PackagePath="$(BuildOutputTargetFolder)\MonoAndroid10\;
$(BuildOutputTargetFolder)\MonoTouch10\;
$(BuildOutputTargetFolder)\xamarinios10\;
$(BuildOutputTargetFolder)\xamarinmac20\;
$(BuildOutputTargetFolder)\xamarintvos10\;
$(BuildOutputTargetFolder)\xamarinwatchos10\"
Condition="'$(AddXamarinPlaceholderFilesToPackage)' == 'true'" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just clean-up to avoid multiple items.

Comment on lines +89 to +101
<!-- Include a netstandard compat error if the project targets both .NETStandard and
.NETCoreApp. This prohibits users to consume packages on an older .NETCoreApp version
than the minimum supported one. -->
<ItemGroup>
<NETStandardCompatError Include="netcoreapp2.0"
Supported="$(NetCoreAppMinimum)"
Condition="$(TargetFrameworks.Contains('netstandard2.')) and
($(TargetFrameworks.Contains('$(NetCoreAppMinimum)')) or $(TargetFrameworks.Contains('$(NetCoreAppCurrent)')))" />
<NETStandardCompatError Include="net461"
Supported="$(NetFrameworkMinimum)"
Condition="$(TargetFrameworks.Contains('netstandard2.0')) and
($(TargetFrameworks.Contains('$(NetFrameworkMinimum)')) or $(TargetFrameworks.Contains('net47')) or $(TargetFrameworks.Contains('net48')))" />
</ItemGroup>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block was moved up without any changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like

'$(DisableNETStandardCompatErrorForNETCoreApp)' != 'true'" />

was removed in the move.

Copy link
Member Author

@ViktorHofer ViktorHofer Apr 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, those two items are now always defined but there is a new switch to disable the NETStandard compat errors. (which isn't used anywhere but it's good to have it)

Originally reported in dotnet#63413,
placeholder files are added unconditionally by the .NETStandard compat
error packaging infrastructure, even if the
buildTransitive/$(SupportedTFM) folder isn't empty.

That hinders our libraries to package their own set of buildTransitive
props and targets files for the supported set of tfms.

This change makes sure that placeholder files are added only if no None
or Content items are declared that point to the same package folder.

Adding documentation that explains the .NETStandard compatibility
packaging infrasturcture and how to correctly package hand-authored
msbuild files next to the generated targets files.
@ViktorHofer ViktorHofer force-pushed the PkgMSBuildPropsTargetsNETStandardCompatInfra branch from 4d69282 to 4398a31 Compare April 6, 2022 20:27
Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few comments. Nothing major.

@ViktorHofer ViktorHofer merged commit 538934c into dotnet:main Apr 12, 2022
@ViktorHofer ViktorHofer deleted the PkgMSBuildPropsTargetsNETStandardCompatInfra branch April 12, 2022 20:16
@am11
Copy link
Member

am11 commented Apr 13, 2022

@ViktorHofer, fyi, codeflow is hitting the following error, probably related to this change (diff: 5707668...f2ce5e8):

error : System.Text.Encodings.Web doesn't support net7.0. Consider updating your TargetFramework to net6.0 or later.

(error message itself seems erroneous since net7.0 > net6.0 🤔)

dotnet/aspnetcore#41166
dotnet/sdk#24837

@eerhardt
Copy link
Member

Looks like the issue is that the placeholder file is getting added as a folder?

image

@am11
Copy link
Member

am11 commented Apr 13, 2022

Just noticed that net461 will be out of support on April 22, 2022. We may want to drop it from buildTransitive.

@eerhardt
Copy link
Member

Just noticed that net461 will be out of support on April 22, 2022. We may want to drop it from buildTransitive.

That .targets file is there to give users errors/warnings that net461 is not supported.

<Project InitialTargets="NETStandardCompatError_System_Text_Encodings_Web_net462">
  <Target Name="NETStandardCompatError_System_Text_Encodings_Web_net462"
          Condition="'$(SuppressTfmSupportBuildWarnings)' == ''">
    <Error Text="System.Text.Encodings.Web doesn't support $(TargetFramework). Consider updating your TargetFramework to net462 or later." />
  </Target>
</Project>

@ViktorHofer
Copy link
Member Author

Oh thanks... Will submit a fix asap

@ghost ghost locked as resolved and limited conversation to collaborators May 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.