Skip to content

Commit 458f313

Browse files
committed
Move MSBuild logic across targets
- Move Package properties from props to targets Include only when the project is packable. - Move the T4 MSBuild logic to a new file and generalize them so any project can use it just by including the targets file.
1 parent 1693e92 commit 458f313

File tree

4 files changed

+39
-32
lines changed

4 files changed

+39
-32
lines changed

CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,6 @@
4141
</When>
4242
</Choose>
4343

44-
<!-- T4 service used by the Guard APIs -->
45-
<ItemGroup>
46-
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
47-
</ItemGroup>
48-
49-
<ItemGroup>
50-
<None Update="Generated\*.tt">
51-
<Generator>TextTemplatingFileGenerator</Generator>
52-
<LastGenOutput>%(Filename).g.cs</LastGenOutput>
53-
</None>
54-
</ItemGroup>
55-
56-
<ItemGroup>
57-
<Compile Update="Generated\*.g.cs">
58-
<DesignTime>True</DesignTime>
59-
<AutoGen>True</AutoGen>
60-
<DependentUpon>$([System.IO.Path]::ChangeExtension(%(Filename), '.tt'))</DependentUpon>
61-
</Compile>
62-
</ItemGroup>
44+
<Import Project="$(BuildToolsDirectory)Community.Toolkit.TextTemplates.targets" />
6345

6446
</Project>

build/Community.Toolkit.Common.props

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
<Project>
22

3-
<PropertyGroup>
4-
<Company>Microsoft</Company>
5-
<Authors>Microsoft</Authors>
6-
<Product>.NET Community Toolkit</Product>
7-
<CommonTags>.NET;Community;Toolkit;dotnet</CommonTags>
8-
<PackageLicenseExpression>MIT</PackageLicenseExpression>
9-
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
10-
<Copyright>(c) .NET Foundation and Contributors. All rights reserved.</Copyright>
11-
<PackageProjectUrl>https://github.com/CommunityToolkit/dotnet</PackageProjectUrl>
12-
<PackageReleaseNotes>https://github.com/CommunityToolkit/dotnet/releases</PackageReleaseNotes>
13-
<PackageIcon>Icon.png</PackageIcon>
14-
</PropertyGroup>
15-
163
<PropertyGroup>
174
<Nullable>Enable</Nullable>
185
<LangVersion>10.0</LangVersion>

build/Community.Toolkit.Common.targets

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
<Project>
22

3+
<PropertyGroup Condition="$(IsPackable)">
4+
<Company>Microsoft</Company>
5+
<Authors>Microsoft</Authors>
6+
<Product>.NET Community Toolkit</Product>
7+
<CommonTags>.NET;Community;Toolkit;dotnet</CommonTags>
8+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
9+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
10+
<Copyright>(c) .NET Foundation and Contributors. All rights reserved.</Copyright>
11+
<PackageProjectUrl>https://github.com/CommunityToolkit/dotnet</PackageProjectUrl>
12+
<PackageReleaseNotes>https://github.com/CommunityToolkit/dotnet/releases</PackageReleaseNotes>
13+
<PackageIcon>Icon.png</PackageIcon>
14+
</PropertyGroup>
15+
316
<PropertyGroup Condition="$(IsPackable)">
417
<!-- TODO: Dynamically generate Title if one wasn't set -->
518
<Title Condition="'$(Title)' == ''">$(Product) Asset</Title>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project>
2+
3+
<!-- T4 text template service used by the Visual Studio project system -->
4+
<ItemGroup>
5+
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
6+
</ItemGroup>
7+
8+
<!-- Using T4 text templates to generate sources -->
9+
<ItemGroup>
10+
<None Update="**\*.tt">
11+
<Generator>TextTemplatingFileGenerator</Generator>
12+
<LastGenOutput>%(Filename).g.cs</LastGenOutput>
13+
</None>
14+
</ItemGroup>
15+
16+
<!-- Sources generated based on the above text templates -->
17+
<ItemGroup>
18+
<Compile Update="**\*.g.cs">
19+
<AutoGen>True</AutoGen>
20+
<DesignTime>True</DesignTime>
21+
<DependentUpon>$([System.IO.Path]::ChangeExtension(%(Filename), '.tt'))</DependentUpon>
22+
</Compile>
23+
</ItemGroup>
24+
25+
</Project>

0 commit comments

Comments
 (0)