forked from dotnet/winforms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Directory.Build.targets
115 lines (99 loc) · 5.92 KB
/
Directory.Build.targets
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
113
114
115
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Project="$(RepositoryEngineeringDir)CodeStyle.targets" />
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Import Project="$(RepositoryEngineeringDir)packageContent.targets" />
<Import Project="$(RepositoryEngineeringDir)versioning.targets" />
<Import Project="$(RepositoryEngineeringDir)ApiCompatibility\PublicApiAnalyzer.targets" />
<!-- CA1416 Validate platform compatibility. Do not apply to netstandard as it does not have the attribute. -->
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.Versioning.SupportedOSPlatform" Condition="!$(TargetFramework.StartsWith('netstandard'))">
<!-- This tells the analyzer that we are targeting windows6.1 (windows 7). -->
<_Parameter1>windows6.1</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
<!-- to prevent using MS.NC.Platforms from SDK, which is lagging behind the version that WinForms gets from the CoreFx packages -->
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.Platforms" Version="$(MicrosoftNETCorePlatformsPackageVersion)" PrivateAssets="all" />
</ItemGroup>
<!-- Set code coverage properties that reference properties not available in Directory.Build.props -->
<PropertyGroup Condition="'$(Coverage)' == 'true'">
<CoverletOutput>$(TargetDir)coverage\$(MSBuildProjectName).coverage</CoverletOutput>
</PropertyGroup>
<!-- Turn on single-file publishing analysis for everything except the test projects -->
<PropertyGroup Condition="'$(IsTestProject)' != 'true'">
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
</PropertyGroup>
<!-- Mark all projects located under **\tests\* folders as non-shipping -->
<PropertyGroup>
<_ProjectDirectoryRelativePath>$([MSBuild]::MakeRelative($(RepoRoot), $(MSBuildProjectDirectory)))</_ProjectDirectoryRelativePath>
<_IsUnderTestsFolder>$(_ProjectDirectoryRelativePath.Contains("\tests\"))</_IsUnderTestsFolder>
<IsShipping Condition="$(_IsUnderTestsFolder)">false</IsShipping>
<RedistTargetFrameworkName>$(TargetFrameworkName)$(TargetFrameworkMajorVersion).</RedistTargetFrameworkName>
</PropertyGroup>
<PropertyGroup Condition="'$(IsTestProject)' == 'true' ">
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture>
<Platform Condition="'$(Platform)' == 'AnyCPU' or '$(Platform)' == 'Any CPU'">$(TargetArchitecture)</Platform>
<TestArchitectures>$(TargetArchitecture)</TestArchitectures>
</PropertyGroup>
<Target Name="InstrumentModulesNoBuild" BeforeTargets="RunTests" Condition="'$(IsUnitTestProject)' == 'true'">
<Coverlet.MSbuild.Tasks.InstrumentationTask
Condition="'$(CollectCoverage)' == 'true'"
Path="$(TargetPath)"
Include="$(Include)"
IncludeDirectory="$(IncludeDirectory)"
Exclude="$(Exclude)"
ExcludeByFile="$(ExcludeByFile)"
ExcludeByAttribute="$(ExcludeByAttribute)"
IncludeTestAssembly="$(IncludeTestAssembly)"
SingleHit="$(SingleHit)"
MergeWith="$(MergeWith)"
UseSourceLink="$(UseSourceLink)" >
<Output TaskParameter="InstrumenterState" PropertyName="InstrumenterState"/>
</Coverlet.MSbuild.Tasks.InstrumentationTask>
</Target>
<Target Name="GenerateCoverageResult" AfterTargets="RunTests" Condition="'$(IsUnitTestProject)' == 'true'">
<Coverlet.MSbuild.Tasks.CoverageResultTask
Condition="'$(CollectCoverage)' == 'true'"
Output="$(CoverletOutput)"
OutputFormat="$(CoverletOutputFormat)"
Threshold="$(Threshold)"
ThresholdType="$(ThresholdType)"
ThresholdStat="$(ThresholdStat)"
InstrumenterState="$(InstrumenterState)"/>
</Target>
<ItemGroup>
<!-- Set TargetingPackVersion -->
<FrameworkReference Update="Microsoft.NETCore.App"
Condition=" '$(VSRedistCommonNetCoreSharedFrameworkx6490PackageVersion)'!='' And $(TargetFramework.StartsWith('$(RedistTargetFrameworkName)')) ">
<TargetingPackVersion>$(VSRedistCommonNetCoreSharedFrameworkx6490PackageVersion)</TargetingPackVersion>
</FrameworkReference>
</ItemGroup>
<PropertyGroup>
<!-- Set RuntimeFrameworkVersion to VSRedistCommonNetCoreSharedFrameworkx6490PackageVersion from Core Setup to prevent large SDK cycle -->
<RuntimeFrameworkVersion Condition="'$(VSRedistCommonNetCoreSharedFrameworkx6490PackageVersion)'!='' And $(TargetFramework.StartsWith('$(RedistTargetFrameworkName)')) ">$(VSRedistCommonNetCoreSharedFrameworkx6490PackageVersion)</RuntimeFrameworkVersion>
<!-- If TargetFramework is not net8.x, then reset RuntimeFrameworkVersion -->
<RuntimeFrameworkVersion Condition="!$(TargetFramework.StartsWith('$(RedistTargetFrameworkName)'))" />
</PropertyGroup>
<Choose>
<When Condition="'$(IncludeInternalObsoleteAttribute)' == 'true' and '$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<ItemGroup>
<Compile Include="$(RepoRoot)src\Common\src\ObsoleteAttribute.cs" />
</ItemGroup>
<PropertyGroup>
<!-- Suppress CS0436 to allow ObsoleteAttribute to be internally defined and used in .NET Standard. -->
<NoWarn>$(NoWarn);CS0436</NoWarn>
</PropertyGroup>
</When>
</Choose>
<!-- If a tfm doesn't target .NETCoreApp but uses the platform support attributes, then we include the
System.Runtime.Versioning*Platform* annotation attribute classes in the project as internal.
If a project has specified assembly-level SupportedOSPlatforms or UnsupportedOSPlatforms,
we can infer the need without having IncludePlatformAttributes set. -->
<PropertyGroup>
<IncludePlatformAttributes Condition="'$(IncludePlatformAttributes)' == '' and ('$(SupportedOSPlatforms)' != '' or '$(UnsupportedOSPlatforms)' != '')">true</IncludePlatformAttributes>
</PropertyGroup>
<ItemGroup Condition="'$(IncludePlatformAttributes)' == 'true' and '$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<Compile Include="$(RepoRoot)src\Common\src\PlatformAttributes.cs" />
</ItemGroup>
</Project>