-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStructId.targets
More file actions
76 lines (66 loc) · 4.35 KB
/
Copy pathStructId.targets
File metadata and controls
76 lines (66 loc) · 4.35 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
<Project>
<ItemGroup>
<!-- This is safe to do even if we're in a transitive targets file, since content files providing
these items won't exist in a transitive project. See https://github.com/NuGet/Home/issues/7420 -->
<Compile Update="@(Compile)">
<Visible Condition="'%(NuGetItemType)' == 'Compile' and '%(NuGetPackageId)' == 'StructId'">false</Visible>
<Link Condition="'%(NuGetItemType)' == 'Compile' and '%(NuGetPackageId)' == 'StructId'">StructId\%(Filename)%(Extension)</Link>
</Compile>
<!-- Templates should always be added transitively since they are all file-local and their
syntax tree is required in the compilation for them to apply properly -->
<StructId Include="$(MSBuildThisFileDirectory)Templates\*.cs"
Link="StructId\Templates\%(Filename)%(Extension)"
Visible="false"/>
</ItemGroup>
<!--
Copies SKILL.md from this package to .agents/skills/structid/ in the consuming repo root.
Uses InitializeSourceControlInformation (SourceLink) to locate the repo root.
Falls back to SolutionDir if the git root cannot be determined.
Falls back to the directory containing the nearest AGENTS.md file found above the project file.
Silently skips if the base directory cannot be determined.
Opt-out: set <StructIdSkill>false</StructIdSkill> in your project or Directory.Build.props.
-->
<Target Name="CopyStructIdSkill"
BeforeTargets="PrepareForBuild"
DependsOnTargets="InitializeSourceControlInformation"
Condition="'$(StructIdSkill)' != 'false'">
<ItemGroup>
<_StructIdSkillSourceRoot Include="@(SourceRoot -> WithMetadataValue('SourceControl', 'git'))" />
</ItemGroup>
<PropertyGroup>
<_StructIdSkillRepoRoot>@(_StructIdSkillSourceRoot)</_StructIdSkillRepoRoot>
<_StructIdSkillRepoRoot Condition="'$(_StructIdSkillRepoRoot)' == '' and '$(SolutionDir)' != '' and '$(SolutionDir)' != '*Undefined*'">$(SolutionDir)</_StructIdSkillRepoRoot>
<_StructIdSkillAgentsMd Condition="'$(_StructIdSkillRepoRoot)' == ''">$([MSBuild]::GetPathOfFileAbove('AGENTS.md', '$(MSBuildProjectDirectory)'))</_StructIdSkillAgentsMd>
<_StructIdSkillRepoRoot Condition="'$(_StructIdSkillRepoRoot)' == '' and '$(_StructIdSkillAgentsMd)' != ''">$([System.IO.Path]::GetDirectoryName('$(_StructIdSkillAgentsMd)'))\</_StructIdSkillRepoRoot>
</PropertyGroup>
<MakeDir Directories="$(_StructIdSkillRepoRoot).agents\skills\structid"
Condition="'$(_StructIdSkillRepoRoot)' != '' and Exists('$(MSBuildThisFileDirectory)..\skills\structid\SKILL.md')"
ContinueOnError="true" />
<Copy SourceFiles="$(MSBuildThisFileDirectory)..\skills\structid\SKILL.md"
DestinationFiles="$(_StructIdSkillRepoRoot).agents\skills\structid\SKILL.md"
SkipUnchangedFiles="true"
Condition="'$(_StructIdSkillRepoRoot)' != '' and Exists('$(MSBuildThisFileDirectory)..\skills\structid\SKILL.md')"
ContinueOnError="true" />
</Target>
<Target Name="AddStructId" DependsOnTargets="ResolveLockFileReferences" BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun">
<!-- Feature detection -->
<PropertyGroup>
<UseDapper>false</UseDapper>
<UseDapper Condition="'@(Reference -> WithMetadataValue('NuGetPackageId', 'Dapper'))' != ''">true</UseDapper>
<UseEntityFramework>false</UseEntityFramework>
<UseEntityFramework Condition="'@(Reference -> WithMetadataValue('NuGetPackageId', 'Microsoft.EntityFrameworkCore'))' != ''">true</UseEntityFramework>
<UseUlid>false</UseUlid>
<UseUlid Condition="'@(Reference -> WithMetadataValue('NuGetPackageId', 'Ulid'))' != ''">true</UseUlid>
</PropertyGroup>
<ItemGroup>
<FeatureTemplatesToRemove Include="@(StructId -> WithMetadataValue('Filename', 'DapperTypeHandler'))" Condition="!$(UseDapper)" />
<FeatureTemplatesToRemove Include="@(StructId -> WithMetadataValue('Filename', 'EntityFrameworkValueConverter'))" Condition="!$(UseEntityFramework)" />
<FeatureTemplatesToRemove Include="@(StructId -> WithMetadataValue('Filename', 'NewableUlid'))" Condition="!$(UseUlid)" />
<StructId Remove="@(FeatureTemplatesToRemove)" />
</ItemGroup>
<!-- Add final template items to project -->
<ItemGroup>
<Compile Include="%(StructId.FullPath)" NuGetPackageId="StructId" />
</ItemGroup>
</Target>
</Project>