Skip to content

Commit 1693e92

Browse files
committed
Simplify MSBuild logic in project files
- Add necessary guard to check for pack. - Remove redundant properties and values. - Remove and adjust quotes in property functions. - Use wildcards to generalize and reduce items declared.
1 parent ed787f9 commit 1693e92

File tree

6 files changed

+11
-67
lines changed

6 files changed

+11
-67
lines changed

CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
</When>
2525

2626
<When Condition="'$(TargetFramework)' == 'netstandard2.1'">
27-
<PropertyGroup>
28-
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
29-
</PropertyGroup>
3027

3128
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
3229
<ItemGroup>
@@ -50,44 +47,17 @@
5047
</ItemGroup>
5148

5249
<ItemGroup>
53-
<None Update="Generated\Guard.Comparable.Numeric.tt">
54-
<Generator>TextTemplatingFileGenerator</Generator>
55-
<LastGenOutput>Guard.Comparable.Numeric.g.cs</LastGenOutput>
56-
</None>
57-
<None Update="Generated\Guard.Collection.tt">
58-
<Generator>TextTemplatingFileGenerator</Generator>
59-
<LastGenOutput>Guard.Collection.g.cs</LastGenOutput>
60-
</None>
61-
<None Update="Generated\ThrowHelper.Collection.tt">
62-
<Generator>TextTemplatingFileGenerator</Generator>
63-
<LastGenOutput>ThrowHelper.Collection.g.cs</LastGenOutput>
64-
</None>
65-
<None Update="Generated\TypeInfo.ttinclude">
50+
<None Update="Generated\*.tt">
6651
<Generator>TextTemplatingFileGenerator</Generator>
67-
<LastGenOutput>TypeInfo.g.cs</LastGenOutput>
52+
<LastGenOutput>%(Filename).g.cs</LastGenOutput>
6853
</None>
6954
</ItemGroup>
7055

7156
<ItemGroup>
72-
<Compile Update="Generated\Guard.Comparable.Numeric.g.cs">
73-
<DesignTime>True</DesignTime>
74-
<AutoGen>True</AutoGen>
75-
<DependentUpon>Guard.Comparable.Numeric.tt</DependentUpon>
76-
</Compile>
77-
<Compile Update="Generated\Guard.Collection.g.cs">
78-
<DesignTime>True</DesignTime>
79-
<AutoGen>True</AutoGen>
80-
<DependentUpon>Guard.Collection.tt</DependentUpon>
81-
</Compile>
82-
<Compile Update="Generated\ThrowHelper.Collection.g.cs">
83-
<DesignTime>True</DesignTime>
84-
<AutoGen>True</AutoGen>
85-
<DependentUpon>ThrowHelper.Collection.tt</DependentUpon>
86-
</Compile>
87-
<Compile Update="Generated\TypeInfo.g.cs">
57+
<Compile Update="Generated\*.g.cs">
8858
<DesignTime>True</DesignTime>
8959
<AutoGen>True</AutoGen>
90-
<DependentUpon>TypeInfo.ttinclude</DependentUpon>
60+
<DependentUpon>$([System.IO.Path]::ChangeExtension(%(Filename), '.tt'))</DependentUpon>
9161
</Compile>
9262
</ItemGroup>
9363

CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.csproj

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,8 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<Compile Remove="EmbeddedResources\INotifyPropertyChanged.cs" />
10-
<Compile Remove="EmbeddedResources\NotNullAttribute.cs" />
11-
<Compile Remove="EmbeddedResources\NotNullIfNotNullAttribute.cs" />
12-
<Compile Remove="EmbeddedResources\ObservableObject.cs" />
13-
<Compile Remove="EmbeddedResources\ObservableRecipient.cs" />
14-
</ItemGroup>
15-
16-
<ItemGroup>
17-
<EmbeddedResource Include="EmbeddedResources\INotifyPropertyChanged.cs">
18-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
19-
</EmbeddedResource>
20-
<EmbeddedResource Include="EmbeddedResources\NotNullAttribute.cs">
21-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22-
</EmbeddedResource>
23-
<EmbeddedResource Include="EmbeddedResources\NotNullIfNotNullAttribute.cs">
24-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25-
</EmbeddedResource>
26-
<EmbeddedResource Include="EmbeddedResources\ObservableObject.cs">
27-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
28-
</EmbeddedResource>
29-
<EmbeddedResource Include="EmbeddedResources\ObservableRecipient.cs">
30-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
31-
</EmbeddedResource>
9+
<Compile Remove="EmbeddedResources\*.cs" />
10+
<EmbeddedResource Include="EmbeddedResources\*.cs" CopyToOutputDirectory="PreserveNewest" />
3211
</ItemGroup>
3312

