forked from dotnet/maui
/
Microsoft.Maui.Templates.csproj
112 lines (96 loc) · 4.96 KB
/
Microsoft.Maui.Templates.csproj
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<Project Sdk="Microsoft.NET.Sdk">
<UsingTask TaskName="ReplaceFileText" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<InputFilename ParameterType="System.String" Required="true" />
<OutputFilename ParameterType="System.String" Required="true" />
<MatchExpression ParameterType="System.String[]" Required="true" />
<ReplacementText ParameterType="System.String[]" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
if (MatchExpression.Length != ReplacementText.Length) throw new Exception("The number of MatchExpression items must match the number of ReplacementText items.");
for (int i = 0; i < MatchExpression.Length; i++)
{
File.WriteAllText(
OutputFilename,
Regex.Replace(File.ReadAllText(InputFilename), MatchExpression[i], ReplacementText[i])
);
//Console.WriteLine($"Processing file '{InputFilename}' --> '{OutputFilename}', replacing match '{MatchExpression[i]}' with text '{ReplacementText[i]}'.");
}
]]>
</Code>
</Task>
</UsingTask>
<PropertyGroup>
<TargetFramework>$(_MauiDotNetTfm)</TargetFramework>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<IncludeContentInPack>true</IncludeContentInPack>
<IncludeBuildOutput>false</IncludeBuildOutput>
<LocalizeTemplates>true</LocalizeTemplates>
<IncludeSymbols>false</IncludeSymbols>
<ContentTargetFolders>content</ContentTargetFolders>
<!-- This project has no .NET assemblies, so disable the warning for that -->
<NoWarn>$(NoWarn);NU5128</NoWarn>
</PropertyGroup>
<PropertyGroup>
<!-- NuGet package information -->
<IsPackable>true</IsPackable>
<PackageId>Microsoft.Maui.Templates.net$(_MauiDotNetVersionMajor)</PackageId>
<PackageType>Template</PackageType>
<Title>.NET MAUI Templates</Title>
<Description>.NET Multi-platform App UI (.NET MAUI) project and item templates.</Description>
</PropertyGroup>
<ItemGroup>
<TemplateJsonInput Include="templates\*\.template.config\**\*.json">
<PackageDestination>$([System.String]::Concat(%(RelativeDir), '%(Filename)%(Extension)'))</PackageDestination>
<IntermediateLocation>$(IntermediateOutputPath)$([System.String]::Concat(%(RelativeDir), '%(Filename)%(Extension)'))</IntermediateLocation>
</TemplateJsonInput>
<Content Include="templates\**\*" Exclude="templates\**\bin\**;templates\**\obj\**;@(TemplateJsonInput)" />
<Compile Remove="**\*" />
</ItemGroup>
<PropertyGroup>
<BeforePack>_UpdateTemplateVersions</BeforePack>
</PropertyGroup>
<Target Name="_UpdateTemplateVersions" DependsOnTargets="SetVersions;LocalizeTemplatesAfterBuild"
Inputs="@(TemplateJsonInput)"
Outputs="%(TemplateJsonInput.IntermediateLocation)">
<!-- Copy files to their output name -->
<Copy
SourceFiles="%(TemplateJsonInput.Fullpath)"
DestinationFiles="%(TemplateJsonInput.IntermediateLocation)" />
<!-- Copy the templatestrings.en.json to templatestrings.json -->
<Copy
SourceFiles="%(TemplateJsonInput.Fullpath)"
DestinationFiles="%(TemplateJsonInput.RelativeDir)templatestrings.json"
Condition="'%(TemplateJsonInput.Filename)%(TemplateJsonInput.Extension)' == 'templatestrings.en.json'" />
<!-- Replace .NET TFM versions -->
<ReplaceFileText
InputFilename="%(TemplateJsonInput.IntermediateLocation)"
OutputFilename="%(TemplateJsonInput.IntermediateLocation)"
MatchExpression="DOTNET_TFM_VALUE;DOTNET_TFM_VERSION_VALUE;DOTNET_TFM_VERSION_MAJOR_VALUE;MS_EXT_LOG_DEBUG_VERSION_VALUE"
ReplacementText="$(_MauiDotNetTfm);$(_MauiDotNetVersion);$(_MauiDotNetVersionMajor)000;$(MicrosoftExtensionsLoggingDebugVersion)" />
<ItemGroup>
<FileWrites Include="%(TemplateJsonInput.IntermediateLocation)" />
<Content Include="%(TemplateJsonInput.IntermediateLocation)" PackagePath="$(ContentTargetFolders)\%(TemplateJsonInput.PackageDestination)" Pack="true" />
</ItemGroup>
</Target>
<Target Name="_CopyToTemplatePacks" AfterTargets="Pack">
<ItemGroup>
<_PackagesToCopy Include="$(PackageOutputPath)/$(PackageId).*.nupkg" />
</ItemGroup>
<Copy
SourceFiles="@(_PackagesToCopy)"
DestinationFolder="$(DotNetTemplatePacksDirectory)"
SkipUnchangedFiles="true"
/>
</Target>
<ItemGroup Condition=" '$(OS)' == 'Windows_NT' ">
<PackageReference Include="Microsoft.TemplateEngine.Tasks" Version="$(MicrosoftTemplateEngineTasksVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
</ItemGroup>
<!-- this target will get replaced by the nuget -->
<Target Name="LocalizeTemplatesAfterBuild" />
</Project>