This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 217
/
Copy pathsharedFramework.proj
165 lines (136 loc) · 9.36 KB
/
sharedFramework.proj
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
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<UsingTask TaskName="ChangeEntryPointLibraryName" AssemblyFile="$(LocalBuildToolsTaskDir)core-setup.tasks.dll"/>
<UsingTask TaskName="ReplaceFileContents" AssemblyFile="$(LocalBuildToolsTaskDir)core-setup.tasks.dll"/>
<UsingTask TaskName="ProcessSharedFrameworkDeps" AssemblyFile="$(LocalBuildToolsTaskDir)core-setup.tasks.dll" />
<PropertyGroup>
<BuildTargets>
PublishSharedFrameworkAndSharedHost;
GenerateRuntimeGraph;
CopyHostArtifactsToSharedFramework;
GenerateVersionFile;
</BuildTargets>
</PropertyGroup>
<PropertyGroup>
<CommonProjectArgs>$(MSBuildPassThroughPropertyList) /p:TargetFramework=$(NETCoreAppFramework) /p:RuntimeIdentifier=$(PackageTargetRid)</CommonProjectArgs>
<!-- SFP is short for SharedFrameworkPublish. Using an abreviation to prevent long path issues. -->
<SharedFrameworkIntermediatePackagesDir>$(IntermediateOutputRootPath)SFP.packages\</SharedFrameworkIntermediatePackagesDir>
<SharedFrameworkNameAndVersionRoot>$(SharedFrameworkPublishDir)shared\$(SharedFrameworkName)\$(SharedFrameworkNugetVersion)</SharedFrameworkNameAndVersionRoot>
</PropertyGroup>
<Target Name="Build" DependsOnTargets="$(BuildTargets)" />
<Target Name="PublishSharedFrameworkAndSharedHost"
DependsOnTargets="RestoreLockedCoreHost">
<PropertyGroup>
<SharedFrameworkSourceRoot>$(MSBuildThisFileDirectory)framework</SharedFrameworkSourceRoot>
<CommonSharedFrameworkArgs>$(CommonProjectArgs) /p:RuntimeFrameworkVersion=$(SharedFrameworkNugetVersion)</CommonSharedFrameworkArgs>
</PropertyGroup>
<RemoveDir Directories="$(SharedFrameworkNameAndVersionRoot)" />
<!-- Specify a separate 'packages' directory in case we are building an already built version of Microsoft.NETCore.App and the $(PackagesDir)
already contains the same version as we are building. (ex. building source-build for `2.0.0` when `2.0.0` has already shipped.
-->
<Exec Command="$(DotnetRestoreCommandNoPackages) --source $(PackageOutputPath) --packages $(SharedFrameworkIntermediatePackagesDir) $(CommonSharedFrameworkArgs)"
WorkingDirectory="$(SharedFrameworkSourceRoot)" />
<!-- We publish to a sub folder of the PublishRoot so tools like heat and zip can generate folder structures easier. -->
<Exec Command="$(DotnetToolCommand) publish --no-restore --output $(SharedFrameworkNameAndVersionRoot) $(CommonSharedFrameworkArgs)"
WorkingDirectory="$(SharedFrameworkSourceRoot)" />
<!-- Clean deps.json -->
<ChangeEntryPointLibraryName DepsFile="$(SharedFrameworkNameAndVersionRoot)/framework.deps.json" />
<!-- Clean up artifacts that dotnet-publish generates which we don't need -->
<ItemGroup>
<ToDelete Include="$(SharedFrameworkNameAndVersionRoot)\framework" />
<ToDelete Include="$(SharedFrameworkNameAndVersionRoot)\framework.exe" />
<ToDelete Include="$(SharedFrameworkNameAndVersionRoot)\framework.dll" />
<ToDelete Include="$(SharedFrameworkNameAndVersionRoot)\framework.pdb" />
<ToDelete Include="$(SharedFrameworkNameAndVersionRoot)\framework.runtimeconfig.json" />
<ToDelete Include="$(SharedFrameworkNameAndVersionRoot)\apphost$(ExeSuffix)" />
<ToDelete Include="$(SharedFrameworkNameAndVersionRoot)\$(LibPrefix)hostfxr$(LibSuffix)" />
<ToDelete Include="$(SharedFrameworkNameAndVersionRoot)\$(LibPrefix)comhost$(LibSuffix)" />
<ToDelete Include="$(SharedFrameworkNameAndVersionRoot)\$(LibPrefix)ijwhost$(LibSuffix)" />
<ToDelete Include="$(SharedFrameworkNameAndVersionRoot)\ijwhost.lib" />
</ItemGroup>
<Message Text="To delete: @(ToDelete)" />
<Delete Files="@(ToDelete)" />
<!-- Rename deps file -->
<Move SourceFiles="$(SharedFrameworkNameAndVersionRoot)\framework.deps.json"
DestinationFiles="$(SharedFrameworkNameAndVersionRoot)\$(SharedFrameworkName).deps.json" />
<!-- Use the muxer we intended to consume (either restored a shipped version or the one we built) -->
<!-- Ensure the host is executable. See https://github.com/NuGet/Home/issues/4424 -->
<Exec Command="chmod u+x $(CoreHostLockedDir)dotnet$(ExeSuffix)"
Condition="'$(OSGroup)' != 'Windows_NT'" />
<Copy SourceFiles="$(CoreHostLockedDir)dotnet$(ExeSuffix)" DestinationFolder="$(SharedFrameworkPublishDir)" />
<!-- Use the FXR Resolver we intended to consume (either restored a shipped version or the one we built) -->
<Copy SourceFiles="$(CoreHostLockedDir)$(LibPrefix)hostfxr$(LibSuffix)" DestinationFolder="$(SharedFrameworkPublishDir)\host\fxr\$(HostResolverVersion)" />
<!-- Copy symbols to publish folder -->
<ItemGroup>
<SharedFrameworkSymbols Include="$(PackageSymbolsBinDir)Microsoft.NETCore.App/**/*.pdb" />
<SharedFrameworkSymbols Include="$(PackageSymbolsBinDir)Microsoft.NETCore.App/**/*$(SymbolFileExtension)" />
<SharedFrameworkSymbols Include="$(PackageSymbolsBinDir)Microsoft.NETCore.App/**/*$(CrossGenSymbolExtension)"
Condition="'$(CrossGenSymbolExtension)' != ''" />
</ItemGroup>
<RemoveDir Directories="$(SharedFrameworkPublishSymbolsDir)"
Condition="Exists('$(SharedFrameworkPublishSymbolsDir)')" />
<MakeDir Directories="$(SharedFrameworkPublishSymbolsDir)" />
<Copy SourceFiles="@(SharedFrameworkSymbols)" DestinationFolder="$(SharedFrameworkPublishSymbolsDir)" />
</Target>
<Target Name="GenerateVersionFile"
DependsOnTargets="GetLatestCommitHash">
<!-- Generate .version file -->
<ItemGroup>
<VersionLines Include="$(LatestCommit)" />
<VersionLines Include="$(SharedFrameworkNugetVersion)" />
</ItemGroup>
<WriteLinesToFile
File="$(SharedFrameworkNameAndVersionRoot)\.version"
Lines="@(VersionLines)"
Overwrite="true" />
</Target>
<!-- TODO: Why do we need to have this is M.N.App references the expected version? However,
I have noticed that without this, M.N.App publish results in having an older (1.1.x)
hostpolicy binary.
-->
<Target Name="CopyHostArtifactsToSharedFramework">
<ItemGroup>
<!-- Hostpolicy should be the latest and not the locked version as it is supposed to evolve for -->
<!-- the framework and has a tight coupling with coreclr's API in the framework. -->
<HostArtifacts Include="$(CoreHostOutputDir)\$(HostPolicyBaseName)" />
</ItemGroup>
<Copy SourceFiles="@(HostArtifacts)" DestinationFolder="$(SharedFrameworkNameAndVersionRoot)" />
</Target>
<Target Name="GenerateRuntimeGraph">
<PropertyGroup>
<SharedFrameworkAssetsFile>$(IntermediateOutputRootPath)/framework/project.assets.json</SharedFrameworkAssetsFile>
<SharedFrameworkDepsFile>$(SharedFrameworkNameAndVersionRoot)\$(SharedFrameworkName).deps.json</SharedFrameworkDepsFile>
<RuntimeGraphGeneratorRuntime Condition="'$(OSGroup)'=='Windows_NT'">win</RuntimeGraphGeneratorRuntime>
<RuntimeGraphGeneratorRuntime Condition="'$(OSGroup)'=='OSX'">osx</RuntimeGraphGeneratorRuntime>
<RuntimeGraphGeneratorRuntime Condition="'$(OSGroup)'=='FreeBSD'">freebsd</RuntimeGraphGeneratorRuntime>
<RuntimeGraphGeneratorRuntime Condition="'$(RuntimeGraphGeneratorRuntime)'==''">linux</RuntimeGraphGeneratorRuntime>
</PropertyGroup>
<ItemGroup>
<TrimPkgsFromDeps Include="runtime.$(PackageTargetRid).microsoft.netcore.dotnetapphost" />
<TrimPkgsFromDeps Include="runtime.$(PackageTargetRid).microsoft.netcore.dotnethostresolver" />
<TrimPkgsFromDeps Include="microsoft.netcore.dotnetapphost" />
<TrimPkgsFromDeps Include="microsoft.netcore.dotnethostresolver" />
</ItemGroup>
<ProcessSharedFrameworkDeps AssetsFilePath="$(SharedFrameworkAssetsFile)"
DepsFilePath="$(SharedFrameworkDepsFile)"
PackagesToRemove="@(TrimPkgsFromDeps)"
Runtime="$(RuntimeGraphGeneratorRuntime)"
BuildToolsTaskDir="$(BuildToolsTaskDir)" />
</Target>
<Target Name="RestoreLockedCoreHost">
<PropertyGroup>
<LockedHostSourceRoot>$(MSBuildThisFileDirectory)lockedhost</LockedHostSourceRoot>
<CommonLockedHostArgs>$(CommonProjectArgs) /p:HostResolverVersion=$(HostResolverVersion) /p:HostVersion=$(HostVersion)</CommonLockedHostArgs>
</PropertyGroup>
<RemoveDir Directories="$(CoreHostLockedDir)" />
<!-- Specify a separate 'packages' directory in case we are building an already built version of Microsoft.NETCore.DotNetHost and the $(PackagesDir)
already contains the same version as we are building. (ex. building source-build for `2.0.0` when `2.0.0` has already shipped.
-->
<Exec Command="$(DotnetRestoreCommandNoPackages) --source $(PackageOutputPath) --packages $(SharedFrameworkIntermediatePackagesDir) $(CommonLockedHostArgs)"
WorkingDirectory="$(LockedHostSourceRoot)" />
<Exec Command="$(DotnetToolCommand) publish --no-restore --output $(CoreHostLockedDir) $(CommonLockedHostArgs)"
WorkingDirectory="$(LockedHostSourceRoot)" />
</Target>
</Project>