3413
<ItemGroup>

CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
the same version) but Microsoft.Build.Tasks.CodeAnalysis.dll is where MSBuild loads the compiler tasks from so if
2020
someone is getting creative with msbuild tasks/targets this is the "most correct" assembly to check.
2121
-->
22-
<GetAssemblyIdentity AssemblyFiles="$([System.IO.Path]::Combine(`$([System.IO.Path]::GetDirectoryName($(CSharpCoreTargetsPath)))`,`Microsoft.Build.Tasks.CodeAnalysis.dll`))">
22+
<GetAssemblyIdentity AssemblyFiles="$([System.IO.Path]::Combine($([System.IO.Path]::GetDirectoryName($(CSharpCoreTargetsPath))), 'Microsoft.Build.Tasks.CodeAnalysis.dll'))">
2323
<Output TaskParameter="Assemblies" ItemName="MVVMToolkitCurrentCompilerAssemblyIdentity"/>
2424
</GetAssemblyIdentity>
2525

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<!-- Embed source files that are not tracked by the source control manager to the PDB -->
3737
<EmbedUntrackedSources>true</EmbedUntrackedSources>
3838
<!-- Include PDB in the built .nupkg -->
39-
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
39+
<AllowedOutputExtensionsInPackageBuildOutputFolder>.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
4040
</PropertyGroup>
4141
<ItemGroup>
4242
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />

build/Community.Toolkit.Common.props

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
<Company>Microsoft</Company>
55
<Authors>Microsoft</Authors>
66
<Product>.NET Community Toolkit</Product>
7-
<CommonTags>dotnet;Community;Toolkit</CommonTags>
7+
<CommonTags>.NET;Community;Toolkit;dotnet</CommonTags>
88
<PackageLicenseExpression>MIT</PackageLicenseExpression>
99
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1010
<Copyright>(c) .NET Foundation and Contributors. All rights reserved.</Copyright>
1111
<PackageProjectUrl>https://github.com/CommunityToolkit/dotnet</PackageProjectUrl>
1212
<PackageReleaseNotes>https://github.com/CommunityToolkit/dotnet/releases</PackageReleaseNotes>
1313
<PackageIcon>Icon.png</PackageIcon>
14-
<PackageIconUrl>https://raw.githubusercontent.com/CommunityToolkit/dotnet/main/build/nuget.png</PackageIconUrl>
1514
</PropertyGroup>
1615

1716
<PropertyGroup>
@@ -26,7 +25,7 @@
2625
</PropertyGroup>
2726

2827
<PropertyGroup>
29-
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
28+
<IsTestProject>$(MSBuildProjectName.EndsWith('Tests'))</IsTestProject>
3029
<IsCoreProject Condition="$(IsTestProject)">False</IsCoreProject>
3130
<IsCoreProject Condition="'$(IsCoreProject)' == ''">True</IsCoreProject>
3231
</PropertyGroup>

build/Community.Toolkit.Common.targets

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
<Project>
22

3-
<PropertyGroup>
3+
<PropertyGroup Condition="$(IsPackable)">
44
<!-- TODO: Dynamically generate Title if one wasn't set -->
55
<Title Condition="'$(Title)' == ''">$(Product) Asset</Title>
6-
</PropertyGroup>
7-
8-
<PropertyGroup>
9-
<CommonTags Condition="$(IsCoreProject)">$(CommonTags);.NET</CommonTags>
106
<PackageTags Condition="'$(PackageTags)' != ''">$(CommonTags);$(PackageTags)</PackageTags>
117
<PackageTags Condition="'$(PackageTags)' == ''">$(CommonTags)</PackageTags>
128
</PropertyGroup>

0 commit comments

Comments
 (0)