Repository navigation
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
81 lines (72 loc) · 4.79 KB
/
Copy pathDirectory.Build.targets
File metadata and controls
81 lines (72 loc) · 4.79 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
<Project>
<!-- CS1591 (task 177): missing XML comment on publicly visible members.
Packable projects keep CS1591 as a warning (TreatWarningsAsErrors → fail).
Everyone else adds 1591 to NoWarn. Must live here: root Directory.Build.props runs
before child props/csproj set IsPackable=true. Both modes are documented next to
the NoWarn list in Directory.Build.props. -->
<PropertyGroup Label="PackableXmlDocs">
<NoWarn Condition="'$(IsPackable)' != 'true'">$(NoWarn);1591</NoWarn>
</PropertyGroup>
<!--
Assembly marker generation.
Every C# product/platform assembly gets a generated public interface IAssemblyMarker in
$(AssemblyMarkerNamespace) (not RootNamespace alone — container-apps share
RootNamespace=TimeWarp.Architecture while markers live in layer sub-namespaces).
An interface (not a sealed class) works as a generic type argument
(AddValidatorsFromAssemblyContaining<IAssemblyMarker>) and cannot be instantiated.
Do not hand-author assembly-marker.cs.
Maps live in source/{container-apps,foundation,analyzers,libraries}/Directory.Build.props.
Opt out: TwGenerateAssemblyMarker=false.
Template: this file must ship in the template package (see timewarp-architecture-template.csproj).
Two targets: write is Inputs/Outputs-skipped when up-to-date; include always runs so
CoreCompile still sees AssemblyMarker.g.cs after an incremental rebuild of other sources.
-->
<PropertyGroup Label="AssemblyMarker defaults">
<TwGenerateAssemblyMarker Condition="'$(TwGenerateAssemblyMarker)' == '' and '$(Language)' == 'C#'">true</TwGenerateAssemblyMarker>
<TwGenerateAssemblyMarker Condition="'$(TwGenerateAssemblyMarker)' == ''">false</TwGenerateAssemblyMarker>
<!-- Fallback only when a map did not set AssemblyMarkerNamespace. Hyphenated roots (project-name
defaults like foundation-domain) are not valid C# namespaces — the target condition skips them. -->
<AssemblyMarkerNamespace Condition="'$(AssemblyMarkerNamespace)' == ''">$(RootNamespace)</AssemblyMarkerNamespace>
<TwAssemblyMarkerFile>$(IntermediateOutputPath)AssemblyMarker.g.cs</TwAssemblyMarkerFile>
<_TwGenerateAssemblyMarkerEnabled Condition="'$(TwGenerateAssemblyMarker)' == 'true'
and '$(Language)' == 'C#'
and '$(AssemblyMarkerNamespace)' != ''
and !$(AssemblyMarkerNamespace.Contains('-'))
and '$(MSBuildProjectExtension)' == '.csproj'">true</_TwGenerateAssemblyMarkerEnabled>
</PropertyGroup>
<Target Name="GenerateAssemblyMarker"
BeforeTargets="BeforeCompile;CoreCompile"
Condition="'$(_TwGenerateAssemblyMarkerEnabled)' == 'true'"
Inputs="$(MSBuildAllProjects);$(MSBuildThisFileFullPath)"
Outputs="$(TwAssemblyMarkerFile)">
<MakeDir Directories="$(IntermediateOutputPath)" Condition="!Exists('$(IntermediateOutputPath)')" />
<!-- Empty marker interface is intentional (assembly identity for typeof / scanning). -->
<ItemGroup>
<!-- Semicolons must be %3b — bare ';' is the MSBuild item separator and would drop them. -->
<_TwAssemblyMarkerLines Include="// <auto-generated />" />
<_TwAssemblyMarkerLines Include="// Generated by GenerateAssemblyMarker (Directory.Build.targets). Do not edit." />
<_TwAssemblyMarkerLines Include="#pragma warning disable CA1040 // Empty marker interface is intentional" />
<_TwAssemblyMarkerLines Include="namespace $(AssemblyMarkerNamespace)%3b" />
<_TwAssemblyMarkerLines Include="/// <summary>" />
<_TwAssemblyMarkerLines Include="/// Marker type identifying this assembly for scanning (for example AddValidatorsFromAssemblyContaining)." />
<_TwAssemblyMarkerLines Include="/// </summary>" />
<_TwAssemblyMarkerLines Include="public interface IAssemblyMarker%3b" />
<_TwAssemblyMarkerLines Include="#pragma warning restore CA1040" />
</ItemGroup>
<WriteLinesToFile File="$(TwAssemblyMarkerFile)"
Lines="@(_TwAssemblyMarkerLines)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
</Target>
<!-- Always include the generated file when generation is enabled so Inputs/Outputs skip on
GenerateAssemblyMarker cannot drop Compile from CoreCompile on later incremental builds. -->
<Target Name="IncludeGeneratedAssemblyMarker"
BeforeTargets="BeforeCompile;CoreCompile"
DependsOnTargets="GenerateAssemblyMarker"
Condition="'$(_TwGenerateAssemblyMarkerEnabled)' == 'true'">
<ItemGroup>
<Compile Include="$(TwAssemblyMarkerFile)" Condition="Exists('$(TwAssemblyMarkerFile)')" Visible="false" />
<FileWrites Include="$(TwAssemblyMarkerFile)" Condition="Exists('$(TwAssemblyMarkerFile)')" />
</ItemGroup>
</Target>
</Project>