dotnet / dotnet/msbuild

[Broken Build]: PublishAot=true + NoBuild=true produce binary without EmbeddedResources

Open
#12,712 0 comments 1 reaction 2 assignees Claimed by @SimaTian View on GitHub
Priority:1 triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Issue Description

In certain situations, MSBuild might fail to correctly embed `EmbeddedResource` items with MSBuild 17.14 when `NoBuild=true` is specified.

The easiest way to get that behavior is by using `PublishAot=true`.

The culprit seems to be https://github.com/dotnet/msbuild/pull/10928.
After that PR, `_GenerateCompileInputs` does not add any `EmbeddedResource` to the inputs, see the [attached binlog](https://github.com/user-attachments/files/23267857/msbuild.zip).

### Steps to Reproduce

With the .NET SDK 9.0.306 / MSBuild 17.14:

1. Clone https://github.com/MrJul/repro-publish-nobuild-bug (this is an almost empty console application with a single .resx file).
2. Run `dotnet build -p:PublishAot=true`
3. Run `dotnet publish -p:PublishAot=true -p:NoBuild=true`
4. Run the published executable
5. Notice it fails with a `MissingManifestResourceException`

Reproducible with SDK versions 9.0.300 through 9.0.306, as well as 10.0.100-rc.2.25502.107.
It works without any issue with 9.0.205.

### Expected Behavior

The executable has embedded resources and runs without any issue.

### Actual Behavior

The executable doesn't have any embedded resources and fails at runtime.

### Ask us questions

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.