Skip to content

Conversation

SimaTian
Copy link
Member

We would like to move forward with making MSBuild server default in some scenarios.
Before we do that, we need to dogfood the feature.
Initial testing suggests it works nicely - so far it works in our internal pipelines an on our local dev loop. We're also already dogfooding in aspnetcore for several months.
So sdk is one of the logical next steps we would like to take.

@Copilot Copilot AI review requested due to automatic review settings August 20, 2025 11:08
Copilot

This comment was marked as outdated.

@SimaTian SimaTian requested a review from Copilot August 20, 2025 13:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables MSBuild server functionality for the .NET SDK build process by setting the MSBUILDUSESERVER environment variable to 1. This change is part of dogfooding MSBuild server before making it default in certain scenarios.

  • Sets MSBUILDUSESERVER=1 environment variable in SDK build pipeline templates
  • Enables MSBuild server for both test template execution and main build steps

@SimaTian SimaTian force-pushed the msbuild-12120-enable-server branch from 81b2bd1 to a61619f Compare September 2, 2025 10:41
@baronfel
Copy link
Member

baronfel commented Sep 2, 2025

@SimaTian additional places to add the env var to:

@marcpopMSFT
Copy link
Member

I assume you'll eventually want to turn this on for arcade after flighting it with a few other repos first.

@SimaTian SimaTian requested a review from tmat as a code owner September 22, 2025 11:01
@SimaTian SimaTian requested a review from a team as a code owner September 22, 2025 11:01
@MiYanni
Copy link
Member

MiYanni commented Sep 23, 2025

@SimaTian

Failures

image

TemplateEngine macOS x64

This is a known failure being tracked here: #50948 (comment)

TestBuild Linux x64

Not sure what's going on here. Haven't seen this failure before with RunFileTests.Pack. @jjonescz Any ideas on this test failure?

image

TestBuild macOS arm64

This is a known failure being tracked here: #50784

@echo off
title SDK Build ($RepoRoot)
set DOTNET_CLI_USE_MSBUILD_SERVER=1
set MSBUILDUSESERVER=1
Copy link
Member

@jjonescz jjonescz Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be added to the sdk-build-env.ps1 too which is constructed below.

That might explain why only linux legs are currently failing and windows ones are not.

@echo off
title SDK Build ($RepoRoot)
set DOTNET_CLI_USE_MSBUILD_SERVER=1
set MSBUILDUSESERVER=1
Copy link
Member

@jjonescz jjonescz Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm dogfooding this while investigating the failures that happen in CI. I cannot repro them so far but I noticed something:

When I run

dotnet test ./test/dotnet.Tests/ --filter "FullyQualifiedName~RunFileTests.Pack"

I normally see all the test results in the stdout.

But when I set DOTNET_CLI_USE_MSBUILD_SERVER=1 before running that same command, it seems a separate process is used to run the tests. But the original dotnet test process doesn't show any test outputs. Which also impacts my ability to inspect what is going on...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this while debugging and I agree it is annoying and problematic.
I think I will have to take a look at the way sdk launches the msbuild app for tests - server adds one layer of indirection (e.g. it spawns another process) for the build. There is supposed to be some redirect, but the tests are wired separately from the rest.

public class MSBuildCommand(
    IEnumerable<string> msbuildArgs,
    string? msbuildPath = null
) : MSBuildForwardingApp(MSBuildArgs.AnalyzeMSBuildArguments([..msbuildArgs], CommonOptions.PropertiesOption,

vs

public class MSBuildCommand : TestCommand

so maybe these are working differently?

{
public GivenThatWeWantToPublishIncrementally(ITestOutputHelper log) : base(log)
{
// During the dogfood, we want the MSBuild server on for build of the pipeline. Not for the tests - it breaks outputs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though I cannot repro the failures locally, could the problem with RunFileTests.Pack be that it relies on dotnet/msbuild#12156, i.e., the virtual in-memory project should be available for MSBuild sub-tasks, and that is not working with MSBuild server?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants