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

Commit fd44c0f

Browse files
authored
[release/3.1] Fix use of ilasm during test builds when using a 3.0 SDK (#27818)
* Add fix for restore of ilasm The restore logic in buildtools tried to use a netcoreapp2.1 TFM for Linux-musl. This ended up restoring Linux-x64 binaries which then broke the test build. This change works around this by saving a copy of the depproj that BuildTools used into the tree and restore it as a 3.0 app manually in init-tools on our side of the build. * Change to a 3.0 SDK for servicing
1 parent 816d9ee commit fd44c0f

File tree

6 files changed

+57
-11
lines changed

6 files changed

+57
-11
lines changed

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"tools": {
3-
"dotnet": "3.0.100-preview6-012264"
3+
"dotnet": "3.0.100"
44
},
55
"native-tools": {
66
"cmake": "3.11.1",

init-tools.cmd

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ if NOT exist "%BUILD_TOOLS_PATH%\init-tools.cmd" (
105105

106106
:afterbuildtoolsrestore
107107

108-
:: Ask init-tools to also restore ILAsm
109-
set /p ILASMCOMPILER_VERSION=< "%~dp0ILAsmVersion.txt"
110-
111108
echo Initializing BuildTools...
112109
echo Running: "%BUILD_TOOLS_PATH%\init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" >> "%INIT_TOOLS_LOG%"
113110
call "%BUILD_TOOLS_PATH%\init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" "%PACKAGES_DIR%" >> "%INIT_TOOLS_LOG%"
@@ -117,6 +114,12 @@ if not [%INIT_TOOLS_ERRORLEVEL%]==[0] (
117114
goto :error
118115
)
119116

117+
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.
118+
set /p ILASM_VERSION=< "%~dp0ILAsmVersion.txt"
119+
if [%NATIVE_TOOLS_RID%] == [] set NATIVE_TOOLS_RID=win-x64
120+
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%"
121+
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"
122+
120123
:: Create semaphore file
121124
echo Done initializing tools.
122125
if NOT exist "%BUILD_TOOLS_SEMAPHORE_DIR%" mkdir "%BUILD_TOOLS_SEMAPHORE_DIR%"

init-tools.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,8 @@ if [ -z "${__ILASM_RID-}" ]; then
153153
fi
154154

155155
echo "Using RID $__ILASM_RID for BuildTools native tools"
156-
157-
export ILASMCOMPILER_VERSION=$__ILASM_VERSION
158156
export NATIVE_TOOLS_RID=$__ILASM_RID
159157

160-
if [ -n "${DotNetBootstrapCliTarPath-}" ]; then
161-
# Assume ilasm is not in nuget yet when bootstrapping...
162-
unset ILASMCOMPILER_VERSION
163-
fi
164-
165158
# Build tools only supported on x64
166159
if [ "${__PKG_ARCH}" != "x64" ] && [ "${__PKG_ARCH}" != "arm" ]; then
167160
echo "Skipped installing build tools."
@@ -178,6 +171,14 @@ else
178171
exit 1
179172
fi
180173

174+
175+
if [ ! -n "${DotNetBootstrapCliTarPath-}" ]; then
176+
# Assume ilasm is not in nuget yet when bootstrapping...
177+
# 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.
178+
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"
179+
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"
180+
fi
181+
181182
echo "Making all .sh files executable under Tools."
182183
# Executables restored with .NET Core 2.0 do not have executable permission flags. https://github.com/NuGet/Home/issues/4424
183184
ls "$__scriptpath/Tools/"*.sh | xargs chmod +x
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
<!--
3+
This project works around a restore issue in buildtools for musl distros. It shouldn't use any
4+
other properties in the test tree. This file prevents any imports.
5+
-->
6+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
<!--
3+
This project works around a restore issue in buildtools for musl distros. It shouldn't use any
4+
other properties in the test tree. This file prevents any imports.
5+
-->
6+
</Project>

tests/ilasm-restore/ilasm.depproj

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<!-- This file is largely a copy of the BuildTools equivalent -->
3+
<PropertyGroup>
4+
<!-- suppress the attempt to copy build output. -->
5+
<CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
6+
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
7+
</PropertyGroup>
8+
9+
<Target Name="CoreCompile">
10+
<Copy SourceFiles="@(NativeCopyLocalItems)" DestinationFolder="$(ExpectedILAsmPath)" />
11+
</Target>
12+
13+
<!-- Required by Common.Targets -->
14+
<Target Name="CreateManifestResourceNames" />
15+
16+
<PropertyGroup>
17+
<NuGetTargetMoniker>.NETCoreApp,Version=v3.0</NuGetTargetMoniker>
18+
<TargetFramework>netcoreapp3.0</TargetFramework>
19+
<RidSpecificAssets>true</RidSpecificAssets>
20+
</PropertyGroup>
21+
22+
<ItemGroup>
23+
<PackageReference Include="Microsoft.NETCore.ILAsm" Version="$(ILAsmPackageVersion)" />
24+
<PackageReference Include="Microsoft.NETCore.ILDAsm" Version="$(ILAsmPackageVersion)" />
25+
26+
<!-- ILAsm has a very unfortunate runtime dependency on CoreCLR, so we need to grab that too -->
27+
<!-- https://github.com/dotnet/coreclr/issues/15059 -->
28+
<PackageReference Include="Microsoft.NETCore.Runtime.CoreCLR" Version="$(ILAsmPackageVersion)" />
29+
</ItemGroup>
30+
</Project>

0 commit comments

Comments
 (0)