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
Use $(TargetFrameworkIdentifier) and $(TargetFrameworkVersion) consistently (#25428)
- always use `$([MSBuild]::VersionXYZ(...))` for version checks
- use `$(NETCoreAppFrameworkIdentifier)` where it's available
- move `$(KnownAppHostPackOrFrameworkReferenceTfm)` setting to Directory.Build.props
- use it to correct `@(KnownFrameworkReference)` updates
- metadata of those items still uses `netcoreapp5.0`
- see also dotnet/efcore#22279 (comment)
nits:
- do not assume `$(TargetFrameworkVersion)` starts with a 'v'; valid w/o it
- add `$(_IsMicrosoftNETCoreApp20OrOlder)` property in OpenAPI targets file
- evaluate the `Condition` once instead of three times
<!-- For 2.x projects desktop and .NET Core projects, if they're opting in to runtime compilation (indicated by PreserveCompilationContext=true), set PreserveCompilationReferences = true -->
230
-
<PreserveCompilationReferencesCondition="'$(PreserveCompilationContext)' == 'true' AND (('$(TargetFrameworkIdentifier)' == '.NETFramework') OR ('$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' < '3.0'))">true</PreserveCompilationReferences>
231
+
<PreserveCompilationReferencesCondition=" '$(PreserveCompilationContext)' == 'true' AND
232
+
('$(TargetFrameworkIdentifier)' == '.NETFramework' OR
233
+
('$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND
Text="OpenAPI document generation is disabled. Add '<OpenApiGenerateDocuments>true</OpenApiGenerateDocuments>' to the project." />
23
27
<!-- E.g. project set $(OpenApiGenerateDocuments) to 'true' but TFM is not supported. -->
24
28
<Error
25
-
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(TargetFrameworkVersion.TrimStart("vV"))' < '2.1'"
29
+
Condition="$(_IsMicrosoftNETCoreApp20OrOlder)"
26
30
Text="OpenAPI document generation is not supported when targeting netcoreapp2.0 or earlier. Disable the feature or move to a later target framework." />
27
31
<!-- E.g. project set $(OpenApiGenerateDocumentsOnBuild) to 'false' but did not invoke GenerateOpenApiDocuments. -->
Text="OpenAPI document generation is disabled. Add '<OpenApiGenerateDocuments>true</OpenApiGenerateDocuments>' to the project." />
44
48
<!-- E.g. project sets $(OpenApiGenerateDocuments) to 'true' but TFM is not supported. -->
45
49
<Error
46
-
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(TargetFrameworkVersion.TrimStart("vV"))' < '2.1'"
50
+
Condition="$(_IsMicrosoftNETCoreApp20OrOlder)"
47
51
Text="OpenAPI document generation is not supported when targeting netcoreapp2.0 or earlier. Disable the feature or move to a later target framework." />
0 commit comments