Repository navigation
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
73 lines (67 loc) · 4.96 KB
/
Copy pathDirectory.Build.targets
File metadata and controls
73 lines (67 loc) · 4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<Project>
<PropertyGroup>
<PackageLicenseExpression Condition="'$(AshlarCommercialProject)' == 'true'"></PackageLicenseExpression>
<PackageLicenseExpression Condition="'$(AshlarCommercialProject)' != 'true'">Apache-2.0</PackageLicenseExpression>
</PropertyGroup>
<!-- Override SDK default 1.0.0 after project evaluation (root VERSION file). -->
<PropertyGroup Condition="Exists('$(MSBuildThisFileDirectory)VERSION') AND '$(IsPackable)' == 'true'">
<AshlarPackageVersion>$([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)VERSION').Trim())</AshlarPackageVersion>
<PackageVersion>$(AshlarPackageVersion)</PackageVersion>
<Version>$(AshlarPackageVersion)</Version>
</PropertyGroup>
<!-- Many test hosts (and the net8.0 inner build of multi-targeted ones) still target net8.0, but a
machine provisioned per the docs has only the .NET 10 SDK, whose shared runtimes are
Microsoft.NETCore.App/AspNetCore.App 10.x. Without a roll-forward policy the very first
`dotnet test -f net8.0` (or `dotnet run` of a net8.0 sample) fails with
"You must install or update .NET to run this application" while `dotnet build` succeeds.
Lives here rather than in Directory.Build.props: OutputType is assigned by the project body,
which MSBuild imports after .props and before .targets, so a .props-side condition on it is
always empty. RollForward is only written into *.runtimeconfig.json (executables and test
hosts), so gating it costs nothing for libraries either way. -->
<PropertyGroup Condition="'$(OutputType)' == 'Exe' OR '$(IsTestProject)' == 'true'">
<RollForward Condition="'$(RollForward)' == ''">Major</RollForward>
</PropertyGroup>
<!-- ASHLAREXP001 is the [Experimental] diagnostic on the autonomy (self-extension) surface; it exists
for EXTERNAL consumers (docs/SdkCompatibilityPolicy.md, "Experimental tier"). The repo's own test
projects exercise that surface by design, so they opt in once here. Same .targets placement
rationale as RollForward above: IsTestProject is set by the project body. -->
<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
<NoWarn>$(NoWarn);ASHLAREXP001</NoWarn>
</PropertyGroup>
<!-- ASHLAREXP002 is the [Experimental] diagnostic on the security and deployment-profile surface of
Ashlar.Abstractions (docs/SdkCompatibilityPolicy.md#ashlarexp002); it too exists for EXTERNAL
consumers. The repo's own test projects exercise that surface by design, so they opt in once here,
like ASHLAREXP001 above. Ashlar's own shipped assemblies opt in per project, each one reviewed in
DiagnosticSuppressionConventionTests (ReviewedProjectWideDisables). -->
<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
<NoWarn>$(NoWarn);ASHLAREXP002</NoWarn>
</PropertyGroup>
<!-- Directory.Build.props adds versionless System.Text.Encodings.Web and
System.Text.RegularExpressions references so central package management can lift the
vulnerable transitives. That file is imported before the project body, so it cannot see a
project that sets ManagePackageVersionsCentrally to false. Leaving the versionless items
in place is NU1015. Metadata conditions are illegal outside a target (MSB4190/MSB4191),
so the drop runs here, before NuGet collects references. A project that pins its own
Version keeps that pin. -->
<Target Name="AshlarDropVersionlessAuditOverrides" BeforeTargets="CollectPackageReferences">
<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' == 'false'">
<PackageReference Remove="System.Text.Encodings.Web" Condition="'%(PackageReference.Version)' == ''" />
<PackageReference Remove="System.Text.RegularExpressions" Condition="'%(PackageReference.Version)' == ''" />
</ItemGroup>
</Target>
<!-- NetStandard compatibility shims (Unity 2019+): required members, init-only, etc.
Evaluated statically (not inside a <Target>) so IDE/language-server design-time builds
also see the polyfills; a Target-added <Compile> item is invisible to design-time builds,
which made every `required` member report CS0656 (missing RequiredMemberAttribute) in the editor.
Placed in Directory.Build.targets (not .props) because TargetFrameworkIdentifier is only
resolved per inner build, which is available by the time this file is imported. -->
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'">
<Compile Include="$(MSBuildThisFileDirectory)src/Ashlar.Compat/Polyfills/*.cs">
<Link>Polyfills/%(Filename)%(Extension)</Link>
</Compile>
<!-- Core.Application is an Abstractions friend for internal refusal-chain handling. It therefore
sees Abstractions' ExperimentalAttribute polyfill; compiling another creates CS0436. -->
<Compile Remove="$(MSBuildThisFileDirectory)src/Ashlar.Compat/Polyfills/ExperimentalAttribute.cs"
Condition="'$(MSBuildProjectName)' == 'Ashlar.Core.Application'" />
</ItemGroup>
</Project>