question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improved incremental build/reference assembly support

See original GitHub issue

(This was reported to me offline via email; I’m adding some context.)

MSBuild and the Roslyn compilers use a feature called reference assemblies to attempt to minimize the build impact of changes to referenced assemblies. When the internal implementation of an assembly changes without changes to its public API surface, referencing projects shouldn’t need to rebuild. This feature is turned on by default for projects targeting .NET 5.0+.

This isn’t working for WPF projects, though. As an example, take a small solution with two projects: a library and a WPF app that references the library. Change whitespace in the library and build the solution. Ideally, the library would recompile, the WPF app would not, and the library would just be copied to the output folder of the WPF app.

In the current implementation, the WPF app is always rebuilt. The proximate cause is

Target Name=CoreCompile Project=WpfApp.csproj
    Building target "CoreCompile" completely.
    Output file "obj\Debug\net5.0-windows\WpfApp.dll" does not exist.

That’s happening in

Target Name=CleanupTemporaryTargetAssembly Project=WpfApp.csproj
    Task "Message" skipped, due to false condition; ('$(MSBuildTargetsVerbose)'=='true') was evaluated as (''=='true').
    Delete
    Delete
        Parameters
            Files = obj\Debug\net5.0-windows\WpfApp.dll
        Deleting file "obj\Debug\net5.0-windows\WpfApp.dll".
    Delete

That’s happening because the _wpftmp project builds to the same location.

The _wpftmp project builds because MarkupCompilePass1 tells it to:

_RequireMCPass2ForMainAssembly = True

It’s doing that because it is taking the implementation assembly as an input, through @(ReferencePath).

I think it could use @(ReferencePathWithRefAssemblies) like CoreCompile does.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
rainersigwaldcommented, Oct 6, 2021

Fortunately I think I just hadn’t run the scenario I thought I had. Things seem to be working now with this change:

--- C:\Program Files\dotnet\sdk\5.0.401\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets
+++ private modification
@@ -215,13 +215,13 @@
   ================================================================
                                    MarkupCompilePass1
   ================================================================
   -->
 
   <Target Name="MarkupCompilePass1"
-          DependsOnTargets="$(MarkupCompilePass1DependsOn);SplashScreenValidation"
+          DependsOnTargets="$(MarkupCompilePass1DependsOn);SplashScreenValidation;FindReferenceAssembliesForReferences"
           Condition="'@(Page)' != '' or '@(ApplicationDefinition)' != '' " >
 
         <Message Text="(in) Page: '@(Page)'" Condition="'$(MSBuildTargetsVerbose)'=='true'"/>
         <Message Text="(in) ApplicationDefinition: '@(ApplicationDefinition)'" Condition="'$(MSBuildTargetsVerbose)'=='true'"/>
         <Message Text="(in) Resource: '@(Resource)'" Condition="'$(MSBuildTargetsVerbose)'=='true'"/>
         <Message Text="(in) CodeGenReference: '@(ReferencePath)'" Condition="'$(MSBuildTargetsVerbose)'=='true'"/>
@@ -246,13 +246,13 @@
                PageMarkup="@(Page)"
                ContentFiles="@(Content)"
                AssemblyName="$(AssemblyName)"
                OutputType="$(OutputType)"
                AssemblyVersion="$(AssemblyVersion)"
                AssemblyPublicKeyToken="$(AssemblyPublicKeyToken)"
-               References="@(ReferencePath)"
+               References="@(ReferencePathWithRefAssemblies)"
                RootNamespace="$(RootNamespace)"
                KnownReferencePaths="$(MSBuildBinPath);$(TargetFrameworkDirectory);@(_TargetFrameworkSDKDirectoryItem);@(KnownReferencePaths)"
                AssembliesGeneratedDuringBuild="@(AssembliesGeneratedDuringBuild)"
                AlwaysCompileMarkupFilesInSeparateDomain="$(AlwaysCompileMarkupFilesInSeparateDomain)"
                HostInBrowser="$(HostInBrowser)"
                LocalizationDirectivesToLocFile="$(LocalizationDirectivesToLocFile)"

I think this is too risky for 6.0 GA but it’d be a nice speedup for 6.0.200/VS 17.1 if we could get it . . .

2reactions
pchaurasia14commented, Sep 9, 2022

@czdietrich - Unfortunately, we weren’t able to attend this item for the past releases. We’ll certainly target this for upcoming releases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

LTCG (Link-time code generation)
INCREMENTAL (Optional) Specifies that the linker only applies whole program optimization or link-time code generation (LTCG) to files ...
Read more >
General Performance Boost Tips
Incredibuild employs caching mechanisms on many levels. These caches build over time; therefore, the more you use Incredibuild, the better ...
Read more >
OPT (Optimizations)
You can use /OPT:LBR to optimize the detection of long branch instructions and the placement of intermediate code islands to minimize overall ...
Read more >
Reducing Rust Incremental Compilation Times on macOS
If solving Rust builds were as easy as this, we'd have just done it long ago. We care tremendously about improving compile times....
Read more >
Improve Visual Studio Build Performance
This feature is named Incremental Build and is essential to significantly reduces the number of projects compiled and thus, to achieve most of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found