-
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathDirectory.Build.props
More file actions
163 lines (153 loc) · 9.29 KB
/
Directory.Build.props
File metadata and controls
163 lines (153 loc) · 9.29 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<Project>
<PropertyGroup>
<!-- Disable Visual Studio's project up to date checking so that a build with build.ps1 will not result in a re-build -->
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
<!--
MSB3277/MSB3243: Assembly version conflicts are BUILD ERRORS.
CPM + transitive pinning (Directory.Packages.props) prevents version drift.
If a conflict appears, add the package to Directory.Packages.props as a
transitive pin or bump the existing pin, instead of suppressing the warning.
-->
<MSBuildWarningsAsErrors>$(MSBuildWarningsAsErrors);MSB3277;MSB3243</MSBuildWarningsAsErrors>
<!--
MSB3568: Duplicate resource name in .resx files
Old WinForms designer files have duplicate entries due to localization/designer quirks.
MSBuild ignores the duplicates (uses first), so this is harmless noise.
-->
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);MSB3568</MSBuildWarningsAsMessages>
<!--
MSB3026: Copy task retry warnings (transient file locks)
Demote to message so first-attempt copy retries don't spam warnings; final failure still errors via MSB3027.
-->
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);MSB3026</MSBuildWarningsAsMessages>
<!--
Global TreatWarningsAsErrors Policy:
All C# projects treat warnings as errors to maintain code quality.
Projects should NOT override this. If a specific warning is unavoidable,
add it to NoWarn above with a comment explaining why.
Note: Some informational messages still appear during build (demoted from warnings):
- LNK4099: Missing PDB for pre-built libraries (graphite2.lib)
- "Missing Palaso native files": Optional Windows-only interop DLLs (Keyman, irrKlang)
- "xsltc.exe not found": Optional .NET Framework SDK tool
These do NOT fail the build and are informational only.
-->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- Default all managed projects to x64 unless explicitly overridden -->
<PlatformTarget Condition="'$(PlatformTarget)' == ''">x64</PlatformTarget>
<Platforms Condition="'$(Platforms)' == ''">x64</Platforms>
<!--
ReSharper test/build controller can invoke SDK-style net48 projects with RuntimeIdentifier=win-x64.
If restore only produced net48 (no RID graph), ResolvePackageAssets fails with NETSDK1005/NETSDK1047.
Restore win-x64 runtime targets by default so both plain net48 and net48/win-x64 builds succeed.
-->
<RuntimeIdentifiers Condition="'$(MSBuildProjectExtension)' == '.csproj' and '$(RuntimeIdentifiers)' == ''">win-x64</RuntimeIdentifiers>
<!-- Force 64-bit MSBuild host to avoid crashes loading 64-bit native DLLs in build tasks -->
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<!-- Disable determinism to allow wildcard versions in CommonAssemblyInfo.cs -->
<Deterministic>false</Deterministic>
<!-- Required for projects with non-string resources (images, icons, etc.) in .NET SDK style projects -->
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
<!--
C# language version policy:
- Default .NET Framework TFMs to C# 8 so we can use modern syntax safely.
- Keep nullable reference types disabled for now to avoid repo-wide warning churn under TreatWarningsAsErrors.
Projects can opt in explicitly when ready.
-->
<LangVersion Condition="'$(MSBuildProjectExtension)' == '.csproj' AND '$(LangVersion)' == ''">8.0</LangVersion>
<Nullable Condition="'$(MSBuildProjectExtension)' == '.csproj' AND '$(Nullable)' == ''">disable</Nullable>
</PropertyGroup>
<!-- Required for non-string resources (images, icons) in .NET Framework SDK-style projects -->
<!-- System.Resources.Extensions 9.0.0 requires net462 or higher - use explicit version check -->
<!--
Global PackageReferences for application code have moved to Src/Directory.Build.props
to scope them to Src/ projects only (Build/Src projects opt out of CPM).
Version declarations are centrally managed in Directory.Packages.props.
-->
<PropertyGroup Label="AssemblyInfo Policy">
<!-- TODO: Fix the location of the Include and remove the CommonAssemblyInfo from all .csproj files
CommonAssemblyInfoTemplate Policy:
All managed projects must link Src/CommonAssemblyInfo.cs to ensure consistent versioning and metadata.
When linking the template, disable SDK auto-generation to prevent CS0579 duplicate attribute errors.
Usage:
<Compile Include="..\..\CommonAssemblyInfo.cs" Link="Properties\CommonAssemblyInfo.cs" />
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
-->
</PropertyGroup>
<PropertyGroup Label="Shared Paths for Traversal Build">
<!-- Root directory paths -->
<FwRoot>$(MSBuildThisFileDirectory)</FwRoot>
<FwDistFiles>$(FwRoot)DistFiles\</FwDistFiles>
<FwOutput>$(FwRoot)Output\</FwOutput>
<FwOutputBase>$(FwOutput)$(Configuration)\</FwOutputBase>
<FwObj>$(FwRoot)Obj\</FwObj>
<!--
Unified Intermediate Output Policy:
All SDK-style projects use the root Obj/ folder (gitignored) instead of per-project obj/ folders.
Configuration is included in the path to prevent stale artifacts when switching Debug/Release.
- Host builds: $(FwRoot)Obj/$(Configuration)/<ProjectName>/
Note: WPF markup compilation creates temp projects like "ProjectName_abc123_wpftmp".
We detect this via the _wpftmp suffix and use the original project's intermediate directory
by checking if MSBuildProjectName contains '_wpftmp' and using the parent directory's name instead.
-->
<_IsWpfTempProject>false</_IsWpfTempProject>
<_IsWpfTempProject Condition="$(MSBuildProjectName.Contains('_wpftmp'))">true</_IsWpfTempProject>
<!-- For WPF temp projects, derive the real name from the project file path's directory name -->
<_RealProjectName Condition="'$(_IsWpfTempProject)' != 'true'">$(MSBuildProjectName)</_RealProjectName>
<_RealProjectName Condition="'$(_IsWpfTempProject)' == 'true'">$([System.IO.Path]::GetFileName($([System.IO.Path]::GetDirectoryName($(MSBuildProjectFullPath)))))</_RealProjectName>
<BaseIntermediateOutputPath>$(FwRoot)Obj\$(Configuration)\$(_RealProjectName)\</BaseIntermediateOutputPath>
<MSBuildProjectExtensionsPath>$(BaseIntermediateOutputPath)</MSBuildProjectExtensionsPath>
<RestoreOutputPath>$(BaseIntermediateOutputPath)</RestoreOutputPath>
<!--
NuGet Package Location Policy: Use nuget.config globalPackagesFolder (packages/)
Do NOT set RestorePackagesPath here - it conflicts with the NUGET_PACKAGES env var.
The env var takes precedence.
See nuget.config for full documentation.
-->
<!-- LCM artifacts directory -->
<DownloadsDir Condition="'$(DownloadsDir)'==''">$(FwRoot)Downloads</DownloadsDir>
<LcmArtifactsDir Condition="'$(LcmArtifactsDir)'==''">$(DownloadsDir)</LcmArtifactsDir>
<!-- Enable binding redirects for all projects -->
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
<ItemGroup>
<Compile Remove="**/*.template.cs" />
</ItemGroup>
<PropertyGroup Condition="'$(UseWPF)' == 'true'">
<XamlDebuggingInformation Condition="'$(Configuration)' == 'Release'">false</XamlDebuggingInformation>
<UseRidGraph>true</UseRidGraph>
</PropertyGroup>
<!-- Modern test infrastructure for all test projects -->
<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
<!-- For .NET Framework projects, ensure NuGet package assemblies are copied to output directory -->
<!-- This is required for dotnet test to discover test adapters -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!--
Test Code Warning Suppressions:
Legacy test code often has unused variables from copy-paste or stubbed-out tests.
Rather than fix every instance in ~40 test projects, suppress these common warnings:
- CS0168: Variable is declared but never used (often in catch blocks)
- CS0169: Field is never used (test fixtures with unused mock fields)
- CS0219: Variable is assigned but its value is never used
- CS0414: Field is assigned but its value is never used
- CS0649: Field is never assigned to (mock fields set via reflection/DI)
Use WarningsNotAsErrors instead of NoWarn because individual project files
override $(NoWarn) directly. WarningsNotAsErrors allows the warning to be emitted
but prevents it from failing the build when TreatWarningsAsErrors=true.
-->
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS0168;CS0169;CS0219;CS0414;CS0649;168;169;219;414;649</WarningsNotAsErrors>
</PropertyGroup>
<!--
Shared test assembly attributes: SLDR offline mode, ICU initialization, registry redirect, etc.
This is applied to all test projects that don't already include the file.
The file sets up proper test initialization for FieldWorks components.
Use AssemblyInfoForTests.cs for UI test projects (most tests).
Projects can override by setting <UseUiIndependentTestAssemblyInfo>true</UseUiIndependentTestAssemblyInfo>
-->
<ItemGroup Condition="'$(IsTestProject)' == 'true' AND '$(UseUiIndependentTestAssemblyInfo)' != 'true'">
<Compile Include="$(FwRoot)Src\AssemblyInfoForTests.cs" Link="Properties\AssemblyInfoForTests.cs" />
</ItemGroup>
<ItemGroup Condition="'$(IsTestProject)' == 'true' AND '$(UseUiIndependentTestAssemblyInfo)' == 'true'">
<Compile Include="$(FwRoot)Src\AssemblyInfoForUiIndependentTests.cs" Link="Properties\AssemblyInfoForUiIndependentTests.cs" />
</ItemGroup>
</Project>