Skip to content

[main] Source code updates from dotnet/msbuild - #7406

Merged
ViktorHofer merged 14 commits into
mainfrom
darc-main-13f75a3c-5b66-4df6-ab28-772f22bf583e
Jul 2, 2026
Merged

ViktorHofer merged 14 commits into
mainfrom
darc-main-13f75a3c-5b66-4df6-ab28-772f22bf583e

Conversation

@dotnet-maestro

@dotnet-maestro dotnet-maestro Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Note

This is a codeflow update. It may contain both source code changes from
the source repo
as well as dependency updates. Learn more here.

This pull request brings the following source code changes

From https://github.com/dotnet/msbuild

Diff the source with this PR branch
darc vmr diff --name-only https://github.com/dotnet/msbuild:0d172d97d0d7de3c1d4d8d9c7d2b0257c9089930..https://github.com/dotnet/dotnet:darc-main-13f75a3c-5b66-4df6-ab28-772f22bf583e

@dotnet-maestro

Copy link
Copy Markdown
Contributor Author

Note

PRs from original repository included in this codeflow update:

💡 You may consult the FAQ for more information or tag @dotnet/prodconsvcs for assistance.

@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team June 26, 2026 02:12
@lewing

lewing commented Jun 26, 2026 •

Copy link
Copy Markdown
Member

SB_Offline Failure Analysis

The SB_CentOSStream10_Offline_CurrentSourceBuiltSdk_x64 failure appears to be caused by a regression in msbuild PR dotnet/msbuild#14079 ("Make property functions and reflection-heavy paths trim-compatible"), which is included in this flow PR.

Symptom: runtime's Directory.Build.targets fires an error target claiming TargetOS='linux' is not lowercase - even though it is.

Suspected root cause: The new FindPublicMethodBySignature in LateBindExecute matches String.Equals(String, String) when types are all typeof(string), bypassing the CoerceArguments path that previously parsed "StringComparison.InvariantCulture" as an enum. This causes the condition to evaluate incorrectly.

Filed: dotnet/msbuild#14190

This PR should not be merged until the msbuild regression is resolved.

/cc @dotnet/msbuild-maintainers

@lewing

lewing commented Jun 26, 2026

Copy link
Copy Markdown
Member

dotnet/msbuild#14191

@dotnet-maestro

Copy link
Copy Markdown
Contributor Author

Note

PRs from original repository included in this codeflow update:

💡 You may consult the FAQ for more information or tag @dotnet/prodconsvcs for assistance.

