-
Notifications
You must be signed in to change notification settings - Fork 758
/
Directory.Build.targets
135 lines (121 loc) · 7.05 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<Project>
<!-- Conditional assert import for v3 test projects -->
<Choose>
<When Condition=" $(MSBuildProjectName.Contains('.v3.')) AND $(MSBuildProjectName.EndsWith('.tests')) ">
<ItemGroup>
<ProjectReference Condition=" '$(TargetFramework)' != 'net6.0' " Include="..\xunit.v3.assert\xunit.v3.assert.csproj" />
<ProjectReference Condition=" '$(TargetFramework)' == 'net6.0' " Include="..\xunit.v3.assert.compat\xunit.v3.assert.net6\xunit.v3.assert.net6.csproj" />
</ItemGroup>
</When>
</Choose>
<!-- Enable building .NET Framework on non-Windows machines -->
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="$(MicrosoftNetFrameworkReferenceAssembliesVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<!-- Enable nullable support for older targets -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
<PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="$(TunnelVisionLabsReferenceAssemblyAnnotatorVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[$(MicrosoftNetCoreAppRefVersion)]" />
</ItemGroup>
<!-- On Unix-like systems, mark .NET Framework binaries as executable -->
<Target
Name="MarkBinaryExecutable"
AfterTargets="Build"
Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' AND '$(OS)' != 'Windows_NT' AND $(TargetPath.EndsWith('.exe')) ">
<Exec Command="chmod +x '$(TargetPath)'" />
</Target>
<!-- Optional ILRepack targets for projects that want to opt-in -->
<Target
Name="ILRepack"
AfterTargets="Build"
Condition=" '$(TargetFramework)' != '' AND '$(RunILRepack)' == 'true' ">
<PropertyGroup>
<OutputAssembly>$([System.IO.Path]::Combine($(TargetDir), "merged", "$(TargetFileName)"))</OutputAssembly>
</PropertyGroup>
<Message Text="$(TargetName) -> $(OutputAssembly)" Importance="High" />
<CallTarget Targets="ILRepackConditional" />
</Target>
<Target
Name="ILRepackConditional"
Inputs="$(TargetPath)"
Outputs="$(TargetDir)merged\$(TargetFileName)">
<ItemGroup>
<Assemblies
Include="$(TargetDir)*.dll;$(TargetPath)"
Exclude="@(ILRepackExclusions)" />
</ItemGroup>
<MakeDir Directories="$(TargetDir)premerge;$(TargetDir)merged" />
<!-- We copy assemblies into a 'premerge' folder and merge from there, because of this issue: https://github.com/gluck/il-repack/issues/283 -->
<Copy SourceFiles="@(Assemblies)" DestinationFolder="$(TargetDir)premerge" />
<PropertyGroup>
<ILRepackExe>$([System.IO.Path]::Combine($(NuGetPackageRoot), "ilrepack.msbuild.task", $(ILRepackVersion), "tools", "ilrepack.exe"))</ILRepackExe>
<ILRepackExe Condition=" '$(OS)' != 'Windows_NT' ">mono $(ILRepackExe)</ILRepackExe>
<MainAssembly>$([System.IO.Path]::Combine($(TargetDir), "premerge", "$(TargetFileName)"))</MainAssembly>
<OutputAssembly>$([System.IO.Path]::Combine($(TargetDir), "merged", "$(TargetFileName)"))</OutputAssembly>
</PropertyGroup>
<ItemGroup>
<OutputsToCopy Include="$(TargetDir)*.config;@(ILRepackExclusions)" />
<ILRepackDependencies
Include="$(TargetDir)premerge\*.dll"
Exclude="$(MainAssembly)"/>
</ItemGroup>
<Copy SourceFiles="@(OutputsToCopy)" DestinationFolder="$(TargetDir)merged" />
<Exec
StandardOutputImportance="low"
Command="$(ILRepackExe) -internalize -ndebug -lib:$(TargetDir) -out:$(OutputAssembly) $(MainAssembly) @(ILRepackDependencies, ' ')" />
<Exec Command="chmod +x '$(OutputAssembly)'" Condition=" '$(OS)' != 'Windows_NT' " />
<RemoveDir Directories="$(TargetDir)premerge" />
</Target>
<!-- Support deterministic builds (via https://github.com/clairernovotny/DeterministicBuilds) -->
<PropertyGroup>
<ContinuousIntegrationBuild Condition=" '$(GITHUB_ACTIONS)' == 'true' ">true</ContinuousIntegrationBuild>
<TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
</PropertyGroup>
<ItemGroup>
<EmbeddedFiles Include="$(GeneratedAssemblyInfoFile)"/>
</ItemGroup>
<!-- Supplement Nerdbank.GitVersioning version calculations -->
<Target Name="UpdateAssemblyVersionInfo" BeforeTargets="GenerateAssemblyVersionInfo" DependsOnTargets="GetBuildVersion">
<PropertyGroup>
<!-- Local builds should have a '-dev' suffix on the build number -->
<PrereleaseSuffix Condition=" '$(GITHUB_ACTIONS)' != 'true' ">-dev</PrereleaseSuffix>
<!-- AssemblyVersion and AssemblyFileVersion should be x.y.z.0 -->
<AssemblyVersion>$(BuildVersionSimple)</AssemblyVersion>
<AssemblyFileVersion>$(BuildVersionSimple)</AssemblyFileVersion>
<!-- Always put the Git hash in the informational version, even for non-pre-release versions -->
<AssemblyInformationalVersion>$(BuildVersionSimple)$(PrereleaseVersion)$(PrereleaseSuffix)+$(GitCommitIdShort)</AssemblyInformationalVersion>
</PropertyGroup>
</Target>
<Target Name="UpdateNuSpecProperties" BeforeTargets="GenerateNuspec" DependsOnTargets="GetBuildVersion">
<ReadLinesFromFile File="$(MSBuildThisFileDirectory)..\.git\modules\src\xunit.v3.assert\Asserts\HEAD">
<Output TaskParameter="Lines" PropertyName="GitAssertModuleCommitId"/>
</ReadLinesFromFile>
<PropertyGroup>
<!-- Local builds should have a '-dev' suffix on the build number -->
<PrereleaseSuffix Condition=" '$(GITHUB_ACTIONS)' != 'true' ">-dev</PrereleaseSuffix>
<!-- Never put the Git hash in the package version -->
<PackageVersion>$(BuildVersionSimple)$(PrereleaseVersion)$(PrereleaseSuffix)</PackageVersion>
<PackageReleaseNotes>https://xunit.net/releases/v3/$(PackageVersion)</PackageReleaseNotes>
<!-- Pass through values we don't know ahead of time for any hand-crafted .nuspec files -->
<NuspecProperties>
Configuration=$(Configuration);
GitAssertModuleCommitId=$(GitAssertModuleCommitId);
GitCommitId=$(GitCommitId);
MicrosoftBclAsyncInterfacesVersion=$(MicrosoftBclAsyncInterfacesVersion);
MonoCecilVersion=$(MonoCecilVersion);
PackageVersion=$(PackageVersion);
SystemIoPipelinesVersion=$(SystemIoPipelinesVersion);
SystemNetHttpVersion=$(SystemNetHttpVersion);
SystemThreadingTasksExtensionsVersion=$(SystemThreadingTasksExtensionsVersion);
XunitAbstractionsVersion=$(XunitAbstractionsVersion);
XunitAnalyzersVersion=$(XunitAnalyzersVersion);
</NuspecProperties>
</PropertyGroup>
</Target>
</Project>