-
-
Notifications
You must be signed in to change notification settings - Fork 846
Expand file tree
/
Copy pathdefault.proj
More file actions
153 lines (151 loc) · 9.5 KB
/
Copy pathdefault.proj
File metadata and controls
153 lines (151 loc) · 9.5 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="All" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="Current">
<PropertyGroup>
<!-- Increment the overall semantic version here. -->
<Version>9.3.2</Version>
<SolutionName>Autofac</SolutionName>
<Configuration Condition="'$(Configuration)'==''">Release</Configuration>
<ArtifactDirectory>$([System.IO.Path]::Combine($(MSBuildProjectDirectory),"artifacts"))</ArtifactDirectory>
<PackageDirectory>$([System.IO.Path]::Combine($(ArtifactDirectory),"packages"))</PackageDirectory>
<LogDirectory>$([System.IO.Path]::Combine($(ArtifactDirectory),"logs"))</LogDirectory>
<CoverageRunSettings>$([System.IO.Path]::Combine($(MSBuildProjectDirectory),'build/Coverage.runsettings'))</CoverageRunSettings>
<BuildDateTime>$([System.DateTimeOffset]::UtcNow.ToString('yyyyMMddTHHmmssZ'))</BuildDateTime>
</PropertyGroup>
<Choose>
<When Condition="'$(GITHUB_REF_NAME)'==''">
<PropertyGroup>
<Version>$(Version)-local</Version>
</PropertyGroup>
</When>
<When Condition="'$(GITHUB_REF_NAME)'=='main' Or $([System.Text.RegularExpressions.Regex]::IsMatch($(GITHUB_REF_NAME), `^v.+\..+\..+`))">
<PropertyGroup>
<Version>$(Version)</Version>
</PropertyGroup>
</When>
<When Condition="'$(GITHUB_REF_NAME)'=='develop'">
<PropertyGroup>
<Version>$(Version)-beta$(BuildDateTime)</Version>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<Version>$(Version)-alpha$(BuildDateTime)</Version>
</PropertyGroup>
</Otherwise>
</Choose>
<ItemGroup>
<CleanDirectory Include="$(ArtifactDirectory)" />
<SourceProject Include="$(MSBuildProjectDirectory)/src/**/*.csproj" />
<TestProject Include="$(MSBuildProjectDirectory)/test/**/*.csproj" />
<SolutionFile Include="$(SolutionName).sln" />
</ItemGroup>
<Target Name="All">
<Message Text="****************************************" Importance="high" />
<Message Text="$(SolutionName) v$(Version)" Importance="high" />
<Message Text="$(Configuration) Configuration" Importance="high" />
<Message Text="$(BuildDateTime)" Importance="high" />
<Message Text="****************************************" Importance="high" />
<CallTarget Targets="Clean;Compile;Test;Package" />
</Target>
<Target Name="Benchmarks" DependsOnTargets="Compile">
<Message Text="****************************************" Importance="high" />
<Message Text="Running Benchmarks" Importance="high" />
<Message Text="****************************************" Importance="high" />
<Exec Command="dotnet run --project "$([System.IO.Path]::Combine($(MSBuildProjectDirectory),'bench/Autofac.Benchmarks'))" -c $(Configuration) --no-launch-profile --no-restore --no-build -- --filter Autofac.Benchmarks.*" />
</Target>
<Target Name="Clean">
<RemoveDir Directories="@(CleanDirectory)" />
<RemoveDir Directories="%(SourceProject.RootDir)%(SourceProject.Directory)bin;%(SourceProject.RootDir)%(SourceProject.Directory)obj" />
<RemoveDir Directories="%(TestProject.RootDir)%(TestProject.Directory)bin;%(TestProject.RootDir)%(TestProject.Directory)obj" />
</Target>
<Target Name="Compile">
<Exec Command="dotnet --info" />
<Exec Command="dotnet build "%(SolutionFile.FullPath)" -c $(Configuration) /p:Version=$(Version)" />
</Target>
<Target Name="Package">
<MakeDir Directories="$(PackageDirectory)" />
<Exec Command="dotnet pack "%(SourceProject.Identity)" -c $(Configuration) --no-build --output "$(PackageDirectory)" /p:Version=$(Version)" />
</Target>
<Target Name="Test">
<MakeDir Directories="$(LogDirectory)" />
<Exec Command="dotnet test "%(SolutionFile.FullPath)" -c $(Configuration) --results-directory "$(LogDirectory)" --logger:trx /p:Version=$(Version) --collect:"XPlat Code Coverage" --settings "$(CoverageRunSettings)"" />
</Target>
<!--
Native AOT verification. Publishes the AOT smoke-test app with PublishAot=true
(which runs the ILC trim/AOT analyzer and would fail the build on any IL2104/
IL3053 warning, since the project treats warnings as errors) and then executes
the produced native binary, asserting a zero exit code. This proves both that
Autofac is statically AOT-clean AND that the AOT-safe resolve path works at
runtime. The project is intentionally excluded from Autofac.sln so the normal
Compile/Test targets do not require the native toolchain.
-->
<PropertyGroup>
<AotProjectDirectory>$([System.IO.Path]::Combine($(MSBuildProjectDirectory),'test/Autofac.Test.Aot'))</AotProjectDirectory>
<AotPublishDirectory>$([System.IO.Path]::Combine($(ArtifactDirectory),'aot'))</AotPublishDirectory>
<AotExecutableName>Autofac.Test.Aot</AotExecutableName>
<AotExecutableName Condition="'$(OS)' == 'Windows_NT'">Autofac.Test.Aot.exe</AotExecutableName>
</PropertyGroup>
<Target Name="VerifyAot" DependsOnTargets="VerifyAotWarnings">
<Message Text="****************************************" Importance="high" />
<Message Text="Verifying Native AOT compatibility" Importance="high" />
<Message Text="****************************************" Importance="high" />
<Exec Command="dotnet publish "$(AotProjectDirectory)" -c $(Configuration) --output "$(AotPublishDirectory)"" />
<Exec Command=""$([System.IO.Path]::Combine($(AotPublishDirectory),$(AotExecutableName)))"" />
</Target>
<!--
AOT/trim warning verification. Builds the warning fixture (which calls the APIs
annotated [RequiresDynamicCode] / [RequiresUnreferencedCode]) and asserts the
expected analyzer diagnostics are emitted. This guards against silently LOSING an
annotation: if an attribute is dropped, the warning stops firing and this target
fails. Unlike VerifyAot proper, this needs no native toolchain - a plain build
surfaces the analyzer diagnostics - so it is cheap to run anywhere.
The check is PER CALL SITE, not just per diagnostic code: each ExpectedAotWarning
item names both the code (IL2026/IL3050) and a distinctive substring of the
annotated member's signature as it appears in the warning text. Multiple call
sites share a code (e.g. RegisterGeneric and RegisterGenericDecorator are both
IL3050), so asserting only "IL3050 appears somewhere" would not catch losing the
annotation on just one of them. Matching the member signature catches each one.
Keep the ExpectedAotWarning items in sync with the calls in
test/Autofac.Test.AotWarnings/Program.cs - one item per annotated call.
-->
<PropertyGroup>
<AotWarningsProjectDirectory>$([System.IO.Path]::Combine($(MSBuildProjectDirectory),'test/Autofac.Test.AotWarnings'))</AotWarningsProjectDirectory>
</PropertyGroup>
<ItemGroup>
<!-- Identity = the IL code; Member = a substring uniquely identifying the API in the warning text. -->
<ExpectedAotWarning Include="IL3050" Member="RegisterGeneric(ContainerBuilder, Type)" />
<ExpectedAotWarning Include="IL3050" Member="RegisterGenericDecorator(ContainerBuilder, Type, Type" />
<ExpectedAotWarning Include="IL2026" Member="RegisterAssemblyTypes(ContainerBuilder, params Assembly" />
<ExpectedAotWarning Include="IL2026" Member="RegisterAssemblyModules(ContainerBuilder, params Assembly" />
</ItemGroup>
<Target Name="VerifyAotWarnings">
<Message Text="****************************************" Importance="high" />
<Message Text="Verifying AOT/trim warnings still fire" Importance="high" />
<Message Text="****************************************" Importance="high" />
<MakeDir Directories="$(LogDirectory)" />
<PropertyGroup>
<AotWarningsLog>$([System.IO.Path]::Combine($(LogDirectory),'aot-warnings-build.log'))</AotWarningsLog>
</PropertyGroup>
<!--
Build the fixture (full recompile so analyzer diagnostics are always emitted)
and redirect ALL output to a log file. This is deliberate: the fixture emits the
IL2026/IL3050 warnings on purpose, and if they reached the CI job's stdout the
.NET problem matcher would turn each one into a (misleading) PR annotation. By
sending the build output only to a file and reading it back here, the warnings
are verified without ever surfacing on the console. The log is written under the
artifacts directory and inspected below.
-->
<Exec Command="dotnet build "$(AotWarningsProjectDirectory)" -c $(Configuration) --no-incremental > "$(AotWarningsLog)" 2>&1"
IgnoreExitCode="true" />
<ReadLinesFromFile File="$(AotWarningsLog)">
<Output TaskParameter="Lines" ItemName="AotWarningsBuildOutput" />
</ReadLinesFromFile>
<PropertyGroup>
<AotWarningsBuildText>@(AotWarningsBuildOutput, '%0a')</AotWarningsBuildText>
</PropertyGroup>
<!-- Each expected warning must appear with BOTH its code and the specific member signature. -->
<Error Condition="!($(AotWarningsBuildText.Contains('warning %(ExpectedAotWarning.Identity)')) and $(AotWarningsBuildText.Contains('%(ExpectedAotWarning.Member)')))"
Text="Expected AOT/trim diagnostic %(ExpectedAotWarning.Identity) for '%(ExpectedAotWarning.Member)' was NOT emitted by Autofac.Test.AotWarnings. A [RequiresDynamicCode]/[RequiresUnreferencedCode] annotation may have been lost in core Autofac." />
<Message Text="All expected AOT/trim warnings were emitted (@(ExpectedAotWarning->'%(Identity): %(Member)', '; '))." Importance="high" />
</Target>
</Project>