Skip to content

Commit 136353a

Browse files
[One .NET] fix parallel .sln builds (#5435)
Fixes: #5280 A test has been randomly failing with: (CoreCompile target) -> CSC : error CS2012: Cannot open 'C:\a\1\s\bin\TestRelease\temp\SolutionBuildSeveralProjects\Lib6\obj\Debug\Lib6.dll' for writing -- 'The process cannot access the file 'C:\a\1\s\bin\TestRelease\temp\SolutionBuildSeveralProjects\Lib6\obj\Debug\Lib6.dll' because it is being used by another process.' I could reproduce this by putting `[Repeat(10)]` on the test. We shouldn't commit this change, since the test took 5+ minutes. The problem happens when: * Build a `.sln` with two Android head projects that reference library projects. * Use `msbuild -m:4` to build with multiple MSBuild nodes. * One of the head projects is running `<Csc/>` of a referenced project at the same time another. The two `<Csc/>` calls can only occur because of the way we have inner builds set up for `$(RuntimeIdentifier)` in 51fb93e. One project is building the referenced library normally, while another is doing an inner build for a `$(RuntimeIdentifier)`. We don't really want `<Csc/>` to compile things *at all* in an inner build. It should just be "finding" paths to assemblies for each `$(RuntimeIdentifier)` and not doing actual work. Let's set `$(SkipCompilerExecution)` to `true` for the inner build: * https://github.com/dotnet/roslyn/blob/4929b2e60abbdbb6cbe72c856d6f370c8cf13b35/src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets#L132 * https://github.com/dotnet/project-system/blob/e217c5fc9f5ec06f593f74762a3bf4d750475a67/docs/well-known-project-properties.md#skipcompilerexecution-bool This property is set during design-time builds in Visual Studio, so it should be something we can rely on here. I *think* this solved the problem, as I was unable to reproduce it anymore after a few tries. It's possible it didn't, though!
1 parent 17e13bc commit 136353a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ _ResolveAssemblies MSBuild target.
5151
<_AdditionalProperties>
5252
_ComputeFilesToPublishForRuntimeIdentifiers=true;
5353
AppendRuntimeIdentifierToOutputPath=true;
54+
SkipCompilerExecution=true;
5455
_OuterIntermediateAssembly=@(IntermediateAssembly);
5556
_OuterOutputPath=$(OutputPath);
5657
_OuterIntermediateOutputPath=$(IntermediateOutputPath);

0 commit comments

Comments
 (0)