Skip to content

Commit

Permalink
Kill .net 4.7.2 version of sharpmake and some related refactoring
Browse files Browse the repository at this point in the history
List of changes contained in this commit:
- Enable msbuild binary log and store them as artifacts in github. Compile time is the same.
- Code signing is now disabled on macos when compiling using CI.
- Kill all mono related scripts
- Clean ifdefed code.
- No longer pass --framework argument to dotnet.exe when compiling on macos/linux. That way build is always the same on all platforms.
I think this code was different because of differences for 4.7.x on those platforms

Note: Found out that msbuild is badly handling builds where --framework is specified but only a single framework version is specified in csproj files.
It then builds twice some projects in parallel and this can cause build errors.

Removing this unifies how all platforms are handled but also workaround the msbuild bug.
  • Loading branch information
jspelletier committed Nov 8, 2022
1 parent 8a21230 commit 8c215bf
Show file tree
Hide file tree
Showing 20 changed files with 93 additions and 513 deletions.
58 changes: 16 additions & 42 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-2019, windows-2022]
framework: [net472, net5.0]
framework: [net5.0]
configuration: [debug, release]

steps:
Expand All @@ -30,46 +30,36 @@ jobs:
if: runner.os == 'Windows'
run: .\bootstrap.bat Sharpmake.Main.sharpmake.cs ${{ matrix.configuration }} ${{ matrix.framework }}

- name: Bootstrap.dotnet.sh ${{ matrix.configuration }}
- name: Bootstrap.sh ${{ matrix.configuration }}
if: runner.os != 'Windows'
shell: bash
run: ./bootstrap.dotnet.sh Sharpmake.Main.sharpmake.cs ${{ matrix.configuration }} ${{ matrix.framework }}
run: ./bootstrap.sh Sharpmake.Main.sharpmake.cs ${{ matrix.configuration }} ${{ matrix.framework }}

- name: CompileSharpmake.bat ${{ matrix.configuration }}
if: runner.os == 'Windows'
run: .\CompileSharpmake.bat Sharpmake.sln "${{ matrix.configuration }}" "Any CPU"

- name: CompileSharpmake.dotnet.sh ${{ matrix.configuration }}
- name: CompileSharpmake.sh ${{ matrix.configuration }}
if: runner.os != 'Windows'
run: ./CompileSharpmake.dotnet.sh Sharpmake.sln ${{ matrix.configuration }} "Any CPU" ${{ matrix.framework }}
run: ./CompileSharpmake.sh Sharpmake.sln ${{ matrix.configuration }} "Any CPU" ${{ matrix.framework }}

- name: GenerateMdbFiles.bat
if: runner.os == 'Windows' && matrix.framework == 'net472' && matrix.configuration == 'release'
run: .\GenerateMdbFiles.bat

- name: UnitTest ${{ matrix.framework }} - NUnit
if: runner.os == 'Windows' && matrix.framework == 'net472'
run: |
nuget install NUnit.ConsoleRunner -Version 3.12.0 -OutputDirectory tmp/pkg
tmp/pkg/NUnit.ConsoleRunner.3.12.0/tools/nunit3-console.exe tmp/unittests/${{ matrix.configuration }}/${{ matrix.framework }}/Sharpmake.UnitTests.dll
- name: Store MSBuild binary logs
if: always()
uses: actions/upload-artifact@v3
with:
name: sharpmake-msbuild-logs-${{ github.sha }}
path: tmp/msbuild

- name: UnitTest ${{ matrix.framework }} - dotnet test
if: runner.os == 'Windows' && matrix.framework != 'net472' # TODO: fix the tests on mac and linux and remove the first part of the if
if: runner.os == 'Windows' # TODO: fix the tests on mac and linux and remove the first part of the if
run: dotnet test --no-build --no-restore tmp/projects/sharpmake.unittests/Sharpmake.UnitTests.csproj --framework ${{ matrix.framework }} --configuration ${{ matrix.configuration }}

- name: RegressionTest
if: runner.os == 'Windows'
run: python regression_test.py --sharpmake_exe "tmp\bin\${{ matrix.configuration }}\${{ matrix.framework }}\Sharpmake.Application.exe"

