Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Packaging for crossgen2 as a framework dependent application. #27296

Merged
merged 9 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,16 @@ if %__BuildCoreLib% EQU 1 (

if "%__BuildManagedTools%" == "1" (
echo %__MsgPrefix%Publishing crossgen2...
call %__ProjectDir%\dotnet.cmd publish --self-contained -r win-%__BuildArch% -c %__BuildType% -o "%__BinDir%\crossgen2" "%__ProjectDir%\src\tools\crossgen2\crossgen2\crossgen2.csproj"
call %__ProjectDir%\dotnet.cmd publish --self-contained -r win-%__BuildArch% -c %__BuildType% -o "%__BinDir%\crossgen2" "%__ProjectDir%\src\tools\crossgen2\crossgen2\crossgen2.csproj" /p:BuildArch=%__BuildArch%

if not !errorlevel! == 0 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: Failed to build crossgen2.
echo !__BuildLog!
echo !__BuildWrn!
echo !__BuildErr!
exit /b !errorlevel!
)

copy /Y "%__BinDir%\clrjit.dll" "%__BinDir%\crossgen2\clrjitilc.dll"
copy /Y "%__BinDir%\jitinterface.dll" "%__BinDir%\crossgen2\jitinterface.dll"
)
Expand Down
8 changes: 7 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,13 @@ build_CoreLib()

if [[ "$__BuildManagedTools" -eq "1" ]]; then
echo "Publishing crossgen2 for $__DistroRid"
"$__ProjectRoot/dotnet.sh" publish --self-contained -r $__DistroRid -c $__BuildType -o "$__BinDir/crossgen2" "$__ProjectRoot/src/tools/crossgen2/crossgen2/crossgen2.csproj"
"$__ProjectRoot/dotnet.sh" publish --self-contained -r $__DistroRid -c $__BuildType -o "$__BinDir/crossgen2" "$__ProjectRoot/src/tools/crossgen2/crossgen2/crossgen2.csproj" /p:BuildArch=$__BuildArch

local exit_code=$?
if [ $exit_code != 0 ]; then
echo "${__ErrMsgPrefix}Failed to build crossgen2."
exit $exit_code
fi

if [ "$__HostOS" == "OSX" ]; then
cp "$__BinDir/libclrjit.dylib" "$__BinDir/crossgen2/libclrjitilc.dylib"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.Build.Traversal">
<ItemGroup>
<!-- identity project, runtime specific projects are included by props above -->
<Project Include="$(MSBuildProjectName).pkgproj" />
</ItemGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove(builds.targets))" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />

<PropertyGroup Condition="'$(PackageTargetRuntime)' == ''">
<IsLineupPackage Condition="'$(IsLineupPackage)' == ''">true</IsLineupPackage>
</PropertyGroup>

<Import Condition="'$(_packageTargetOSGroup)' != ''" Project="$(MSBuildThisFileDirectory)runtime.$(_packageTargetOSGroup).$(MSBuildProjectName).props" />

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />

<PropertyGroup>
<!-- We're publishing crossgen2 as framework dependent application in the runtime package for now since we only have
two simple scenarios we want to support in the short term: win_x64 to win_x64 and linux_x64 to linux_x64 compilations.
Once we have more complex targets, especially cross-platform and cross-architecture, crossgen2 should move to its own
package, and become a self-contained package.
-->
<Crossgen2RuntimeConfigContents>
{
"runtimeOptions": {
"tfm": "netcoreapp3.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "5.0.0-alpha1.0"
}
}
}
</Crossgen2RuntimeConfigContents>
<Crossgen2RuntimeConfigFile>$(ArtifactsObjDir)crossgen2\crossgen2.runtimeconfig.json</Crossgen2RuntimeConfigFile>
</PropertyGroup>

<ItemGroup>
<ArchitectureSpecificToolFile Include="$(Crossgen2RuntimeConfigFile)" />
</ItemGroup>

<Target Name="WriteCrossgen2RuntimeConfig" BeforeTargets="GetPackageFiles">
<!-- Emit the runtime config json file that will be packaged with crossgen2 -->
<WriteLinesToFile File="$(Crossgen2RuntimeConfigFile)" Lines="$(Crossgen2RuntimeConfigContents)" Overwrite="true" WriteOnlyWhenDifferent="true" />
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\crossgen2" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\crossgen2.dll" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\ILCompiler*.dll" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\Microsoft.DiaSymReader.dll" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\System.CommandLine.dll" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\libclrjitilc.so" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\libjitinterface.so" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\crossgen2.exe" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\crossgen2.dll" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\ILCompiler*.dll" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\Microsoft.DiaSymReader.dll" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\System.CommandLine.dll" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\clrjitilc.dll" />
<ArchitectureSpecificToolFile Include="$(BinDir)crossgen2\jitinterface.dll" />
</ItemGroup>
</Project>
11 changes: 8 additions & 3 deletions src/.nuget/descriptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@
"CommonTypes": [ ]
},
{
"Name": "Microsoft.NETCore.Native",
"Description": "Native shims for .NET Core runtime",
"CommonTypes": [ ]
"Name": "Microsoft.NETCore.Native",
"Description": "Native shims for .NET Core runtime",
"CommonTypes": [ ]
},
{
"Name": "Microsoft.NETCore.Crossgen2",
"Description": "The .NET Crossgen2 compiler.",
"CommonTypes": [ ]
}
]
4 changes: 4 additions & 0 deletions src/.nuget/packages.builds
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<ProjectReference Include="Microsoft.NETCore.ILDAsm\Microsoft.NETCore.ILDAsm.builds" />
</ItemGroup>

