[Microsoft.Build.Traversal] Behavior is differrent, incorrect under net7.0
Closed this issue · 4 comments
We are upgrading the Azure SDK for .NET to target net7.0 and net6.0 TFMs (and net461 on Windows). After changing our global.json to "7.0.100" and setting (effectively) <TargetFrameworks>net7.0;net6.0</TargetFrameworks>
, I've noticed that loggers and properties are not being passed to inner builds.
Currently, we are using Microsoft.Build.Traversal 3.0.23 but even after upgrading to 3.2.0 it still doesn't work.
See Azure/azure-sdk-for-net#32814 (comment) for some details, but where we noticed this was that we pass /p:EnableSourceLink=false
(and a bunch of other properties) but it was failing in our sparse checkout (known separate issue).
For example, in https://github.com/Azure/azure-sdk-for-net, this exact command line exhibits very different behaviors:
net6.0
dotnet test eng/service.proj --filter "(TestCategory!=Manually) & (TestCategory!=Live) & (Placeholder!=DefaultIgnoreMe)" --framework net6.0 --logger "trx;LogFileName=net6.0.trx" --logger:"console;verbosity=normal" -bl:"$PWD\msbuild.binlog" --blame-crash-dump-type full --blame-hang-dump-type full --blame-hang-timeout 100minutes /p:SDKType=all /p:ServiceDirectory=keyvault /p:IncludeSrc=false /p:IncludeSamples=false /p:IncludePerf=false /p:IncludeStress=false /p:RunApiCompat=false /p:InheritDocEnabled=false /p:Configuration=Debug /p:CollectCoverage=false /p:EnableSourceLink=false /p:ProjectListOverrideFile= /p:UseProjectReferenceToAzureClients=false
- Builds only packages under sdk/keyvault/ and those on which they depend e.g., sdk/core/Azure.Core/src/Azure.Core.csproj.
- Doesn't yield errors about invalid repo version (since we use sparse checkouts in some pipelines, which uses repo version 1, which causes Microsoft.Build.Tasks.Git to panic).
net7.0
exact same command line
- Builds all packages under sdk/ (because the filter property isn't being passed down).
- Yields errors because of the Microsoft.Build.Tasks.Git issue hopefully getting fixed in dotnet/sourcelink#772.
I can't get you a binlog because however -bl
is handled in inner builds (or even the outer?) is not taking effect: no binlog is generated under net7.0. It gets generated fine under net6.0 and does contain information about every package (filtered list) built.
Probably the fastest repro would be to:
git clone --no-checkout --filter=tree:0 https://github.com/Azure/azure-sdk-for-net
cd azure-sdk-for-net
git sparse-checkout init
git sparse-checkout set --no-cone '/*' '!/*/' '/eng'
git sparse-checkout add '/*' '!SessionRecords' '/sdk/appconfiguration/**/SessionRecords/*'
git remote add heaths https://github.com/heaths/azure-sdk-for-net
git fetch heaths issue32596
git checkout -b issue32596 FETCH_HEAD
dotnet test eng/service.proj --filter "(TestCategory!=Manually) & (TestCategory!=Live) & (Placeholder!=DefaultIgnoreMe)" --framework net6.0 --logger "trx;LogFileName=net6.0.trx" --logger:"console;verbosity=normal" -bl:msbuild.binlog --blame-crash-dump-type full --blame-hang-dump-type full --blame-hang-timeout 100minutes /p:SDKType=all /p:ServiceDirectory=keyvault /p:IncludeSrc=false /p:IncludeSamples=false /p:IncludePerf=false /p:IncludeStress=false /p:RunApiCompat=false /p:InheritDocEnabled=false /p:Configuration=Debug /p:CollectCoverage=false /p:EnableSourceLink=false /p:ProjectListOverrideFile= /p:UseProjectReferenceToAzureClients=false
Notice that is discovers, restores, and tries to build a bunch of packages. That should only be ~6-8 packages, and will otherwise build successfully if you:
- Change global.json to use "6.0.100" instead (or any 6.0.*).
- Change eng/Directory.Build.Common.props such that
<RequiredTargetFrameworks>net6.0</RequiredTargetFrameworks>
.
I am taking a look...
Oh, and for your other question offline, this does not repro for dotnet build
:
dotnet build eng/service.proj --framework net6.0 -bl:"$PWD\msbuild.binlog" /p:SDKType=all /p:ServiceDirectory=keyvault /p:IncludeSrc=false /p:IncludeSamples=false /p:IncludePerf=false /p:IncludeStress=false /p:RunApiCompat=false /p:InheritDocEnabled=false /p:Configuration=Debug /p:CollectCoverage=false /p:EnableSourceLink=false /p:ProjectListOverrideFile= /p:UseProjectReferenceToAzureClients=false
Appears to be caused by microsoft/vstest#4014