From d9f44d298c0d36e3ecdcca36cac8363d5a2b3e96 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Fri, 12 Feb 2021 11:23:06 +0100 Subject: [PATCH 1/2] enforce MSBuild to never used shared compilation and start more than one process by doing that we lower the chances for getting "file in use" exception after re-running a failed build script --- scripts/dotnet.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/dotnet.py b/scripts/dotnet.py index 1025c1af456..57375ab7168 100755 --- a/scripts/dotnet.py +++ b/scripts/dotnet.py @@ -284,7 +284,8 @@ def restore(self, cmdline = [ 'dotnet', 'restore', self.csproj_file, - '--packages', packages_path + '--packages', packages_path, + '/p:UseSharedCompilation=false', '/p:BuildInParallel=false', '/m:1', ] if runtime_identifier: @@ -309,6 +310,7 @@ def build(self, '--configuration', configuration, '--no-restore', "/p:NuGetPackageRoot={}".format(packages_path), + '/p:UseSharedCompilation=false', '/p:BuildInParallel=false', '/m:1', ] if output_to_bindir: @@ -332,6 +334,7 @@ def build(self, '--framework', target_framework_moniker, '--no-restore', "/p:NuGetPackageRoot={}".format(packages_path), + '/p:UseSharedCompilation=false', '/p:BuildInParallel=false', '/m:1', ] if output_to_bindir: @@ -402,7 +405,8 @@ def publish(self, self.csproj_file, '--configuration', configuration, '--output', output_dir, - "/p:NuGetPackageRoot={}".format(packages_path) + "/p:NuGetPackageRoot={}".format(packages_path), + '/p:UseSharedCompilation=false', '/p:BuildInParallel=false', '/m:1' ] if runtime_identifier: cmdline += ['--runtime', runtime_identifier] From fe907ce8885974316fa26402e75a530f7d945b0b Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Mon, 15 Feb 2021 12:17:21 +0100 Subject: [PATCH 2/2] add comments --- scripts/dotnet.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/dotnet.py b/scripts/dotnet.py index 57375ab7168..471b284f3d9 100755 --- a/scripts/dotnet.py +++ b/scripts/dotnet.py @@ -277,7 +277,11 @@ def restore(self, project. Keyword arguments: - packages_path -- The directory to restore packages to. + packages_path -- The directory to restore packages to. + MSBuild arguments used to avoid "process cannot access the file": + /p:UseSharedCompilation=false -- disable shared compilation + /p:BuildInParallel=false -- disable parallel builds + /m:1 -- don't spawn more than a single process ''' if not packages_path: raise TypeError('Unspecified packages directory.')