- name: Upload sharpmake .net framework release binaries
if: matrix.configuration == 'release' && matrix.framework == 'net472'
uses: actions/upload-artifact@v3
with:
name: 'Sharpmake-${{ matrix.framework }}-${{ github.sha }}'
path: tmp/bin/release/${{ matrix.framework }}

- name: Upload sharpmake ${{ matrix.framework }} ${{ runner.os }}-release binaries
if: matrix.configuration == 'release' && matrix.framework != 'net472'
if: matrix.configuration == 'release'
uses: actions/upload-artifact@v3
with:
name: 'Sharpmake-${{ matrix.framework }}-${{ runner.os }}-${{ github.sha }}'
Expand All @@ -82,21 +72,13 @@ jobs:
fail-fast: false
matrix:
os: [windows-2019] # only windows for now, but ideally should be all. TODO: add windows-2022
framework: [net472, net5.0]
framework: [net5.0]

steps:
- name: Checkout the repo
uses: actions/checkout@v3.1.0

- name: Download sharpmake .net framework release binaries
if: matrix.framework == 'net472'
uses: actions/download-artifact@v3
with:
name: 'Sharpmake-${{ matrix.framework }}-${{ github.sha }}'
path: tmp/bin/release/${{ matrix.framework }}

- name: Download sharpmake ${{ matrix.framework }} ${{ runner.os }}-release binaries
if: matrix.framework != 'net472'
uses: actions/download-artifact@v3
with:
name: 'Sharpmake-${{ matrix.framework }}-${{ runner.os }}-${{ github.sha }}'
Expand All @@ -113,7 +95,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-2019] # TODO: add windows-2022
framework: [net472, net5.0]
framework: [net5.0]
configuration: [debug, release]

env:
Expand All @@ -125,22 +107,14 @@ jobs:
- name: Checkout the repo
uses: actions/checkout@v3.1.0

- name: Download sharpmake .net framework release binaries
if: matrix.framework == 'net472'
uses: actions/download-artifact@v3
with:
name: 'Sharpmake-${{ matrix.framework }}-${{ github.sha }}'
path: tmp/bin/release/${{ matrix.framework }}

- name: Download sharpmake ${{ matrix.framework }} ${{ runner.os }}-release binaries
if: matrix.framework != 'net472'
uses: actions/download-artifact@v3
with:
name: 'Sharpmake-${{ matrix.framework }}-${{ runner.os }}-${{ github.sha }}'
path: tmp/bin/release/${{ matrix.framework }}

- name: chmod +x on Sharpmake.Application
if: runner.os != 'Windows' && matrix.framework != 'net472'
if: runner.os != 'Windows'
run: chmod +x $SHARPMAKE_UNIX_EXE

- name: CompileCommandDatabase ${{ matrix.configuration }}
Expand Down
6 changes: 4 additions & 2 deletions CompileSharpmake.bat
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ if not defined VSMSBUILDCMD (
goto error
)

SET MSBUILDLOGFILE="tmp/msbuild/windows/msbuild_%~2.binlog"

echo MSBuild batch path: !VSMSBUILDCMD!
call !VSMSBUILDCMD!
if %errorlevel% NEQ 0 goto error
Expand Down Expand Up @@ -54,7 +56,7 @@ goto success
:BuildSharpmakeDotnet
echo Compiling %~1 in "%~2|%~3"...

set DOTNET_BUILD_CMD=dotnet build "%~1" -nologo -v m -c "%~2"
set DOTNET_BUILD_CMD=dotnet build "%~1" -nologo -v m -c "%~2" -bl:%MSBUILDLOGFILE%
echo %DOTNET_BUILD_CMD%
%DOTNET_BUILD_CMD%
set ERROR_CODE=%errorlevel%
Expand All @@ -69,7 +71,7 @@ goto success
:BuildSharpmakeMSBuild
echo Compiling %~1 in "%~2|%~3"...

