Repository navigation
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
65 lines (61 loc) · 3.1 KB
/
Copy pathDirectory.Build.targets
File metadata and controls
65 lines (61 loc) · 3.1 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
<Project>
<!-- Auto-configure MTP test runner for test projects -->
<PropertyGroup Condition="$(MSBuildProjectName.EndsWith('.Tests'))">
<OutputType>Exe</OutputType>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
<TestingPlatformExitCodeOnZeroTests>0</TestingPlatformExitCodeOnZeroTests>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<!-- Auto-add xUnit using for test projects -->
<ItemGroup Condition="$(MSBuildProjectName.EndsWith('.Tests'))">
<Using Include="Xunit" />
</ItemGroup>
<!-- Global usings by project kind (the root Directory.Build.props holds the shared BCL ones):
- Xunit: every test project uses [Fact], [Theory] and Assert.
- TruthWeaver.Testing.Assertions and TruthWeaver.Testing.Fakes: only for a test project that references it
(FakePredicates, DecisionAssertions). The other sub-namespaces (Harness, Fuzzing, RuleTests) take a per-file using.
Detected from the ProjectReference items, so a test project with no
reference never gets a namespace it cannot resolve.
- NSubstitute is deliberately not global: 7 of about 230 test files use it, so a per-file using stays.
- TruthWeaver.Abstractions for src projects is set in src/Directory.Build.props. -->
<ItemGroup Condition="$(MSBuildProjectName.EndsWith('.Tests')) and '@(ProjectReference->AnyHaveMetadataValue('Filename', 'TruthWeaver.Testing'))' == 'true'">
<Using Include="TruthWeaver.Testing.Assertions" />
<Using Include="TruthWeaver.Testing.Fakes" />
</ItemGroup>
<!-- Auto-configure architecture test projects -->
<PropertyGroup Condition="$(MSBuildProjectName.EndsWith('.Architecture.Tests'))">
<OutputType>Exe</OutputType>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
<TestingPlatformExitCodeOnZeroTests>0</TestingPlatformExitCodeOnZeroTests>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<!--
Installs the Git hooks (Husky.Net, .husky/task-runner.json) the first time a developer restores the
solution, so a fresh clone needs no manual step. Skipped in CI (the CI variable), outside a Git work
tree, when HUSKY=0, and for every project except one so it runs once. A failure never fails the build.
-->
<Target
Name="InstallGitHooks"
BeforeTargets="Restore;CollectPackageReferences"
Condition="'$(MSBuildProjectName)' == 'TruthWeaver' and '$(CI)' != 'true' and '$(HUSKY)' != '0' and Exists('$(MSBuildThisFileDirectory).git')"
>
<Exec
Command="dotnet tool restore"
WorkingDirectory="$(MSBuildThisFileDirectory)"
StandardOutputImportance="Low"
StandardErrorImportance="High"
IgnoreExitCode="true"
/>
<Exec
Command="dotnet husky install"
WorkingDirectory="$(MSBuildThisFileDirectory)"
StandardOutputImportance="Low"
StandardErrorImportance="High"
IgnoreExitCode="true"
/>
</Target>
</Project>