Repository navigation
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
60 lines (53 loc) · 4.27 KB
/
Copy pathDirectory.Build.targets
File metadata and controls
60 lines (53 loc) · 4.27 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
<!--
This file allows overriding of properties for all projects in the directory.
See https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-by-directory?view=vs-2022#directorybuildprops-and-directorybuildtargets
-->
<Project>
<PropertyGroup>
<_BuildProjBaseIntermediateOutputPath>$(MSBuildThisFileDirectory)build/obj/</_BuildProjBaseIntermediateOutputPath>
<_DotnetToolManifestFile>$(MSBuildThisFileDirectory).config/dotnet-tools.json</_DotnetToolManifestFile>
<_DotnetToolRestoreOutputFile>$(_BuildProjBaseIntermediateOutputPath)/dotnet-tool-restore-$(NETCoreSdkVersion)-$(OS)</_DotnetToolRestoreOutputFile>
<_DotnetFantomasOutputFile>$(BaseIntermediateOutputPath)dotnet-fantomas-msbuild-$(NETCoreSdkVersion)-$(OS)</_DotnetFantomasOutputFile>
</PropertyGroup>
<!-- Make sure that dotnet tools are restored before restoring any project -->
<Target Name="ToolRestore" BeforeTargets="Restore;CollectPackageReferences" Inputs="$(_DotnetToolManifestFile)" Outputs="$(_DotnetToolRestoreOutputFile)">
<Exec Command="dotnet tool restore" WorkingDirectory="$(MSBuildThisFileDirectory)" StandardOutputImportance="High" StandardErrorImportance="High" />
<MakeDir Directories="$(_BuildProjBaseIntermediateOutputPath)"/>
<Touch Files="$(_DotnetToolRestoreOutputFile)" AlwaysCreate="True" ForceTouch="True" />
</Target>
<!--
Links .claude/skills to .github/skills so Claude Code discovers the repository skills.
Git cannot store a Windows junction, and a committed symlink only checks out as a real link
with core.symlinks=true plus Developer Mode, so the link is created locally and git-ignored.
A junction needs no elevation on Windows; elsewhere a relative symlink is used.
When several projects race to create it, the losers only get a warning.
-->
<PropertyGroup>
<_ClaudeSkillsLink>$(MSBuildThisFileDirectory).claude/skills</_ClaudeSkillsLink>
<_ClaudeSkillsTarget>$(MSBuildThisFileDirectory).github/skills</_ClaudeSkillsTarget>
</PropertyGroup>
<Target Name="ClaudeSkillsLink"
BeforeTargets="ResolveNuGetPackageAssets;BeforeCompile"
Condition="( '$(BuildingProject)' == 'false' OR '$(DesignTimeBuild)' == 'true' ) AND !Exists('$(_ClaudeSkillsLink)') AND Exists('$(_ClaudeSkillsTarget)')">
<Message Text="Linking .claude/skills to .github/skills..." Importance="High" />
<MakeDir Directories="$(MSBuildThisFileDirectory).claude" />
<Exec Condition="'$(OS)' == 'Windows_NT'" Command="mklink /J "$([System.IO.Path]::GetFullPath('$(_ClaudeSkillsLink)'))" "$([System.IO.Path]::GetFullPath('$(_ClaudeSkillsTarget)'))"" ContinueOnError="WarnAndContinue" />
<Exec Condition="'$(OS)' != 'Windows_NT'" Command="ln -s ../.github/skills "$(_ClaudeSkillsLink)"" ContinueOnError="WarnAndContinue" />
</Target>
<!--
Make sure that files are formatted before building.
A multi-targeted project builds its target frameworks in parallel, so formatting in each of them ran Fantomas
concurrently on the same files ("being used by another process") and raced on the marker file (MSB3371).
Every build of a project therefore delegates to one dedicated instance of it without a target framework.
MSBuild runs a target once per project instance, so a project is formatted once per build,
whether it is built from the solution, as a project reference or on its own.
-->
<Target Name="FormatBeforeBuild" Condition=" '$(MSBuildProjectExtension)' == '.fsproj' AND '$(DesignTimeBuild)' != 'true' " BeforeTargets="BeforeBuild">
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Format" Properties="_FantomasFormatInstance=true" RemoveProperties="TargetFramework;RuntimeIdentifier" />
</Target>
<Target Name="Format" Inputs="@(Compile)" Outputs="$(_DotnetFantomasOutputFile)">
<Exec Command="dotnet fantomas $(MSBuildProjectDirectory)" StandardOutputImportance="High" StandardErrorImportance="High" WorkingDirectory="$(MSBuildThisFileDirectory)" ContinueOnError="WarnAndContinue" />
<Exec Command="dotnet fantomas $(MSBuildProjectDirectory)" StandardOutputImportance="High" StandardErrorImportance="High" WorkingDirectory="$(MSBuildThisFileDirectory)" ContinueOnError="WarnAndContinue" />
<Touch Files="$(_DotnetFantomasOutputFile)" AlwaysCreate="True" ForceTouch="True" />
</Target>
</Project>