From 4271041a8862b4375fd247e8acd61f144227ac0a Mon Sep 17 00:00:00 2001 From: Nirmal Guru Date: Thu, 29 Jul 2021 09:36:45 +0530 Subject: [PATCH] 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. --- CommunityToolkit.sln | 1 + Directory.Build.props | 2 +- eng/AssemblyInfo.Shared.cs | 16 ++++++ eng/Toolkit.Common.targets | 12 +++- eng/Toolkit.TextTemplates.targets | 35 ++---------- .../CommunityToolkit.HighPerformance.csproj | 2 +- .../CommunityToolkit.Mvvm.csproj | 2 +- .../CommunityToolkit.Mvvm.targets | 48 ++++++++-------- src/Directory.Build.props | 7 +-- src/Directory.Build.targets | 57 ++++--------------- tests/Directory.Build.props | 2 +- tests/Directory.Build.targets | 2 +- 12 files changed, 71 insertions(+), 115 deletions(-) create mode 100644 eng/AssemblyInfo.Shared.cs diff --git a/CommunityToolkit.sln b/CommunityToolkit.sln index e07f55fbd..66730b785 100644 --- a/CommunityToolkit.sln +++ b/CommunityToolkit.sln @@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Root", "Root", "{CFA75BE0-5 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{CD16E790-7B7B-411E-9CE7-768E759CC22D}" ProjectSection(SolutionItems) = preProject + eng\AssemblyInfo.Shared.cs = eng\AssemblyInfo.Shared.cs eng\Sign-Package.ps1 = eng\Sign-Package.ps1 eng\SignClientSettings.json = eng\SignClientSettings.json eng\Toolkit.Common.props = eng\Toolkit.Common.props diff --git a/Directory.Build.props b/Directory.Build.props index 3896f9371..ff806bb95 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -19,7 +19,7 @@ true - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + .pdb diff --git a/eng/AssemblyInfo.Shared.cs b/eng/AssemblyInfo.Shared.cs new file mode 100644 index 000000000..db0396925 --- /dev/null +++ b/eng/AssemblyInfo.Shared.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// This file contains assembly and module attributes that is shared across projects. +// Include it in `Directory.Build.targets` near to all projects that need this file. + +using System.Runtime.CompilerServices; + +/* + Using `[module: SkipLocalsInit]` suppresses the .init flag for local variables for the entire module. + This doesn't affect the correctness of the methods in this assembly, as none of them are relying on + JIT ensuring that all local memory is zeroed out to work. Doing this can provide some minor + performance benefits, depending on the workload. +*/ +[module: SkipLocalsInit] diff --git a/eng/Toolkit.Common.targets b/eng/Toolkit.Common.targets index 51dcd077e..fe9c21020 100644 --- a/eng/Toolkit.Common.targets +++ b/eng/Toolkit.Common.targets @@ -1,6 +1,6 @@ - + Microsoft Microsoft .NET Community Toolkit @@ -13,19 +13,25 @@ Icon.png - + $(Product) Asset $(CommonTags);$(PackageTags) $(CommonTags) - + + + + <_ToolkitTargetFrameworkVersion>$([MSBuild]::GetTargetFrameworkVersion($(TargetFramework))) + <_NET_6_OR_GREATER>$([MSBuild]::VersionGreaterThanOrEquals($(_ToolkitTargetFrameworkVersion), '6.0')) + + - + diff --git a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj index 63858e173..6a6bb18d3 100644 --- a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj +++ b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj @@ -39,7 +39,7 @@ - + - + - + - + DependsOnTargets="MVVMToolkit_GatherAnalyzers"> - - + + - @(MVVMToolkitCurrentCompilerAssemblyIdentity->'%(Version)') + @(MVVMToolkit_CurrentCompilerAssemblyIdentity->%(Version)) - - true + + true - - + + - + - + DependsOnTargets="MVVMToolkit_RemoveAnalyzers_WhenRoslynVersionIsNotSupported"> - roslyn4.3 - roslyn4.0 + roslyn4.3 + roslyn4.0 - + - + DependsOnTargets="MVVMToolkit_GatherAnalyzers"> - + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index ad499bb2b..96b5b700b 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,6 +1,6 @@ - + true @@ -12,10 +12,7 @@ - - all - build; analyzers - + \ No newline at end of file diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 6b83bf1fd..035d9e42c 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -1,56 +1,19 @@ - + - - - NETSTANDARD2_1_OR_GREATER - - - - - true + true + true + NETSTANDARD2_1_OR_GREATER - - - $(IntermediateOutputPath)$(MSBuildProjectName).SkipLocalsInit.g.cs - - -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -[module: global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]]]> - - - - - - - + + + - - - - - + + + \ No newline at end of file diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 55ce96af9..9c91d9c2c 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -1,6 +1,6 @@ - + false diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 07296256b..e7f220069 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -1,6 +1,6 @@ - +