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

Generate targets files that throws for unsupported netstandard applicable tfms #53244

Merged
merged 5 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
<GeneratePackage Condition="(('$(PreReleaseVersionLabel)' == 'servicing' or
'$(GitHubRepositoryName)' == 'runtimelab') and
'$(MSBuildProjectExtension)' != '.sfxproj')">false</GeneratePackage>
<PlaceholderFile>$(RepositoryEngineeringDir)_._</PlaceholderFile>
</PropertyGroup>

<!-- Language configuration -->
Expand Down
36 changes: 36 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<PackageDescription Condition="'$(PackageDescription)' == '' and '$(UseRuntimePackageDisclaimer)' == 'true'">$(RuntimePackageDisclaimer)</PackageDescription>
<!-- Keep in sync as required by the Packaging SDK in Arcade. -->
<Description>$(PackageDescription)</Description>
<BeforePack>$(BeforePack);AddNETStandardCompatErrorFileForPackaging</BeforePack>
</PropertyGroup>

<!-- Remove when https://github.com/NuGet/Home/issues/10405 is implemented and consumed. -->
Expand All @@ -70,4 +71,39 @@
<PackDependsOn />
</PropertyGroup>
</Target>

<!-- Add targets file that marks a .NETStandard applicable tfm as unsupported. -->
<Target Name="AddNETStandardCompatErrorFileForPackaging"
Condition="'@(NETStandardCompatError)' != ''"
Inputs="%(NETStandardCompatError.Identity)"
Outputs="unused"
BeforeTargets="GetFiles">
<PropertyGroup>
<_NETStandardCompatErrorFilePath>$(BaseIntermediateOutputPath)netstandardcompaterrors\%(NETStandardCompatError.Identity)\$(PackageId).targets</_NETStandardCompatErrorFilePath>
<_NETStandardCompatErrorFileTarget>NETStandardCompatError_$(PackageId)_%(NETStandardCompatError.Supported.Trim('.'))</_NETStandardCompatErrorFileTarget>
<_NETStandardCompatErrorFileContent>
<![CDATA[<Project InitialTargets="$(_NETStandardCompatErrorFileTarget)">
<Target Name="$(_NETStandardCompatErrorFileTarget)"
Condition="'%24(SuppressTfmSupportBuildWarnings)' == ''">
<Error Text="$(PackageId) doesn't support %24(TargetFramework). Consider updating your TargetFramework to %(NETStandardCompatError.Supported) or later." />
</Target>
</Project>]]>
</_NETStandardCompatErrorFileContent>
</PropertyGroup>

<WriteLinesToFile File="$(_NETStandardCompatErrorFilePath)"
Lines="$(_NETStandardCompatErrorFileContent)"
WriteOnlyWhenDifferent="true"
Encoding="Unicode" />

<ItemGroup>
<None Include="$(_NETStandardCompatErrorFilePath)"
PackagePath="buildTransitive\%(NETStandardCompatError.Identity)"
Pack="true" />
<None Include="$(PlaceholderFile)"
PackagePath="buildTransitive\%(NETStandardCompatError.Supported)"
Pack="true" />
<FileWrites Include="$(_NETStandardCompatErrorFilePath)" />
Copy link
Member

Choose a reason for hiding this comment

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

Clean may not work correctly for pkgproj, but test this out for csproj if you have a chance. Clean does some weird things with paths based on where they are wrt output path

</ItemGroup>
</Target>
</Project>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<ItemGroup>
<Content Condition="'$(AdditionalRuntimeIdentifiers)' == ''" Include="runtime.json" PackagePath="/" />
<Content Condition="'$(AdditionalRuntimeIdentifiers)' != ''" Include="$(IntermediateOutputPath)runtime.json" PackagePath="/" />
<Content Include="_._" PackagePath="lib/netstandard1.0" />
<Content Include="$(PlaceholderFile)" PackagePath="lib/netstandard1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
</ProjectReference>
<ProjectReference Include="..\src\System.Drawing.Common.csproj" />
<InboxOnTargetFramework Include="$(AllXamarinFrameworks)" />
<PackageFile Include="buildTransitive\System.Drawing.Common.targets"
TargetPath="buildTransitive\netcoreapp2.0" />
<File Include="$(PlaceHolderFile)"
TargetPath="buildTransitive\netcoreapp3.0" />
<NETStandardCompatError Include="netcoreapp2.0" Supported="netcoreapp3.1" />
</ItemGroup>
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
</Project>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
<SupportedFramework>net461;netcoreapp2.0;uap10.0.16299;$(AllXamarinFrameworks)</SupportedFramework>
</ProjectReference>
<ProjectReference Include="..\src\System.Security.Cryptography.Pkcs.csproj" />
<PackageFile Include="buildTransitive\System.Security.Cryptography.Pkcs.targets"
TargetPath="buildTransitive\netcoreapp2.0" />
<File Include="$(PlaceholderFile)"
TargetPath="buildTransitive\netcoreapp3.0" />
<NETStandardCompatError Include="netcoreapp2.0" Supported="netcoreapp3.1" />
<!-- Exclude TFMs that aren't supported by the package anymore from validation. -->
<ExcludeHarvestedSupportedFramework Include="netcoreapp1.0;netcoreapp1.1;netcore50;uap10.0;net46" />
</ItemGroup>
Expand Down

This file was deleted.

5 changes: 1 addition & 4 deletions src/libraries/System.Speech/pkg/System.Speech.pkgproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
<InboxOnTargetFramework Include="net45">
<AsFrameworkReference>true</AsFrameworkReference>
</InboxOnTargetFramework>
<PackageFile Include="buildTransitive\System.Speech.targets"
TargetPath="buildTransitive\netcoreapp2.0" />
<File Include="$(PlaceholderFile)"
TargetPath="buildTransitive\netcoreapp2.1" />
<NETStandardCompatError Include="netcoreapp2.0" Supported="netcoreapp3.1" />
</ItemGroup>
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
</Project>

This file was deleted.