<ItemGroup Condition="'$(BuildArch)'=='x64' And ('$(__BuildOS)' == 'Windows_NT' Or '$(__BuildOS)' == 'Linux')">
<ProjectReference Include="Microsoft.NETCore.Crossgen2\Microsoft.NETCore.Crossgen2.builds" />
</ItemGroup>

<!-- Generate a version.txt file we include in our packages
The InitializeSourceControlInformationFromSourceControlManager is part of Microsoft.Build.Tasks.Git
and is responsible for setting SourceRevisionId -->
Expand Down
1 change: 0 additions & 1 deletion src/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<ProjectReference Condition="'$(BuildManagedTools)' == 'true'" Include="tools/runincontext/runincontext.csproj" />
<ProjectReference Condition="'$(BuildManagedTools)' == 'true'" Include="tools/r2rdump/R2RDump.csproj" />
<ProjectReference Condition="'$(BuildManagedTools)' == 'true'" Include="tools/ReadyToRun.SuperIlc/ReadyToRun.SuperIlc.csproj" />
<ProjectReference Condition="'$(BuildManagedTools)' == 'true'" Include="tools/crossgen2/crossgen2/crossgen2.csproj" />
<ProjectReference Include="System.Private.CoreLib\System.Private.CoreLib.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<TargetFramework>netstandard1.3</TargetFramework>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<Platforms>x64;x86</Platforms>
<PlatformTargets Condition="'$(BuildArch)' != ''">$(BuildArch)</PlatformTargets>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

<!-- We're binplacing these into an existing publish layout so that F5 build in VS updates
the same bits tests expect to see in bin/crossgen2. That way we never need to wonder which
binaries are up to date and which are stale. -->
<OutputPath>$(BinDir)/crossgen2</OutputPath>
<GenerateDependencyFile>false</GenerateDependencyFile>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<DefineConstants>READYTORUN;$(DefineConstants)</DefineConstants>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<Platforms>x64;x86</Platforms>
<PlatformTargets Condition="'$(BuildArch)' != ''">$(BuildArch)</PlatformTargets>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

<!-- We're binplacing these into an existing publish layout so that F5 build in VS updates
the same bits tests expect to see in bin/crossgen2. That way we never need to wonder which
binaries are up to date and which are stale. -->
<OutputPath>$(BinDir)/crossgen2</OutputPath>
<GenerateDependencyFile>false</GenerateDependencyFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<TargetFramework>netstandard1.3</TargetFramework>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<Platforms>x64;x86</Platforms>
<PlatformTargets Condition="'$(BuildArch)' != ''">$(BuildArch)</PlatformTargets>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

<!-- We're binplacing these into an existing publish layout so that F5 build in VS updates
the same bits tests expect to see in bin/crossgen2. That way we never need to wonder which
binaries are up to date and which are stale. -->
<OutputPath>$(BinDir)/crossgen2</OutputPath>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we leave the conditioned OutputPath in the other projects (like in crossgen2.csproj)?

Copy link
Author

@fadimounir fadimounir Oct 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for those. Building the main crossgen2 project takes care of putting these dependent files in the correct place (one of the scenarios I tested from VS)

<GenerateDependencyFile>false</GenerateDependencyFile>
</PropertyGroup>
<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/tools/crossgen2/crossgen2/crossgen2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
<TargetFramework>netcoreapp3.0</TargetFramework>
<NoWarn>8002,NU1701</NoWarn>
<Platforms>x64;x86</Platforms>
<PlatformTargets Condition="'$(BuildArch)' != ''">$(BuildArch)</PlatformTargets>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

<!-- We're binplacing these into an existing publish layout so that F5 build in VS updates
the same bits tests expect to see in bin/crossgen2. That way we never need to wonder which
binaries are up to date and which are stale. -->
<OutputPath>$(BinDir)/crossgen2</OutputPath>
<OutputPath Condition="'$(BuildingInsideVisualStudio)' == 'true'">$(BinDir)/crossgen2</OutputPath>
<GenerateDependencyFile>false</GenerateDependencyFile>
<GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
Expand Down