forked from dotnet/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Crossgen.targets
175 lines (146 loc) · 9.72 KB
/
Crossgen.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<Project>
<!-- Crossgen is currently not supported on the s390x architecture. -->
<Target Name="CrossgenLayout"
Condition="'$(DISABLE_CROSSGEN)' == '' AND '$(Architecture)' != 's390x'"
DependsOnTargets="SetSdkBrandingInfo">
<PropertyGroup>
<RuntimeNETCoreAppPackageName>microsoft.netcore.app.runtime.$(SharedFrameworkRid)</RuntimeNETCoreAppPackageName>
<RuntimeNETCrossgenPackageName>microsoft.netcore.app.crossgen2.$(Crossgen2Rid)</RuntimeNETCrossgenPackageName>
<CrossgenPath>$(NuGetPackageRoot)/$(RuntimeNETCrossgenPackageName)/$(MicrosoftNETCoreAppRuntimePackageVersion)/tools/crossgen2$(ExeExtension)</CrossgenPath>
<!-- When ingesting stable pgo instrumented binaries, the shared framework will be a non-stable version,
as will the archive file names themselves. -->
<SharedFrameworkNameVersionPath Condition=" '$(PgoInstrument)' != 'true' ">$(RedistLayoutPath)shared/$(SharedFrameworkName)/$(MicrosoftNETCoreAppRuntimePackageVersion)</SharedFrameworkNameVersionPath>
<SharedFrameworkNameVersionPath Condition=" '$(PgoInstrument)' == 'true' ">$(RedistLayoutPath)shared/$(SharedFrameworkName)/$(VSRedistCommonNetCoreSharedFrameworkx6460PackageVersion)</SharedFrameworkNameVersionPath>
</PropertyGroup>
<!-- Download the runtime package with the crossgen executable in it -->
<ItemGroup>
<CrossGenDownloadPackageProject Include="$(MSBuildThisFileDirectory)DownloadPackage.csproj">
<Properties>
PackageToRestore=$(RuntimeNETCrossgenPackageName);
PackageVersionToRestore=$(MicrosoftNETCoreAppRuntimePackageVersion);
TargetFramework=$(TargetFramework)
</Properties>
</CrossGenDownloadPackageProject>
</ItemGroup>
<MSBuild
BuildInParallel="False"
Projects="@(CrossGenDownloadPackageProject)">
</MSBuild>
<ItemGroup>
<RoslynFiles Include="$(SdkOutputDirectory)Roslyn\bincore\**\*" />
<FSharpFilesRuntimes Include="$(SdkOutputDirectory)FSharp\runtimes\**\*" />
<FSharpFilesRoot Include="$(SdkOutputDirectory)FSharp\**\*" Exclude="$(SdkOutputDirectory)FSharp\FSharp.Build.dll;@(FSharpFilesRuntimes)" />
<FSharpFiles Include="@(FSharpFilesRuntimes);@(FSharpFilesRoot)" />
<RazorToolFiles Include="$(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.Razor\tools\**\*" />
<RemainingFiles Include="$(SdkOutputDirectory)**\*" Exclude="$(SdkOutputDirectory)FSharp\FSharp.Build.dll;@(RoslynFiles);@(FSharpFiles)" />
<!-- Removing Full CLR built TestHost assemblies from getting Crossgen as it is throwing error -->
<RemainingFiles Remove="$(SdkOutputDirectory)TestHost*\**\*" />
<RemainingFiles Remove="$(SdkOutputDirectory)Sdks\**\*" />
<RemainingFiles Remove="$(SdkOutputDirectory)**\Microsoft.TestPlatform.Extensions.EventLogCollector.dll" />
<!-- Add back the .NET Core assemblies in the Sdks folder -->
<RemainingFiles Include="$(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk\tools\net6.0\**\*" />
<RemainingFiles Include="$(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\tools\net6.0\**\*" />
<RemainingFiles Include="$(SdkOutputDirectory)Sdks\NuGet.Build.Tasks.Pack\CoreCLR\**\*" />
<RemainingFiles Include="$(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.Razor\tasks\net6.0\**\*" />
<RemainingFiles Include="$(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\netcoreapp*\**\*" />
<RemainingFiles Include="$(SdkOutputDirectory)Sdks\Microsoft.NET.ILLink.Tasks\tools\net5.0\**\*" />
<RemainingFiles Include="$(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.Publish\tools\net6.0\**\*" />
<RemainingFiles Include="$(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.Web\tools\net6.0\**\*" />
<RemainingFiles Include="$(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.Web.ProjectSystem\tools\net6.0\**\*" />
<RemainingFiles Include="$(SdkOutputDirectory)Sdks\Microsoft.NET.Sdk.Worker\tools\net6.0\**\*" />
<!-- Don't try to CrossGen .NET Framework support assemblies for .NET Standard -->
<RemainingFiles Remove="$(SdkOutputDirectory)Microsoft\Microsoft.NET.Build.Extensions\net*\**\*" />
<!-- Don't CrossGen bundled DotnetTools -->
<RemainingFiles Remove="$(SdkOutputDirectory)DotnetTools\**\*" />
<!-- Don't crossgen satellite assemblies -->
<RoslynFiles Remove="$(SdkOutputDirectory)Roslyn\bincore\**\*.resources.dll" />
<FSharpFiles Remove="$(SdkOutputDirectory)FSharp\**\*.resources.dll" />
<RazorToolFiles Remove="$(SdkOutputDirectory)**\*.resources.dll" />
<RemainingFiles Remove="$(SdkOutputDirectory)**\*.resources.dll" />
<!-- Don't crossgen reference assemblies redisted with msbuild for RoslynCodeTaskFactory -->
<RazorToolFiles Remove="$(SdkOutputDirectory)**\ref\*.dll" />
<RemainingFiles Remove="$(SdkOutputDirectory)**\ref\*.dll" />
</ItemGroup>
<AddMetadataIsPE Items="@(RoslynFiles)">
<Output TaskParameter="ResultItems" ItemName="RoslynFilesWithPEMarker" />
</AddMetadataIsPE>
<AddMetadataIsPE Items="@(FSharpFiles)">
<Output TaskParameter="ResultItems" ItemName="FSharpFilesWithPEMarker" />
</AddMetadataIsPE>
<AddMetadataIsPE Items="@(RazorToolFiles)">
<Output TaskParameter="ResultItems" ItemName="RazorToolFilesWithPEMarker" />
</AddMetadataIsPE>
<AddMetadataIsPE Items="@(RemainingFiles)">
<Output TaskParameter="ResultItems" ItemName="RemainingFilesWithPEMarker" />
</AddMetadataIsPE>
<ItemGroup>
<RoslynTargets Include="%(RoslynFilesWithPEMarker.FullPath)" Condition=" '%(RoslynFilesWithPEMarker.IsPE)' == 'True' " />
<FSharpTargets Include="%(FSharpFilesWithPEMarker.FullPath)" Condition=" '%(FSharpFilesWithPEMarker.IsPE)' == 'True' " />
<RazorToolTargets Include="%(RazorToolFilesWithPEMarker.FullPath)" Condition=" '%(RazorToolFilesWithPEMarker.IsPE)' == 'True' " />
<RemainingTargets Include="%(RemainingFilesWithPEMarker.FullPath)" Condition=" '%(RemainingFilesWithPEMarker.IsPE)' == 'True' " />
<RoslynFolders Include="@(RoslynTargets->DirectoryName()->Distinct())" />
<FSharpFolders Include="@(FSharpTargets->DirectoryName()->Distinct())" />
<RazorToolFolders Include="@(RazorToolTargets->DirectoryName()->Distinct())" />
<RemainingFolders Include="@(RemainingTargets->DirectoryName()->Distinct())" />
<!-- FSharp.Build.dll causes the FSharp folder to be included. Remove it, as we don't want other FSharp dlls being included in the crossgen. -->
<RemainingFolders Remove="$(PublishDir)FSharp\**\*" />
<!-- RemainingFolders should be ordered so that dependencies are first looked up in the leaf folders.
Currently it is not ordered and crossgen is picking the wrong dlls when resolving dependencies: https://github.com/dotnet/core-sdk/pull/6774
As a partial solution, we remove the root folder from the list and put it back to the end.
Remove the following 2 lines when resolving this issue: https://github.com/dotnet/core-sdk/issues/6877 -->
<RemainingFolders Remove="$(SdkOutputDirectory.TrimEnd('\').TrimEnd('/'))" />
<RemainingFolders Include="$(SdkOutputDirectory.TrimEnd('\').TrimEnd('/'))" />
</ItemGroup>
<!-- Crossgen does not support generating symbols on Mac -->
<PropertyGroup Condition="'$(CreateCrossgenSymbols)' == ''">
<CreateCrossgenSymbols>true</CreateCrossgenSymbols>
<CreateCrossgenSymbols Condition="'$(OSName)' == 'osx'">false</CreateCrossgenSymbols>
<CreateCrossgenSymbols Condition="'$(OSName)' == 'freebsd'">false</CreateCrossgenSymbols>
</PropertyGroup>
<Crossgen
SourceAssembly="%(RoslynTargets.FullPath)"
DestinationPath="%(RoslynTargets.FullPath)"
Architecture="$(Architecture)"
CrossgenPath="$(CrossgenPath)"
ReadyToRun="True"
CreateSymbols="$(CreateCrossgenSymbols)"
PlatformAssemblyPaths="@(RoslynFolders);$(SharedFrameworkNameVersionPath)" />
<Crossgen
SourceAssembly="%(FSharpTargets.FullPath)"
DestinationPath="%(FSharpTargets.FullPath)"
Architecture="$(Architecture)"
CrossgenPath="$(CrossgenPath)"
ReadyToRun="True"
CreateSymbols="$(CreateCrossgenSymbols)"
PlatformAssemblyPaths="@(FSharpFolders);$(SharedFrameworkNameVersionPath)" />
<Crossgen
SourceAssembly="%(RemainingTargets.FullPath)"
DestinationPath="%(RemainingTargets.FullPath)"
Architecture="$(Architecture)"
CrossgenPath="$(CrossgenPath)"
ReadyToRun="True"
CreateSymbols="$(CreateCrossgenSymbols)"
PlatformAssemblyPaths="@(RemainingFolders);$(SharedFrameworkNameVersionPath)" />
<Crossgen
SourceAssembly="%(RazorToolTargets.FullPath)"
DestinationPath="%(RazorToolTargets.FullPath)"
Architecture="$(Architecture)"
CrossgenPath="$(CrossgenPath)"
ReadyToRun="True"
CreateSymbols="$(CreateCrossgenSymbols)"
PlatformAssemblyPaths="@(RazorToolFolders);@(RoslynFolders);$(SharedFrameworkNameVersionPath)" />
<ItemGroup>
<PdbsToMove Include="$(SdkOutputDirectory)**/*.pdb" />
<PdbsToMove Include="$(SdkOutputDirectory)**/*.ni.*.map" />
</ItemGroup>
<!-- Move symbols to separate folder, they are not included in the layout but are published separately -->
<Move SourceFiles="@(PdbsToMove)"
DestinationFiles="@(PdbsToMove->'$(ArtifactsSymStoreDirectory)/sdk/$(Version)/%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
<Target Name="ChmodLayout"
AfterTargets="CrossgenLayout"
Condition=" '$(OSName)' != 'win' ">
<Exec Command="find $(SdkOutputDirectory) -type d -exec chmod 755 {} \;" />
<Exec Command="find $(SdkOutputDirectory) -type f -exec chmod 644 {} \;" />
</Target>
</Project>