Skip to content

Commit 8c26e32

Browse files
authored
Fix matching logger path against parent directories (#1917)
Using a regex match with a full path results can result in the regex matching parent directories of the source directory. If the code is being compiled in a subdirectory with a full path that includes `net5.0` (such as `dotnet5.0`), multiple loggers can match. Multiple loggers matching will produce an invalid msbuild command, failing the build. To reproduce: mkdir dotnet5.0 git clone https://github.com/dotnet/source-build cd source-build git checkout master ./build.sh In my case, sourcelink fails to build with this error message: MSBUILD : error MSB1008: Only one project can be specified. Switch: /home/omajid/dotnet5.0/source-build/packages/restored/microsoft.dotnet.arcade.sdk/5.0.0-beta.20426.4/tools/net472/Microsoft.DotNet.Arcade.Sdk.dll Fixes: #1914
1 parent 138b3f7 commit 8c26e32

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

repos/Directory.Build.targets

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@
9393
Condition="'$(EngCommonToolsShFile)' != ''"
9494
Inputs="$(MSBuildProjectFullPath)"
9595
Outputs="$(RepoCompletedSemaphorePath)UpdateBuildToolFramework.complete" >
96+
<!-- Use a relative find in NewText to avoid regex matches with parent directories.
97+
See https://github.com/dotnet/source-build/issues/1914 for details. -->
9698
<ReplaceTextInFile InputFile="$(EngCommonToolsShFile)"
9799
OldText="local logger_path=&quot;$toolset_dir/$_InitializeBuildToolFramework/Microsoft.DotNet.Arcade.Sdk.dll&quot;"
98-
NewText="logger_path=%24%28find &quot;$toolset_dir&quot; -name Microsoft.DotNet.Arcade.Sdk.dll -regex &apos;.*netcoreapp2.1.*\|.*net5.0.*&apos;)" />
100+
NewText="logger_path=&quot;%24toolset_dir&quot;/%24%28cd &quot;$toolset_dir&quot; &amp;&amp; find -name Microsoft.DotNet.Arcade.Sdk.dll -regex &apos;.*netcoreapp2.1.*\|.*net5.0.*&apos;)" />
99101

100102
<WriteLinesToFile File="$(RepoCompletedSemaphorePath)UpdateBuildToolFramework.complete" Overwrite="true" />
101103
</Target>

0 commit comments

Comments
 (0)