msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

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

Open MrJul opened this issue 2 months ago • 0 comments

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.

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

MrJul avatar Oct 31 '25 18:10 MrJul