-
Notifications
You must be signed in to change notification settings - Fork 172
/
Directory.Build.targets
90 lines (80 loc) · 3.72 KB
/
Directory.Build.targets
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
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!--
Speckle-sharp main Directory.Build.targets file
This file gets automatically imported by every project in the repo.
The import happens AFTER any information in the .csproj, which means that each project
cannot override anything in it, only modify properties that these targets consume.
It is intended to hold any common targets and events shared by all (or most) projects in the
repository.
Such as, copying a converter to the Kit folder, or cleaning up the entire monorepo.
-->
<PropertyGroup>
<!-- Determines if the project should execute the CopyToKitFolder target. Can be overriden
per-project. -->
<CopyToKitFolder Condition="'$(CopyToKitFolder)' == ''">false</CopyToKitFolder>
<!-- The name of the kit folder we want to copy into. Can be overriden per-project. -->
<KitFolder Condition="$(KitFolder) == ''">Objects</KitFolder>
</PropertyGroup>
<!--
Ensures consistent behaviour when copying files from our Objects Kit to the local Kit folder for
every supported OS.
Requires the property "CopyToKitFolder" to be set to true in the specific project.
It will copy only the target assembly, any dependencies must be copied in the project file
in a target that depends on this one to guarantee execution order..
-->
<Target
Label="Copy To Objects Kit Folder"
Name="CopyToKitFolder"
AfterTargets="PostBuildEvent"
Condition="'$(CopyToKitFolder)' == true AND '$(IsDesktopBuild)' == true">
<Message Text="Copying $(AssemblyName).dll to $(KitFolder) Kit folder" Importance="high"/>
<Exec Condition="$([MSBuild]::IsOsPlatform('Windows'))"
Command="xcopy /Y /S "$(TargetDir)$(AssemblyName).dll" "$(AppData)\Speckle\Kits\$(KitFolder)\""/>
<Exec Condition="$([MSBuild]::IsOsPlatform('OSX'))"
Command="mkdir -p $HOME'/.config/Speckle/Kits/$(KitFolder)'"/>
<Exec Condition="$([MSBuild]::IsOsPlatform('OSX'))"
Command="cp '$(TargetDir)$(AssemblyName).dll' $HOME'/.config/Speckle/Kits/$(KitFolder)/'"/>
</Target>
<!--
Reports the current build version number in the build logs.
-->
<Target Name="ReportBuildVersion" BeforeTargets="BeforeBuild">
<Message
Text="Building $(MSBuildProjectName).csproj with version $(Version) and file version $(FileVersion)"
Importance="high"/>
</Target>
<!--
Deep clean target will remove all bin/ and obj/ folders from the monorepo. Can be invoked by
cleaning any project
while passing the DeepClean parameter as "true".
"dotnet clean /p:DeepClean=true"
-->
<Target Name="DeepClean">
<Message Text="Deep clean of $(MSBuildProjectName).csproj" Importance="high"/>
<RemoveDir Directories="$(BaseIntermediateOutputPath)"/>
<RemoveDir Directories="$(BaseOutputPath)"/>
</Target>
<!--
Supress many analysers for test projects, since we may want to test code that would otherwise generate warnings
-->
<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
<AnalysisMode>Recommended</AnalysisMode>
<NoWarn>
$(NoWarn);
<!-- Things we need to test -->
CS0618;CA1034;CA2201;CA1051;CA1040;CA1724;
IDE0044;IDE0130;CA1508;
<!-- Analysers that provide no tangeable value to a test project -->
CA5394;CA2007;CA1852;CA1819;CA1711;CA1063;CA1816;CA2234;CS8618;
</NoWarn>
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
</PropertyGroup>
<Target
Label="Warn user of test analyser settings"
Name="TestProjectAnalysersWarnings"
AfterTargets="PostBuildEvent"
Condition="'$(IsTestProject)' == 'true'">
<Message Text="Running project with Test project analysers configuration (many analysers supressed)" Importance="high"/>
</Target>
</Project>