git: fed755e222a5 - main - devel/msbuild: Avoid MSB1008 build error

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Wed, 09 Aug 2023 13:04:26 UTC
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=fed755e222a5c6fba13458265e0c0378de139046

commit fed755e222a5c6fba13458265e0c0378de139046
Author:     Marcin Cieślak <saper@saper.info>
AuthorDate: 2023-08-05 23:55:13 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-08-09 13:01:14 +0000

    devel/msbuild: Avoid MSB1008 build error
    
    The following error:
    
    ============= MSBuild command =============
    /big/ports/usr/ports/devel/msbuild/work/msbuild-0.06/build/../artifacts/mono-msbuild/msbuild "/big/ports/usr/ports/devel/msbuild/work/msbuild-0.06/build/Toolset.proj" /t:restore /m /clp:Summary /warnaserror /v:minimal /bl:"/big/ports/usr/ports/devel/msbuild/work/msbuild-0.06/build/../artifacts/Release-MONO/log/Toolset.binlog"
    ===========================================
    Microsoft (R) Build Engine version 15.8.38.37692 (xplat-master/3c930fa8 Tue May  8 12:36:23 EDT 2018) for Mono
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    MSBUILD : error MSB1008: Only one project can be specified.
    Switch: /m
    
    can be fixed by making sure the /m is given the parameter
    (number of CPUs to use in parallel).
    
    MSBuild does not seem to parallelize builds currently, but
    this fixes the error.
    
    PR:             272961
    Approved by:    portmgr (build fix blanket)
---
 devel/msbuild/Makefile                        |  9 +++++++--
 devel/msbuild/files/patch-Directory.Build.rsp |  6 ++++++
 devel/msbuild/files/patch-build_build.sh      | 13 +++++++++++--
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/devel/msbuild/Makefile b/devel/msbuild/Makefile
old mode 100644
new mode 100755
index 202008202cc7..3dbbaace866c
--- a/devel/msbuild/Makefile
+++ b/devel/msbuild/Makefile
@@ -15,17 +15,17 @@ LICENSE_FILE=	${WRKSRC}/LICENSE
 
 BUILD_DEPENDS=	bash:shells/bash
 
+USES=		mono:nuget shebangfix
+
 NUGET_FEEDS=	DOTNET_CORE NUGET ROSLYN ROSLYN_TOOLS SYMREADER_CONVERTER
 NUGET_LAYOUT=	dotnet
 
-USES=		mono:nuget shebangfix
 USE_GITHUB=	yes
 GH_ACCOUNT=	mono
 GH_TAGNAME=	0.06
 SHEBANG_FILES=	*.sh artifacts/mono-msbuild/msbuild build.sh build/*.sh
 
 MAKE_ENV=	GIT_COMMIT=3c930fa8721935cf0e381fd349f6f50cf2bc223d
-MAKE_JOBS_UNSAFE=MSBuild has not implemented concurrent builds on non Windows platforms
 ALL_TARGET=	all-mono
 TEST_TARGET=	test-mono
 
@@ -33,6 +33,11 @@ post-extract:
 	${MKDIR} ${WRKSRC}/artifacts
 	${MV} ${WRKDIR}/msbuild ${WRKSRC}/artifacts/mono-msbuild
 
+pre-configure:
+	${REINPLACE_CMD} -e s/%%MAKE_JOBS_NUMBER%%/${MAKE_JOBS_NUMBER}/ \
+		${WRKSRC}/build/build.sh \
+		${WRKSRC}/Directory.Build.rsp
+
 do-build:
 	(cd ${WRKSRC}; \
 		${SETENV} ${MAKE_ENV} ./build/build.sh -host mono -configuration Release -skipTests build)
diff --git a/devel/msbuild/files/patch-Directory.Build.rsp b/devel/msbuild/files/patch-Directory.Build.rsp
new file mode 100644
index 000000000000..f842758065a3
--- /dev/null
+++ b/devel/msbuild/files/patch-Directory.Build.rsp
@@ -0,0 +1,6 @@
+--- Directory.Build.rsp.orig	2018-05-02 18:19:31 UTC
++++ Directory.Build.rsp
+@@ -1 +1 @@
+-/verbosity:minimal /m /clp:Summary
+\ No newline at end of file
++/verbosity:minimal /m:%%MAKE_JOBS_NUMBER%% /clp:Summary
diff --git a/devel/msbuild/files/patch-build_build.sh b/devel/msbuild/files/patch-build_build.sh
index 3d3055138ea2..065406ac069b 100644
--- a/devel/msbuild/files/patch-build_build.sh
+++ b/devel/msbuild/files/patch-build_build.sh
@@ -1,4 +1,4 @@
---- build/build.sh.orig	2018-06-25 18:50:41 UTC
+--- build/build.sh.orig	2023-08-06 19:14:14 UTC
 +++ build/build.sh
 @@ -151,7 +151,7 @@ function ExitIfError {
    then
@@ -9,12 +9,21 @@
      then
        StopProcesses
      fi
+@@ -297,7 +297,7 @@ function InstallRepoToolset {
+   if [ ! -d "$RepoToolsetBuildProj" ]
+   then
+     ToolsetProj="$ScriptRoot/Toolset.proj"
+-    CallMSBuild $(QQ $ToolsetProj) /t:restore /m /clp:Summary /warnaserror /v:$verbosity $logCmd $properties
++    CallMSBuild $(QQ $ToolsetProj) /t:restore /m:%%MAKE_JOBS_NUMBER%% /clp:Summary /warnaserror /v:$verbosity $logCmd $properties
+   fi
+ }
+ 
 @@ -343,7 +343,7 @@ function Build {
  
    local logCmd=$(GetLogCmd Build)
  
 -  commonMSBuildArgs="/m /clp:Summary /v:$verbosity /p:Configuration=$configuration /p:SolutionPath=$(QQ $MSBuildSolution) /p:CIBuild=$ci /p:DisableNerdbankVersioning=$dotnetBuildFromSource"
-+  commonMSBuildArgs="/m /clp:Summary /v:$verbosity /p:Configuration=$configuration /p:SolutionPath=$(QQ $MSBuildSolution) /p:CIBuild=$ci /p:DisableNerdbankVersioning=true"
++  commonMSBuildArgs="/m:%%MAKE_JOBS_NUMBER%% /clp:Summary /v:$verbosity /p:Configuration=$configuration /p:SolutionPath=$(QQ $MSBuildSolution) /p:CIBuild=$ci /p:DisableNerdbankVersioning=true"
  
    # Only enable warnaserror on CI runs.
    if $ci