Repository navigation
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
95 lines (84 loc) · 5.67 KB
/
Copy pathDirectory.Build.targets
File metadata and controls
95 lines (84 loc) · 5.67 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<Project>
<!--
SDK otherwise appends +gitsha to InformationalVersion when SourceRevisionId is present.
This is not the application version. $(Version) stays the NuGet package version.
-->
<PropertyGroup>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
<!--
Production executable copyright. GenerateAssemblyInfo emits AssemblyCopyrightAttribute from $(Copyright).
-->
<PropertyGroup Condition="'$(MSBuildProjectName)' == 'VectorNNTPD.BackFillerService' OR '$(MSBuildProjectName)' == 'VectorNNTPD.StorageService'">
<Copyright>©2026 Chris Knipe <cknipe@opticnetworks.net></Copyright>
</PropertyGroup>
<PropertyGroup Condition="'$(MSBuildProjectName)' == 'VectorNNTPD.ReaderService' OR '$(MSBuildProjectName)' == 'VectorNNTPD.TransitService'">
<Copyright>© 2026 Chris Knipe <cknipe@opticnetworks.net></Copyright>
</PropertyGroup>
<!--
Production executable version: 1.0.<days since 2000-01-01>.<seconds since local midnight / 2>.
One DateTime.Now tick count feeds both components. Deterministic compilation stays enabled.
Libraries and tools are left on the SDK default version.
-->
<PropertyGroup>
<_IsProductionExecutable Condition="'$(MSBuildProjectName)' == 'VectorNNTPD.BackFillerService' OR '$(MSBuildProjectName)' == 'VectorNNTPD.StorageService' OR '$(MSBuildProjectName)' == 'VectorNNTPD.ReaderService' OR '$(MSBuildProjectName)' == 'VectorNNTPD.TransitService'">true</_IsProductionExecutable>
</PropertyGroup>
<Target Name="ApplyDateTimeApplicationVersion"
BeforeTargets="GetAssemblyVersion"
Condition="'$(DesignTimeBuild)' != 'true' AND '$(_IsProductionExecutable)' == 'true'">
<PropertyGroup>
<_ApplicationVersionNow>$([System.DateTime]::Now.Ticks)</_ApplicationVersionNow>
<_ApplicationVersionBuild>$([System.DateTime]::new($([System.Int64]::Parse($(_ApplicationVersionNow)))).Subtract($([System.DateTime]::new(2000,1,1))).Days)</_ApplicationVersionBuild>
<_ApplicationVersionRevision>$([System.Convert]::ToInt32($([System.Math]::Truncate($([MSBuild]::Divide($([System.DateTime]::new($([System.Int64]::Parse($(_ApplicationVersionNow)))).TimeOfDay.TotalSeconds), 2))))))</_ApplicationVersionRevision>
<AssemblyVersion>1.0.$(_ApplicationVersionBuild).$(_ApplicationVersionRevision)</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<InformationalVersion>$(AssemblyVersion)</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
</Target>
<!--
Production publish is self-contained Native AOT for win-x64 and linux-x64 only.
A normal build does not set RuntimeIdentifier, so libraries, tests, and tools stay portable.
-->
<PropertyGroup Condition="'$(_IsProductionExecutable)' == 'true'">
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
<SelfContained Condition="'$(RuntimeIdentifier)' == 'win-x64' OR '$(RuntimeIdentifier)' == 'linux-x64'">true</SelfContained>
<PublishAot Condition="'$(RuntimeIdentifier)' == 'win-x64' OR '$(RuntimeIdentifier)' == 'linux-x64'">true</PublishAot>
</PropertyGroup>
<!--
StorageService, ReaderService, and TransitService use Serilog.Settings.Configuration for
MinimumLevel/enrichment while sinks are registered explicitly. Native AOT/single-file
analysis then fails publish on Serilog.Settings.Configuration:
IL3000/IL3002 (Assembly.Location / DependencyContext in single-file) and IL2104/IL3050
(assembly trim/AOT analysis). Scope is those hosts + PublishAot only. BackFiller does
not need this because it never calls ReadFrom.Configuration.
-->
<PropertyGroup Condition="('$(MSBuildProjectName)' == 'VectorNNTPD.StorageService' OR '$(MSBuildProjectName)' == 'VectorNNTPD.ReaderService' OR '$(MSBuildProjectName)' == 'VectorNNTPD.TransitService') AND '$(PublishAot)' == 'true'">
<NoWarn>$(NoWarn);IL2026;IL2104;IL3050;IL3000;IL3002</NoWarn>
<WarningsNotAsErrors>$(WarningsNotAsErrors);IL2026;IL2104;IL3050</WarningsNotAsErrors>
<ILLinkTreatWarningsAsErrors>false</ILLinkTreatWarningsAsErrors>
<IlcTreatWarningsAsErrors>false</IlcTreatWarningsAsErrors>
</PropertyGroup>
<Target Name="RejectNonX64Platform"
BeforeTargets="Restore;Build;Publish">
<Error Condition="'$(Platform)' != 'x64'"
Text="VectorNNTPD builds only for Platform x64. Platform '$(Platform)' is not supported." />
</Target>
<Target Name="RejectUnsupportedProductionRuntimeIdentifier"
BeforeTargets="Restore;Build;Publish"
Condition="'$(_IsProductionExecutable)' == 'true' AND '$(RuntimeIdentifier)' != '' AND '$(RuntimeIdentifier)' != 'win-x64' AND '$(RuntimeIdentifier)' != 'linux-x64'">
<Error Text="Production applications publish only win-x64 and linux-x64. RuntimeIdentifier '$(RuntimeIdentifier)' is not supported." />
</Target>
<!--
PublishAot is true only when RuntimeIdentifier is win-x64 or linux-x64.
The SDK imports ILCompiler targets only when that package was restored.
A restore without the runtime identifier does not download it, and publishing
without restoring again then emits a self-contained managed app instead of failing.
-->
<Target Name="RequireNativeAotCompiler"
BeforeTargets="Publish"
Condition="'$(PublishAot)' == 'true' AND ('$(RuntimeIdentifier)' == 'win-x64' OR '$(RuntimeIdentifier)' == 'linux-x64')">
<Error Condition="'$(ILCompilerTargetsPath)' == ''"
Text="Native AOT publish for $(RuntimeIdentifier) did not restore the ILCompiler targets. Restore this project with the same RuntimeIdentifier before publishing." />
</Target>
</Project>