set MSBUILD_CMD=msbuild -clp:Summary -t:rebuild -restore -p:RestoreUseStaticGraphEvaluation=true "%~1" /nologo /verbosity:m /p:Configuration="%~2" /p:Platform="%~3" /maxcpucount /p:CL_MPCount=%NUMBER_OF_PROCESSORS%
set MSBUILD_CMD=msbuild -bl:%MSBUILDLOGFILE% -clp:Summary -t:rebuild -restore -p:RestoreUseStaticGraphEvaluation=true "%~1" /nologo /verbosity:m /p:Configuration="%~2" /p:Platform="%~3" /maxcpucount /p:CL_MPCount=%NUMBER_OF_PROCESSORS%
echo %MSBUILD_CMD%
%MSBUILD_CMD%
set ERROR_CODE=%errorlevel%
Expand Down
48 changes: 0 additions & 48 deletions CompileSharpmake.dotnet.sh

This file was deleted.

30 changes: 19 additions & 11 deletions CompileSharpmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@
# $1: Project/Solution to build
# $2: Target(Normally should be Debug or Release)
# $3: Platform(Normally should be "Any CPU" for sln and AnyCPU for a csproj)
# if none are passed, defaults to building Sharpmake.sln in Debug|Any CPU
# if none are passed, defaults to building Sharpmake.sln in Debug|Any CPU for all frameworks

function BuildSharpmake {
solutionPath=$1
configuration=$2
platform=$3
echo Compiling $solutionPath in "${configuration}|${platform}"...
MSBUILD_CMD="msbuild -t:build -restore -p:RestoreUseStaticGraphEvaluation=true \"${solutionPath}\" /nologo /v:m /p:Configuration=${configuration} /p:Platform=\"${platform}\""
echo $MSBUILD_CMD
eval $MSBUILD_CMD

# Note: Disabling code signing on mac as otherwise we get such error:
# error NETSDK1177: Failed to sign apphost with error code 0:
# See https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/6.0/apphost-generated-for-macos
# We can't disable UseAppHost as otherwise we won't have any executable. Disabling signing is not ideal but works for our case.
MSBUILDLOGFILE="tmp/msbuild/${ImageOS}${platform}/msbuild_${configuration}.binlog"
BUILD_CMD="dotnet build -nologo --verbosity m -bl:\"${MSBUILDLOGFILE}\" -p:UseAppHost=true /p:_EnableMacOSCodeSign=false \"$solutionPath\" --configuration \"$configuration\""
echoMessage="Compiling $solutionPath in ${configuration}|${platform}"

echo $echoMessage
echo $BUILD_CMD
eval $BUILD_CMD
if [ $? -ne 0 ]; then
echo ERROR: Failed to compile $solutionPath in "${configuration}|${platform}".
echo ERROR: Failed to compile $solutionPath in "${configuration}|${platform}|".
exit 1
fi
}
Expand All @@ -24,11 +32,11 @@ set -e

CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

which msbuild > /dev/null
MSBUILD_FOUND=$?
if [ $MSBUILD_FOUND -ne 0 ]; then
echo "MSBuild not found"
exit $MSBUILD_FOUND
which dotnet > /dev/null
DOTNET_FOUND=$?
if [ $DOTNET_FOUND -ne 0 ]; then
echo "dotnet not found, see https://dotnet.microsoft.com/download"
exit $DOTNET_FOUND
fi

SOLUTION_PATH=${1:-"${CURRENT_DIR}/Sharpmake.sln"}
Expand Down
70 changes: 0 additions & 70 deletions GenerateMdbFiles.bat

This file was deleted.

15 changes: 3 additions & 12 deletions Sharpmake.Application/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,10 @@ private static int Main()
{
if (CommandLine.ContainParameter("breakintodebugger"))
{
#if NETFRAMEWORK
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
Console.WriteLine("Debugger requested. Please attach a debugger and press ENTER to continue");
while (Console.ReadKey(true).Key != ConsoleKey.Enter)
{
System.Windows.Forms.MessageBox.Show("Debugger requested. Please attach a debugger and press OK");
}
else
#endif
{
Console.WriteLine("Debugger requested. Please attach a debugger and press ENTER to continue");
while (Console.ReadKey(true).Key != ConsoleKey.Enter)
{
Console.WriteLine("Press ENTER to continue");
}
Console.WriteLine("Press ENTER to continue");
}
Debugger.Break();
}
Expand Down
Loading

0 comments on commit 8c215bf

Please sign in to comment.