|
1 | 1 | <Project Sdk="Microsoft.NET.Sdk.Web"> |
| 2 | + <!-- Keep the SmtpTemplates React-Email source tree out of the SDK's default |
| 3 | + Compile/Content/None globs so package.json, tsconfig.json, *.tsx, etc. |
| 4 | + don't get swept into the build or published. --> |
| 5 | + <PropertyGroup> |
| 6 | + <DefaultItemExcludes>$(DefaultItemExcludes);SmtpTemplates\**</DefaultItemExcludes> |
| 7 | + <SmtpTemplatesDir>$(MSBuildProjectDirectory)\SmtpTemplates</SmtpTemplatesDir> |
| 8 | + </PropertyGroup> |
| 9 | + |
2 | 10 | <ItemGroup> |
3 | 11 | <ProjectReference Include="..\Common\Common.csproj" /> |
4 | 12 | </ItemGroup> |
|
8 | 16 | <!-- Expose API internals to IntegrationTest project --> |
9 | 17 | <InternalsVisibleTo Include="$(AssemblyName).Tests.Integration" /> |
10 | 18 | </ItemGroup> |
11 | | - |
| 19 | + |
12 | 20 | <!-- NuGet packages --> |
13 | 21 | <ItemGroup> |
14 | 22 | <PackageReference Include="AspNet.Security.OAuth.Discord" /> |
|
20 | 28 |
|
21 | 29 | <!-- Files to copy --> |
22 | 30 | <ItemGroup> |
23 | | - <!-- Copy all Liquid templates (recursively) to build and publish outputs --> |
24 | | - <None Update="SmtpTemplates\**\*.liquid"> |
25 | | - <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
26 | | - </None> |
27 | | - |
28 | 31 | <!-- Dev cert included on publish --> |
29 | 32 | <None Include="devcert.pfx" CopyToPublishDirectory="Always" /> |
30 | 33 | </ItemGroup> |
31 | 34 |
|
| 35 | + <!-- Show the React-Email sources in the IDE without copying them anywhere. --> |
| 36 | + <ItemGroup> |
| 37 | + <None Include="SmtpTemplates\emails\**\*.tsx" /> |
| 38 | + <None Include="SmtpTemplates\scripts\**\*.ts" /> |
| 39 | + <None Include="SmtpTemplates\package.json" /> |
| 40 | + <None Include="SmtpTemplates\pnpm-lock.yaml" /> |
| 41 | + <None Include="SmtpTemplates\tsconfig.json" /> |
| 42 | + <None Include="SmtpTemplates\README.md" /> |
| 43 | + <None Include="SmtpTemplates\.gitignore" /> |
| 44 | + </ItemGroup> |
| 45 | + |
| 46 | + <!-- React-Email template build pipeline --> |
| 47 | + |
| 48 | + <ItemGroup> |
| 49 | + <SmtpTemplateSources Include="$(SmtpTemplatesDir)\emails\**\*.tsx" /> |
| 50 | + <SmtpTemplateSources Include="$(SmtpTemplatesDir)\emails\**\*.ts" /> |
| 51 | + <SmtpTemplateSources Include="$(SmtpTemplatesDir)\scripts\**\*.ts" /> |
| 52 | + <SmtpTemplateSources Include="$(SmtpTemplatesDir)\package.json" /> |
| 53 | + <SmtpTemplateSources Include="$(SmtpTemplatesDir)\pnpm-lock.yaml" /> |
| 54 | + <SmtpTemplateSources Include="$(SmtpTemplatesDir)\tsconfig.json" /> |
| 55 | + </ItemGroup> |
| 56 | + |
| 57 | + <Target Name="InstallEmailTemplateDeps" |
| 58 | + Inputs="$(SmtpTemplatesDir)\package.json;$(SmtpTemplatesDir)\pnpm-lock.yaml" |
| 59 | + Outputs="$(SmtpTemplatesDir)\node_modules\.package-lock.json"> |
| 60 | + <Exec WorkingDirectory="$(SmtpTemplatesDir)" Command="pnpm install --frozen-lockfile" /> |
| 61 | + </Target> |
| 62 | + |
| 63 | + <Target Name="BuildEmailTemplates" |
| 64 | + DependsOnTargets="InstallEmailTemplateDeps" |
| 65 | + Inputs="@(SmtpTemplateSources)" |
| 66 | + Outputs="$(SmtpTemplatesDir)\dist\.stamp"> |
| 67 | + <Exec WorkingDirectory="$(SmtpTemplatesDir)" Command="pnpm export" /> |
| 68 | + <Touch Files="$(SmtpTemplatesDir)\dist\.stamp" AlwaysCreate="true" /> |
| 69 | + </Target> |
| 70 | + |
| 71 | + <!-- Glob the generated .liquid files into Content items so the SDK copies |
| 72 | + them to the output dir and propagates them transitively via |
| 73 | + GetCopyToOutputDirectoryItems to ProjectReference dependents. Done in a |
| 74 | + target (rather than a top-level ItemGroup) so the glob is evaluated |
| 75 | + AFTER BuildEmailTemplates has materialised dist/. Safe because |
| 76 | + DefaultItemExcludes above stops the SDK from globbing SmtpTemplates\** |
| 77 | + on its own. --> |
| 78 | + <Target Name="IncludeEmailTemplates" |
| 79 | + DependsOnTargets="BuildEmailTemplates" |
| 80 | + BeforeTargets="AssignTargetPaths;GetCopyToOutputDirectoryItems"> |
| 81 | + <ItemGroup> |
| 82 | + <!-- Stage in a private item type first so the %(Filename) batching is |
| 83 | + qualified to these items only — an unqualified %(Filename) inside a |
| 84 | + <Content> ItemGroup batches across ALL existing Content items |
| 85 | + (including appsettings*.json), producing a cartesian-product mess. --> |
| 86 | + <_EmailTemplateLiquid Include="$(SmtpTemplatesDir)\dist\*.liquid" /> |
| 87 | + <Content Include="@(_EmailTemplateLiquid)"> |
| 88 | + <Link>SmtpTemplates\%(_EmailTemplateLiquid.Filename)%(_EmailTemplateLiquid.Extension)</Link> |
| 89 | + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| 90 | + <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
| 91 | + </Content> |
| 92 | + </ItemGroup> |
| 93 | + </Target> |
| 94 | + |
| 95 | + <Target Name="CleanEmailTemplates" BeforeTargets="Clean"> |
| 96 | + <RemoveDir Directories="$(SmtpTemplatesDir)\dist" /> |
| 97 | + </Target> |
| 98 | + |
32 | 99 | <!-- Git stuff --> |
33 | 100 | <Target Name="SetHash" AfterTargets="InitializeSourceControlInformation"> |
34 | 101 | <ItemGroup> |
|
0 commit comments