diff options
author | Viktor Hofer <viktor.hofer@microsoft.com> | 2021-08-10 08:19:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-10 08:19:06 +0300 |
commit | 4d82932722b56924598708f991961a75e5a90b36 (patch) | |
tree | 45324b86553cbacbe01f5552f918c5bb514f1fbf /Directory.Build.targets | |
parent | 08166d32268e5260dc3304de21f7750a03978a0a (diff) |
Automatically generate .NETStandard compat errors (#57057)
* Automatically generate .NETStandard compat errors
Before this change, a project had to explicitly add a
NETStandardCompatError item to declare that a given tfm range
shouldn't be supported when packaging.
Automate this logic so that projects don't need to specify the item
themselves anymore. Instead condition the NETStandardCompatError target
calcuation logic on the existence of both a .NETStandard and a
.NETCoreApp tfm.
* Update Directory.Build.targets
* Update packaging.targets
* Update eng/packaging.targets
Co-authored-by: Santiago Fernandez Madero <safern@microsoft.com>
Co-authored-by: Santiago Fernandez Madero <safern@microsoft.com>
Diffstat (limited to 'Directory.Build.targets')
-rw-r--r-- | Directory.Build.targets | 40 |
1 files changed, 3 insertions, 37 deletions
diff --git a/Directory.Build.targets b/Directory.Build.targets index 532b24c473a..f8e663fdc26 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,4 +1,4 @@ -<Project InitialTargets="ErrorForMissingPackageDescription;_OverridePackDependsOn"> +<Project InitialTargets="_OverridePackDependsOn"> <PropertyGroup> <!-- For non-SDK projects that import this file and then import Microsoft.Common.targets, @@ -54,12 +54,12 @@ <PackageDescription Condition="'$(PackageDescription)' == '' and '$(UseRuntimePackageDisclaimer)' == 'true'">$(RuntimePackageDisclaimer)</PackageDescription> <!-- Keep in sync as required by the Packaging SDK in Arcade. --> <Description>$(PackageDescription)</Description> - <GenerateNuspecDependsOn>AddNETStandardCompatErrorFileForPackaging;$(GenerateNuspecDependsOn)</GenerateNuspecDependsOn> + <GenerateNuspecDependsOn>ErrorForMissingPackageDescription;$(GenerateNuspecDependsOn)</GenerateNuspecDependsOn> </PropertyGroup> <!-- Remove when https://github.com/NuGet/Home/issues/10405 is implemented and consumed. --> <Target Name="ErrorForMissingPackageDescription" - Condition="'$(IsPackable)' == 'true' and '$(PackageDescription)' == ''"> + Condition="'$(PackageDescription)' == ''"> <Error Text="Required property 'PackageDescription' is missing for $(MSBuildProjectName)." /> </Target> @@ -72,40 +72,6 @@ </PropertyGroup> </Target> - <!-- Add targets file that marks a .NETStandard applicable tfm as unsupported. --> - <Target Name="AddNETStandardCompatErrorFileForPackaging" - Condition="'@(NETStandardCompatError)' != ''" - Inputs="%(NETStandardCompatError.Identity)" - Outputs="unused"> - <PropertyGroup> - <_NETStandardCompatErrorFilePath>$(BaseIntermediateOutputPath)netstandardcompaterrors\%(NETStandardCompatError.Identity)\$(PackageId).targets</_NETStandardCompatErrorFilePath> - <_NETStandardCompatErrorFileTarget>NETStandardCompatError_$(PackageId.Replace('.', '_'))_$([System.String]::new('%(NETStandardCompatError.Supported)').Replace('.', '_'))</_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)" - Overwrite="true" - WriteOnlyWhenDifferent="true" /> - - <ItemGroup> - <None Include="$(_NETStandardCompatErrorFilePath)" - PackagePath="buildTransitive\%(NETStandardCompatError.Identity)" - Pack="true" /> - <None Include="$(PlaceholderFile)" - PackagePath="buildTransitive\%(NETStandardCompatError.Supported)" - Pack="true" /> - <FileWrites Include="$(_NETStandardCompatErrorFilePath)" /> - </ItemGroup> - </Target> - <!-- Arcade SDK versioning is defined by static properties in a targets file: work around this by moving properties based on versioning into a target. |