Skip to content

Overbuild caused by PackageReference support #5448

Closed
@rainersigwald

Description

@rainersigwald

The _wpftmp build inside a normal project is built with a global property set: $(_WpfTempProjectNuGetFilePathNoExt). It also now runs ResolveProjectReferences by default. This combines to cause overbuild of the referenced projects, because MSBuild treats projects as distinct when they have different global properties.

This can be observed in build output:

dotnet build --no-restore -bl
Microsoft (R) Build Engine version 17.0.0-preview-21477-04+3a1e456fe for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\dotnet\sdk\6.0.100-rc.2.21478.25\MSBuild.dll -bl -consoleloggerparameters:Summary -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\6.0.100-rc.2.21478.25\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\6.0.100-rc.2.21478.25\dotnet.dll -maxcpucount -verbosity:m .\wpf_incremental.sln
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  Library -> S:\play\wpf_incremental\Library\bin\Debug\net5.0\Library.dll
  Library -> S:\play\wpf_incremental\Library\bin\Debug\net5.0\Library.dll
  WpfApp -> S:\play\wpf_incremental\WpfApp\bin\Debug\net5.0-windows\WpfApp.dll

Note the doubled Library -> S:\play\wpf_incremental\Library\bin\Debug\net5.0\Library.dll: that project is building twice.

The global property for the _wpftmp project is set here:

// Disable conflicting Arcade SDK workaround that imports NuGet props/targets
Hashtable globalProperties = new Hashtable(1);
globalProperties["_WpfTempProjectNuGetFilePathNoExt"] = "";

Timeline:

  1. Workaround for WPF temp project not importing NuGet props/targets files arcade#1581 introduced $(_WpfTempProjectNuGetFilePathNoExt) to .NET's Arcade SDK.
  2. Support PackageReferences in WPF projects #3585 introduced $(IncludePackageReferencesDuringMarkupCompilation) (defaulted to false). This introduced this race condition.
  3. [release/5.0] Support Source Generators in WPF projects #3846 backported it to .NET 5.0 SDKs. This included ee91876 that unconditionally set _WpfTempProjectNuGetFilePathNoExt to empty.
  4. Opt into IncludePackageReferencesDuringMarkupCompilation sdk#15465 turned $(IncludePackageReferencesDuringMarkupCompilation) on by default in the SDK.
  5. Revert 'Opt into IncludePackageReferencesDuringMarkupCompilation' sdk#15695 turned it off again, so this isn't noticeable in the default configurations under .NET SDK 5.0.yxx .
  6. Make source generator and package reference support opt-out (on by default) #4089 flipped the default in WPF.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions