1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-08 03:27:04 +09:00

Move dotnet.cmd/sh helper scripts into the repo root (#672)

* Move dotnet helper scripts to repo root

* Don't swallow InitializeDotNetCli output

* Use temporary file to store sdk location

To avoid a nested process chain in which the inner process then invokes
the host, we instead create a temporary file to store the sdk location.
This commit is contained in:
Viktor Hofer 2019-12-11 21:01:58 +01:00 committed by GitHub
parent 071da4c41a
commit f5957b1bae
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 89 additions and 113 deletions

22
dotnet.cmd Normal file
View file

@ -0,0 +1,22 @@
@echo off
powershell -ExecutionPolicy ByPass -NoProfile -Command "& { . '%~dp0eng\common\tools.ps1'; InitializeDotNetCli $true $true }"
if NOT [%ERRORLEVEL%] == [0] (
echo Failed to install or invoke dotnet... 1>&2
exit /b %ERRORLEVEL%
)
set /p dotnetPath=<%~dp0artifacts\toolset\sdk.txt
:: Clear the 'Platform' env variable for this session, as it's a per-project setting within the build, and
:: misleading value (such as 'MCD' in HP PCs) may lead to build breakage (issue: #69).
set Platform=
:: Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism
set DOTNET_MULTILEVEL_LOOKUP=0
:: Disable first run since we want to control all package sources
set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
call "%dotnetPath%\dotnet.exe" %*

27
dotnet.sh Executable file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
source="${BASH_SOURCE[0]}"
# resolve $SOURCE until the file is no longer a symlink
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"
# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
# Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism
export DOTNET_MULTILEVEL_LOOKUP=0
# Disable first run since we want to control all package sources
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
source $scriptroot/eng/common/tools.sh
InitializeDotNetCli true # Install
__dotnetDir=${_InitializeDotNetCli}
dotnetPath=${__dotnetDir}/dotnet
${dotnetPath} "$@"

View file

@ -98,7 +98,7 @@ function Exec-Process([string]$command, [string]$commandArgs) {
}
}
function InitializeDotNetCli([bool]$install) {
function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
if (Test-Path variable:global:_DotNetInstallDir) {
return $global:_DotNetInstallDir
}
@ -146,6 +146,22 @@ function InitializeDotNetCli([bool]$install) {
}
$env:DOTNET_INSTALL_DIR = $dotnetRoot
if ($createSdkLocationFile) {
# Create a temporary file under the toolset dir and rename it to sdk.txt to avoid races.
do {
$sdkCacheFileTemp = Join-Path $ToolsetDir $([System.IO.Path]::GetRandomFileName())
}
until (!(Test-Path $sdkCacheFileTemp))
Set-Content -Path $sdkCacheFileTemp -Value $dotnetRoot
try {
Rename-Item -Force -Path $sdkCacheFileTemp 'sdk.txt'
} catch {
# Somebody beat us
Remove-Item -Path $sdkCacheFileTemp
}
}
}
# Add dotnet to PATH. This prevents any bare invocation of dotnet in custom

View file

@ -1,13 +0,0 @@
@if not defined _echo @echo off
setlocal
set "DotNetCli=%~dp0..\dotnet.cmd"
set "DependenciesBuildProj=%~dp0..\tests\build.proj"
echo Running: "%DotNetCli%" msbuild "%DependenciesBuildProj%" %*
call "%DotNetCli%" msbuild "%DependenciesBuildProj%" %*
if NOT [%ERRORLEVEL%]==[0] (
exit /b 1
)
exit /b 0

View file

@ -531,7 +531,7 @@ set __MsbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
set __Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr!
REM Build wrappers using the local SDK's msbuild. As we move to arcade, the other builds should be moved away from run.exe as well.
call "%__ProjectDir%\dotnet.cmd" msbuild %__ProjectDir%\tests\src\runtest.proj /nodereuse:false /p:BuildWrappers=true !__Logging! %__msbuildArgs% %TargetsWindowsMsbuildArg% %__SkipFXRestoreArg% %__UnprocessedBuildArgs%
call "%__RepoRootDir%\dotnet.cmd" msbuild %__ProjectDir%\tests\src\runtest.proj /nodereuse:false /p:BuildWrappers=true !__Logging! %__msbuildArgs% %TargetsWindowsMsbuildArg% %__SkipFXRestoreArg% %__UnprocessedBuildArgs%
if errorlevel 1 (
echo %__ErrMsgPrefix%%__MsgPrefix%Error: XUnit wrapper build failed. Refer to the build log files for details:
echo %__BuildLog%

View file

@ -663,7 +663,7 @@ __CrossBuild=0
__DistroRid=""
__DoCrossgen=0
__DoCrossgen2=0
__DotNetCli="$__ProjectDir/dotnet.sh"
__DotNetCli="$__RepoRootDir/dotnet.sh"
__GccBuild=0
__GccMajorVersion=0
__GccMinorVersion=0

View file

@ -656,7 +656,7 @@ 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" /p:BuildArch=%__BuildArch%
call %__RepoRootDir%\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.
@ -706,7 +706,7 @@ if %__BuildCoreLib% EQU 1 (
)
)
set IBCMergeCommand=%__ProjectDir%\dotnet.cmd --roll-forward-on-no-candidate-fx 2 "!IbcMergePath!"
set IBCMergeCommand=%__RepoRootDir%\dotnet.cmd --roll-forward-on-no-candidate-fx 2 "!IbcMergePath!"
REM Merge the optimization data into the source DLL
set NEXTCMD=!IBCMergeCommand! -q -f -delete -mo "!InputAssemblyFile!" !RawOptimizationDataFile!

View file

@ -392,7 +392,7 @@ 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" /p:BuildArch=$__BuildArch
"$__RepoRootDir/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

View file

@ -1,38 +0,0 @@
@if not defined _echo @echo off
setlocal
set "__ProjectDir=%~dp0"
set "__RepoRootDir=%__ProjectDir%..\..\"
:: Clear the 'Platform' env variable for this session, as it's a per-project setting within the build, and
:: misleading value (such as 'MCD' in HP PCs) may lead to build breakage (issue: #69).
set Platform=
:: Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism
set DOTNET_MULTILEVEL_LOOKUP=0
:: Disable first run since we do not need all ASP.NET packages restored.
set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
set PS_DOTNET_INSTALL_SCRIPT=". %__RepoRootDir%eng\common\tools.ps1; InitializeDotNetCli($true)"
set "PS_COMMAND=powershell -NoProfile -ExecutionPolicy unrestricted -Command %PS_DOTNET_INSTALL_SCRIPT%"
echo running: %PS_COMMAND%
for /f "delims=" %%l in ('%PS_COMMAND%') do set "__dotnetDir=%%l"
if NOT [%ERRORLEVEL%] == [0] (
echo Failed to install dotnet using Arcade.
exit /b %ERRORLEVEL%
)
set "dotnetPath=%__dotnetDir%\dotnet.exe"
pushd %~dp0
echo Running: "%dotnetPath%" %*
call "%dotnetPath%" %*
popd
if NOT [%ERRORLEVEL%]==[0] (
exit /b 1
)
exit /b 0

View file

@ -1,34 +0,0 @@
#!/usr/bin/env bash
working_tree_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
__ProjectDir=${working_tree_root}
__RepoRootDir=${working_tree_root}/../..
# Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism
export DOTNET_MULTILEVEL_LOOKUP=0
# Disable first run since we want to control all package sources
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
source ${__RepoRootDir}/eng/common/tools.sh
InitializeDotNetCli
__dotnetDir=${_InitializeDotNetCli}
if [ $? != 0 ]; then
echo "Failed to install dotnet using Arcade"
exit $?
fi
dotnetPath=${__dotnetDir}/dotnet
echo "Running: ${dotnetPath} $@"
${dotnetPath} "$@"
if [ $? -ne 0 ]
then
echo "ERROR: An error occurred in ${dotnetPath} $@. Check logs under $working_tree_root."
exit 1
fi
echo "Command successfully completed."
exit 0

View file

@ -448,7 +448,7 @@ function create_testhost
fi
# Initialize test variables
local dotnetExe=$coreClrSrc/dotnet.sh
local dotnetExe=$coreClrSrc/../../dotnet.sh
local coreClrSrcTestDir=$coreClrSrc/tests
if [ -z $coreClrBinDir ]; then

View file

@ -20,7 +20,7 @@ set "__RootBinDir=%__ProjectDir%\..\artifacts"
set "__LogsDir=%__RootBinDir%\log"
set "__MsbuildDebugLogsDir=%__LogsDir%\MsbuildDebugLogs"
set __ToolsDir=%__ProjectDir%\..\Tools
set "DotNetCli=%__ProjectDir%\..\dotnet.cmd"
set "DotNetCli=%__ProjectDir%\..\..\..\dotnet.cmd"
set __Sequential=
set __msbuildExtraArgs=

View file

@ -59,7 +59,7 @@ function create_testhost
fi
# Initialize test variables
local dotnetExe=$coreClrSrc/dotnet.sh
local dotnetExe=$coreClrSrc/../../dotnet.sh
local coreClrSrcTestDir=$coreClrSrc/tests
if [ -z $coreClrBinDir ]; then

View file

@ -52,14 +52,9 @@ REM === Check if dotnet CLI and necessary directories exist
REM ===
REM =========================================================================================
set __DotNetCmd=%__ThisScriptPath%..\dotnet.cmd
set __DotNetCmd=%__ThisScriptPath%..\..\..\dotnet.cmd
set __CsprojPath=%__ThisScriptPath%\stress_dependencies\stress_dependencies.csproj
if not exist "%__DotNetCmd%" (
echo dotnet.exe does not exist: %__DotNetCmd%
goto Fail
)
REM Create directories needed
if not exist "%__OutputDir%" md "%__OutputDir%"

View file

@ -90,7 +90,7 @@ fi
# This script must be located in coreclr/tests.
scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
dotnet=$"${scriptDir}"/../dotnet.sh
dotnet=$"${scriptDir}"/../../../dotnet.sh
csprojPath="${scriptDir}"/stress_dependencies/stress_dependencies.csproj
if [ ! -e $dotnetCmd ]; then

View file

@ -1,35 +1,36 @@
set CurrentDir=%~dp0
set ProjectDir=%CurrentDir%..\..\..\..\
set RepoRoot=%ProjectDir%..\..\
"%ProjectDir%dotnet.cmd" build /p:__BuildArch=x64 /p:__BuildOS=Windows_NT /p:__BuildType=Checked %ProjectDir%src\tools\r2rdump\R2RDump.csproj
"%ProjectDir%dotnet.cmd" build /p:__BuildArch=x64 /p:__BuildOS=Windows_NT /p:__BuildType=Debug %ProjectDir%src\tools\r2rdump\R2RDump.csproj
"%ProjectDir%dotnet.cmd" build /p:__BuildArch=x86 /p:__BuildOS=Windows_NT /p:__BuildType=Release %ProjectDir%src\tools\r2rdump\R2RDump.csproj
"%ProjectDir%dotnet.cmd" build /p:__BuildArch=x86 /p:__BuildOS=Windows_NT /p:__BuildType=Debug %ProjectDir%src\tools\r2rdump\R2RDump.csproj
"%RepoRoot%dotnet.cmd" build /p:__BuildArch=x64 /p:__BuildOS=Windows_NT /p:__BuildType=Checked %ProjectDir%src\tools\r2rdump\R2RDump.csproj
"%RepoRoot%dotnet.cmd" build /p:__BuildArch=x64 /p:__BuildOS=Windows_NT /p:__BuildType=Debug %ProjectDir%src\tools\r2rdump\R2RDump.csproj
"%RepoRoot%dotnet.cmd" build /p:__BuildArch=x86 /p:__BuildOS=Windows_NT /p:__BuildType=Release %ProjectDir%src\tools\r2rdump\R2RDump.csproj
"%RepoRoot%dotnet.cmd" build /p:__BuildArch=x86 /p:__BuildOS=Windows_NT /p:__BuildType=Debug %ProjectDir%src\tools\r2rdump\R2RDump.csproj
set tests=HelloWorld GcInfoTransitions GenericFunctions MultipleRuntimeFunctions
(for %%a in (%tests%) do (
"%ProjectDir%dotnet.cmd" build /p:__BuildArch=x64 /p:__BuildOS=Windows_NT /p:__BuildType=Checked "%ProjectDir%tests\src\readytorun\r2rdump\files\%%a.csproj"
"%RepoRoot%dotnet.cmd" build /p:__BuildArch=x64 /p:__BuildOS=Windows_NT /p:__BuildType=Checked "%ProjectDir%tests\src\readytorun\r2rdump\files\%%a.csproj"
%ProjectDir%artifacts\tests\Windows_NT.x64.Checked\Tests\Core_Root\crossgen /readytorun /platform_assemblies_paths %ProjectDir%artifacts\tests\Windows_NT.x64.Checked\Tests\Core_Root /out %%a.ni.dll %ProjectDir%artifacts\tests\Windows_NT.x64.Checked\readytorun\r2rdump\files\%%a\%%a.dll
"%ProjectDir%dotnet.cmd" %ProjectDir%artifacts\bin\coreclr\Windows_NT.x64.Checked\netcoreapp2.0\R2RDump.dll --in %%a.ni.dll --out %ProjectDir%tests\src\readytorun\r2rdump\files\Windows_NT.x64.Checked\%%a.xml -x -v --ignoreSensitive
"%RepoRoot%dotnet.cmd" %ProjectDir%artifacts\bin\coreclr\Windows_NT.x64.Checked\netcoreapp2.0\R2RDump.dll --in %%a.ni.dll --out %ProjectDir%tests\src\readytorun\r2rdump\files\Windows_NT.x64.Checked\%%a.xml -x -v --ignoreSensitive
))
(for %%a in (%tests%) do (
"%ProjectDir%dotnet.cmd" build /p:__BuildArch=x64 /p:__BuildOS=Windows_NT /p:__BuildType=Debug "%ProjectDir%tests\src\readytorun\r2rdump\files\%%a.csproj"
"%RepoRoot%dotnet.cmd" build /p:__BuildArch=x64 /p:__BuildOS=Windows_NT /p:__BuildType=Debug "%ProjectDir%tests\src\readytorun\r2rdump\files\%%a.csproj"
%ProjectDir%artifacts\tests\Windows_NT.x64.Debug\Tests\Core_Root\crossgen /readytorun /platform_assemblies_paths %ProjectDir%artifacts\tests\Windows_NT.x64.Debug\Tests\Core_Root /out %%a.ni.dll %ProjectDir%artifacts\tests\Windows_NT.x64.Debug\readytorun\r2rdump\files\%%a\%%a.dll
"%ProjectDir%dotnet.cmd" %ProjectDir%artifacts\bin\coreclr\Windows_NT.x64.Debug\netcoreapp2.0\R2RDump.dll --in %%a.ni.dll --out %ProjectDir%tests\src\readytorun\r2rdump\files\Windows_NT.x64.Debug\%%a.xml -x -v --ignoreSensitive
"%RepoRoot%dotnet.cmd" %ProjectDir%artifacts\bin\coreclr\Windows_NT.x64.Debug\netcoreapp2.0\R2RDump.dll --in %%a.ni.dll --out %ProjectDir%tests\src\readytorun\r2rdump\files\Windows_NT.x64.Debug\%%a.xml -x -v --ignoreSensitive
))
(for %%a in (%tests%) do (
"%ProjectDir%dotnet.cmd" build /p:__BuildArch=x86 /p:__BuildOS=Windows_NT /p:__BuildType=Release "%ProjectDir%tests\src\readytorun\r2rdump\files\%%a.csproj"
"%RepoRoot%dotnet.cmd" build /p:__BuildArch=x86 /p:__BuildOS=Windows_NT /p:__BuildType=Release "%ProjectDir%tests\src\readytorun\r2rdump\files\%%a.csproj"
%ProjectDir%artifacts\tests\Windows_NT.x86.Release\Tests\Core_Root\crossgen /readytorun /platform_assemblies_paths %ProjectDir%artifacts\tests\Windows_NT.x86.Release\Tests\Core_Root /out %%a.ni.dll %ProjectDir%artifacts\tests\Windows_NT.x86.Release\readytorun\r2rdump\files\%%a\%%a.dll
"%ProjectDir%dotnet.cmd" %ProjectDir%artifacts\bin\coreclr\Windows_NT.x86.Release\netcoreapp2.0\R2RDump.dll --in %%a.ni.dll --out %ProjectDir%tests\src\readytorun\r2rdump\files\Windows_NT.x86.Release\%%a.xml -x -v --ignoreSensitive
"%RepoRoot%dotnet.cmd" %ProjectDir%artifacts\bin\coreclr\Windows_NT.x86.Release\netcoreapp2.0\R2RDump.dll --in %%a.ni.dll --out %ProjectDir%tests\src\readytorun\r2rdump\files\Windows_NT.x86.Release\%%a.xml -x -v --ignoreSensitive
))
(for %%a in (%tests%) do (
"%ProjectDir%dotnet.cmd" build /p:__BuildArch=x86 /p:__BuildOS=Windows_NT /p:__BuildType=Debug "%ProjectDir%tests\src\readytorun\r2rdump\files\%%a.csproj"
"%RepoRoot%dotnet.cmd" build /p:__BuildArch=x86 /p:__BuildOS=Windows_NT /p:__BuildType=Debug "%ProjectDir%tests\src\readytorun\r2rdump\files\%%a.csproj"
%ProjectDir%artifacts\tests\Windows_NT.x86.Debug\Tests\Core_Root\crossgen /readytorun /platform_assemblies_paths %ProjectDir%artifacts\tests\Windows_NT.x86.Debug\Tests\Core_Root /out %%a.ni.dll %ProjectDir%artifacts\tests\Windows_NT.x86.Debug\readytorun\r2rdump\files\%%a\%%a.dll
"%ProjectDir%dotnet.cmd" %ProjectDir%artifacts\bin\coreclr\Windows_NT.x86.Debug\netcoreapp2.0\R2RDump.dll --in %%a.ni.dll --out %ProjectDir%tests\src\readytorun\r2rdump\files\Windows_NT.x86.Debug\%%a.xml -x -v --ignoreSensitive
"%RepoRoot%dotnet.cmd" %ProjectDir%artifacts\bin\coreclr\Windows_NT.x86.Debug\netcoreapp2.0\R2RDump.dll --in %%a.ni.dll --out %ProjectDir%tests\src\readytorun\r2rdump\files\Windows_NT.x86.Debug\%%a.xml -x -v --ignoreSensitive
))
COPY /Y %ProjectDir%tests\src\readytorun\r2rdump\files\Windows_NT.x64.Checked\*.xml %ProjectDir%tests\src\readytorun\r2rdump\files\Windows_NT.x64.Release\