ViktorHofer pushed a commit to dotnet/msbuild that referenced this pull request Jun 29, 2026
…calls (#14191)

## Summary

`FindPublicMethodBySignature` (introduced in #14079) uses
`_receiverType.GetMethods()` without binding flags, which returns all
public methods including static ones. When resolving an instance call
like `String.Equals` with types `[string, string]`, it incorrectly
matches the **static** `String.Equals(String, String)` overload instead
of falling through to `CoerceArguments` which would parse the enum
string argument (`"StringComparison.InvariantCulture"`) correctly.

The old `Type.GetMethod(name, bindingFlags, null, types, null)`
respected `BindingFlags.Instance` and excluded static methods, so it
returned null and correctly fell through to enum coercion.

## Fix

Pass `_bindingFlags` to `GetMethods()` so it filters by instance/static
correctly, matching the behavior of the replaced code.

## Reproduction

The bug breaks any MSBuild condition using instance methods with enum
parameters passed as strings. For example, runtime's
`Directory.Build.targets`:
```xml
Condition="!$(TargetOS.Equals($(TargetOS.ToLower()), StringComparison.InvariantCulture))"
```

This fires an error claiming `TargetOS='linux'` is not lowercase,
because `String.Equals("linux", "StringComparison.InvariantCulture")`
(static, ordinal comparison) returns `false`.

Reproduced locally by building MSBuild from commit 161f9ea and running
against a minimal test project. Fix verified.

## Impact

This regression blocks the msbuild flow PR to the VMR
(dotnet/dotnet#7406) — the `SB_CentOSStream10_Offline` leg fails because
it's the first consumer of the newly-built MSBuild.

Fixes #14190

---------

Co-authored-by: Copilot <[email protected]>
@dotnet-maestro

Copy link
Copy Markdown
Contributor Author

This pull request only contains source updates from https://github.com/dotnet/msbuild between commits 33d17672fac4c26656a201774f9894dff51a4e78 and f795830904f855e65ef5bb47cc33bba363b4b7a5.

@akoeplinger

Copy link
Copy Markdown
Member

looks like building the analyzer caused some prebuilts:

/__w/1/s/eng/finish-source-only.proj(141,5): error : Prebuilt packages are not allowed in source-only builds.
/__w/1/s/eng/finish-source-only.proj(141,5): error : 
/__w/1/s/eng/finish-source-only.proj(141,5): error : Detected 11 prebuilt package(s):
/__w/1/s/eng/finish-source-only.proj(141,5): error :   - Microsoft.CodeAnalysis.Analyzers.3.11.0
/__w/1/s/eng/finish-source-only.proj(141,5): error :   - Microsoft.CodeAnalysis.CSharp.Workspaces.4.12.0
/__w/1/s/eng/finish-source-only.proj(141,5): error :   - Microsoft.CodeAnalysis.CSharp.4.12.0
/__w/1/s/eng/finish-source-only.proj(141,5): error :   - Microsoft.CodeAnalysis.Workspaces.Common.4.12.0
/__w/1/s/eng/finish-source-only.proj(141,5): error :   - System.Composition.AttributedModel.8.0.0
/__w/1/s/eng/finish-source-only.proj(141,5): error :   - System.Composition.Convention.8.0.0
/__w/1/s/eng/finish-source-only.proj(141,5): error :   - System.Composition.Hosting.8.0.0
/__w/1/s/eng/finish-source-only.proj(141,5): error :   - System.Composition.Runtime.8.0.0
/__w/1/s/eng/finish-source-only.proj(141,5): error :   - System.Composition.TypedParts.8.0.0
/__w/1/s/eng/finish-source-only.proj(141,5): error :   - System.Composition.8.0.0
/__w/1/s/eng/finish-source-only.proj(141,5): error :   - System.IO.Pipelines.8.0.0
/__w/1/s/eng/finish-source-only.proj(141,5): error : 
/__w/1/s/eng/finish-source-only.proj(141,5): error : For detailed usage information, see: /__w/1/s/artifacts/log/Release/prebuilt-annotated-usage.xml
/__w/1/s/eng/finish-source-only.proj(141,5): error : 
/__w/1/s/eng/finish-source-only.proj(141,5): error : See https://aka.ms/dotnet/prebuilts for guidance on what prebuilts are and how to eliminate them.

@ViktorHofer

ViktorHofer commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

msbuild depends on roslyn when building source only: https://github.com/dotnet/dotnet/blob/main/repo-projects/msbuild.proj#L13
If the roslyn version that is targeted doesn't matter and can be latest then we can just consume the previously-source-built artifacts (by defining the dependencies accordingly in Version.Details.xml). cc @dotnet/source-build

All the dependencies are compile-time only:

image

@ViktorHofer

Copy link
Copy Markdown
Member

@baronfel

@baronfel

Copy link
Copy Markdown
Member

@ViktorHofer I don't think we have very hard roslyn dependencies here - it should be able to be latest for source build.

I'd expect this to only matter for running the analyzer on the source-build SDK itself - end users of a source-built SDK would instead prefer to use the package from NuGet.org, yeah?

@dotnet-maestro

dotnet-maestro Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

This pull request only contains source updates from https://github.com/dotnet/msbuild between commits 33d17672fac4c26656a201774f9894dff51a4e78 and b2bc777aa3afa4660ee77c78af5ab133aee52d94.

@ViktorHofer

Copy link
Copy Markdown
Member

Producing the package when building msbuild from source is just so that you don't have condition its usage out when building other repositories source-only. The package that will eventually reach nuget.org (when we decide to make it a shipping asset) will come from msbuild's main vertical (win-x64) same as other packages like Microsoft.Build.Framework.

If we would ever decide to put the analyzer inbox into the msbuild shipping assets in the SDK then that should be fine either as the compiler would be latest there as well (for pretty much all scenarios except design-time afaik).

So yes, previously-source-built-artifacts (PSB) is very likely the way to go here. As noted above that means defining the dependencies in msbuild's Version.Details.xml and Version.Details.props files.

@dotnet-maestro

dotnet-maestro Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Note

PRs from original repository included in this codeflow update:

💡 You may consult the FAQ for more information or tag @dotnet/prodconsvcs for assistance.

@dotnet-maestro

dotnet-maestro Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

This pull request only contains source updates from https://github.com/dotnet/msbuild between commits 33d17672fac4c26656a201774f9894dff51a4e78 and 0d172d97d0d7de3c1d4d8d9c7d2b0257c9089930.

…n.Details for source-build

Cherry-pick of dotnet/msbuild#14247 (commit e6072821c1) into src/msbuild to validate the source-build prebuilt fix in the VMR before the msbuild PR merges. Declares Microsoft.CodeAnalysis.CSharp/.CSharp.Workspaces (4.12.0) and Microsoft.CodeAnalysis.Analyzers (3.11.0) in eng/Version.Details.xml (empty Sha) so source-build redirects them to the live source-built Roslyn, avoiding the prebuilt package violation from src/TaskAnalyzer.

Co-authored-by: Copilot <[email protected]>
@ViktorHofer

ViktorHofer commented Jul 2, 2026 •

Copy link
Copy Markdown
Member

@mthalman IIRC you solved similar analyzer <--> compiler issues in the past in other repositories. Can you please take a look at the failure and recommend a path forward? The issue right now is that we defined roslyn dependencies in msbuild's Version.Details.xml which makes the analyzers come from PSB (with a 5.10.0.0 assembly version) while the compiler is older (5.8.0.0).

Do we need to somehow flow the PSB version in and use that?

AlesProkop and others added 2 commits July 2, 2026 15:54
…d Version.Details for source-build"

This reverts commit 5730288.
…4209)

Remove src/TaskAnalyzer/TaskAnalyzer.csproj from MSBuild.SourceBuild.slnf. Building the analyzer in source-build pulls Roslyn analyzer packages that are either prebuilt violations or (once redirected to source-built Roslyn) reference a newer compiler than the bootstrap compiler (CS9057). Backing out #14209 in the VMR unblocks codeflow; the analyzer source-build support will be revisited with the source-build team. This revert will flow back to dotnet/msbuild.

Co-authored-by: Copilot <[email protected]>
@AlesProkop

Copy link
Copy Markdown
Member

Reverted dotnet/msbuild#14209 to unblock.

@ViktorHofer
ViktorHofer enabled auto-merge (squash) July 2, 2026 15:39
@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team July 2, 2026 15:39
@ViktorHofer
ViktorHofer merged commit 1b8bdee into main Jul 2, 2026
15 of 16 checks passed
@ViktorHofer
ViktorHofer deleted the darc-main-13f75a3c-5b66-4df6-ab28-772f22bf583e branch July 2, 2026 16:36
adammcclure pushed a commit to adammcclure/dotnet that referenced this pull request Jul 7, 2026
[main] Source code updates from nuget/nuget.client


 - Fix CS8602/CS8600 in TemplateEngine NuGet helpers after nuget.client dotnet#7406

NuGet/NuGet.Client PR dotnet#7406 ("Enable nullable for NuGet.Protocol
repository abstractions") changed SourceRepository.GetResourceAsync<T>
to return Task<T?>, matching the long-standing XML doc contract
("Null if the resource does not exist"). Consumers in sdk's
TemplateEngine NuGet helpers were storing the result in non-nullable
locals and dereferencing immediately, producing CS8600/CS8602 under
nullable-enabled compilation with TreatWarningsAsErrors=true.

Mirror the same pattern nuget.client now uses internally
(SourceRepository.GetFeedType): throw InvalidOperationException if a
provider cannot produce the requested resource, then proceed with a
non-null value.

Fixed 4 call sites across 2 files:
  src/Cli/Microsoft.TemplateEngine.Cli/NuGet/NugetApiManager.cs
    - GetResourceAsync<PackageMetadataResource>
    - GetResourceAsync<PackageSearchResource>
  test/TemplateEngine/Microsoft.TemplateEngine.TestHelper/PackageManager.cs
    - GetResourceAsync<FindPackageByIdResource>
    - GetResourceAsync<PackageMetadataResource>

Co-authored-by: Copilot <[email protected]>

 - Fix CS8600/CS8602/CS8618 in NugetPackProvider after nuget.client dotnet#7406

Repository.GetResource<T>() is now annotated to return T? (matching the
documented null-on-missing behavior). The TemplateSearch.TemplateDiscovery
tool dereferences the result and stores it in a non-nullable field, so the
build fails with CS8600/CS8602/CS8618. Throw InvalidOperationException
when the source does not provide the requested resource, matching the
pattern used in NugetApiManager.cs and PackageManager.cs (and mirroring
nuget.client's own internal SourceRepository.GetFeedType adoption).

Co-authored-by: Copilot <[email protected]>

 - Fix CS8600 in NugetPackProvider.GetPackageInfoAsync after nuget.client dotnet#7406

GetResourceAsync<PackageMetadataResource> now returns Task<T?> — add null
check with InvalidOperationException, matching the pattern used elsewhere.

Co-authored-by: Copilot <[email protected]>
mmitche pushed a commit to mmitche/dotnet that referenced this pull request Jul 16, 2026
…t#6927)

[release/10.0.4xx] Source code updates from nuget/nuget.client


 - Fix CS8602/CS8600 in TemplateEngine NuGet helpers after nuget.client dotnet#7406

NuGet/NuGet.Client PR dotnet#7406 ("Enable nullable for NuGet.Protocol
repository abstractions") changed SourceRepository.GetResourceAsync<T>
to return Task<T?>, matching the long-standing XML doc contract
("Null if the resource does not exist"). Consumers in sdk's
TemplateEngine NuGet helpers were storing the result in non-nullable
locals and dereferencing immediately, producing CS8600/CS8602 under
nullable-enabled compilation with TreatWarningsAsErrors=true.

Mirror the same pattern nuget.client now uses internally
(SourceRepository.GetFeedType): throw InvalidOperationException if a
provider cannot produce the requested resource, then proceed with a
non-null value.

Fixed 4 call sites across 2 files:
  src/Cli/Microsoft.TemplateEngine.Cli/NuGet/NugetApiManager.cs
    - GetResourceAsync<PackageMetadataResource>
    - GetResourceAsync<PackageSearchResource>
  test/TemplateEngine/Microsoft.TemplateEngine.TestHelper/PackageManager.cs
    - GetResourceAsync<FindPackageByIdResource>
    - GetResourceAsync<PackageMetadataResource>

Co-authored-by: Copilot <[email protected]>
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.

5 participants