-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Closed
Copy link
Labels
Description
Describe the bug
A multi-targeting tool project constructs the DotnetToolSettings.xml file at the same location from all target frameworks:
From Microsoft.NET.PackTool.targets
:
<_ToolsSettingsFilePath>$(BaseIntermediateOutputPath)DotnetToolSettings.xml</_ToolsSettingsFilePath>
This leads to a race condition in the build where each target framework wants to write this file to the same location, leading to timing breaks.
In the binlog viewer below, notice how net8.0 and net9.0 both write to the file at the same path:
Here's the full binlog
build.zip
And a github workflow that failed at least twice in a row due to this timing break:
https://github.com/AArnott/DotNetRepoTools/actions/runs/15973577065/job/45052231169?pr=96
To Reproduce
I suspect any csproj with properties like these is vulnerable to it:
<PropertyGroup>
<!-- Multi-target so that the tool will run on the latest runtime on the user's machine.
This is important so that if the user only has an SDK installed that matches the latest runtime version,
we'll be able to find MSBuild via that SDK. -->
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<OutputType>exe</OutputType>
<ToolCommandName>repo</ToolCommandName>
<PackAsTool>True</PackAsTool>
<Description>A CLI tool with commands to help maintain .NET codebases.</Description>
</PropertyGroup>