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

[release/3.1] Fix use of ilasm during test builds when using a 3.0 SDK #27818

Merged
merged 2 commits into from
Nov 11, 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
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tools": {
"dotnet": "3.0.100-preview6-012264"
"dotnet": "3.0.100"
},
"native-tools": {
"cmake": "3.11.1",
Expand Down
9 changes: 6 additions & 3 deletions init-tools.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ if NOT exist "%BUILD_TOOLS_PATH%\init-tools.cmd" (

:afterbuildtoolsrestore

:: Ask init-tools to also restore ILAsm
set /p ILASMCOMPILER_VERSION=< "%~dp0ILAsmVersion.txt"

echo Initializing BuildTools...
echo Running: "%BUILD_TOOLS_PATH%\init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" >> "%INIT_TOOLS_LOG%"
call "%BUILD_TOOLS_PATH%\init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" "%PACKAGES_DIR%" >> "%INIT_TOOLS_LOG%"
Expand All @@ -117,6 +114,12 @@ if not [%INIT_TOOLS_ERRORLEVEL%]==[0] (
goto :error
)

REM ILasm/ILDasm used to be restored by buildtools. The reference there was a netocreapp2.0, which was prior to our support of linux-musl. We initialize it locally as a 3.0 with the new SDK.
set /p ILASM_VERSION=< "%~dp0ILAsmVersion.txt"
if [%NATIVE_TOOLS_RID%] == [] set NATIVE_TOOLS_RID=win-x64
echo Running: call "%DOTNET_CMD%" build "%~dp0tests\ilasm-restore\ilasm.depproj" --no-cache --packages "%PACKAGES_DIR%" -r "%NATIVE_TOOLS_RID%" /p:ILAsmPackageVersion="%ILASM_VERSION%" /p:ExpectedILAsmPath="%TOOLRUNTIME_DIR%\ilasm" >> "%INIT_TOOLS_LOG%"
call "%DOTNET_CMD%" build "%~dp0tests\ilasm-restore\ilasm.depproj" --no-cache --packages "%PACKAGES_DIR%" -r "%NATIVE_TOOLS_RID%" /p:ILAsmPackageVersion="%ILASM_VERSION%" /p:ExpectedILAsmPath="%TOOLRUNTIME_DIR%\ilasm"

:: Create semaphore file
echo Done initializing tools.
if NOT exist "%BUILD_TOOLS_SEMAPHORE_DIR%" mkdir "%BUILD_TOOLS_SEMAPHORE_DIR%"
Expand Down
15 changes: 8 additions & 7 deletions init-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,8 @@ if [ -z "${__ILASM_RID-}" ]; then
fi

echo "Using RID $__ILASM_RID for BuildTools native tools"

export ILASMCOMPILER_VERSION=$__ILASM_VERSION
export NATIVE_TOOLS_RID=$__ILASM_RID

if [ -n "${DotNetBootstrapCliTarPath-}" ]; then
# Assume ilasm is not in nuget yet when bootstrapping...
unset ILASMCOMPILER_VERSION
fi

# Build tools only supported on x64
if [ "${__PKG_ARCH}" != "x64" ] && [ "${__PKG_ARCH}" != "arm" ]; then
echo "Skipped installing build tools."
Expand All @@ -178,6 +171,14 @@ else
exit 1
fi


if [ ! -n "${DotNetBootstrapCliTarPath-}" ]; then
# Assume ilasm is not in nuget yet when bootstrapping...
# ILasm/ILDasm used to be restored by buildtools. The reference there was a netocreapp2.0, which was prior to our support of linux-musl. We initialize it locally as a 3.0 with the new SDK.
echo "Running: eval $__DOTNET_CMD build ${__scriptpath}/tests/ilasm-restore/ilasm.depproj --no-cache --packages $__PACKAGES_DIR -r $NATIVE_TOOLS_RID -p:ILAsmPackageVersion=$__ILASM_VERSION -p:ExpectedILAsmPath=$__TOOLRUNTIME_DIR/ilasm" >> "$__init_tools_log"
eval "$__DOTNET_CMD" build "${__scriptpath}/tests/ilasm-restore/ilasm.depproj" --no-cache --packages "$__PACKAGES_DIR" -r "$NATIVE_TOOLS_RID" -p:ILAsmPackageVersion="$__ILASM_VERSION" -p:ExpectedILAsmPath="$__TOOLRUNTIME_DIR/ilasm"
fi

echo "Making all .sh files executable under Tools."
# Executables restored with .NET Core 2.0 do not have executable permission flags. https://github.com/NuGet/Home/issues/4424
ls "$__scriptpath/Tools/"*.sh | xargs chmod +x
Expand Down
6 changes: 6 additions & 0 deletions tests/ilasm-restore/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<!--
This project works around a restore issue in buildtools for musl distros. It shouldn't use any
other properties in the test tree. This file prevents any imports.
-->
</Project>
6 changes: 6 additions & 0 deletions tests/ilasm-restore/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<!--
This project works around a restore issue in buildtools for musl distros. It shouldn't use any
other properties in the test tree. This file prevents any imports.
-->
</Project>
30 changes: 30 additions & 0 deletions tests/ilasm-restore/ilasm.depproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- This file is largely a copy of the BuildTools equivalent -->
<PropertyGroup>
<!-- suppress the attempt to copy build output. -->
<CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>

<Target Name="CoreCompile">
<Copy SourceFiles="@(NativeCopyLocalItems)" DestinationFolder="$(ExpectedILAsmPath)" />
</Target>

<!-- Required by Common.Targets -->
<Target Name="CreateManifestResourceNames" />

<PropertyGroup>
<NuGetTargetMoniker>.NETCoreApp,Version=v3.0</NuGetTargetMoniker>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RidSpecificAssets>true</RidSpecificAssets>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETCore.ILAsm" Version="$(ILAsmPackageVersion)" />
<PackageReference Include="Microsoft.NETCore.ILDAsm" Version="$(ILAsmPackageVersion)" />

<!-- ILAsm has a very unfortunate runtime dependency on CoreCLR, so we need to grab that too -->
<!-- https://github.com/dotnet/coreclr/issues/15059 -->
<PackageReference Include="Microsoft.NETCore.Runtime.CoreCLR" Version="$(ILAsmPackageVersion)" />
</ItemGroup>
</Project>