dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.95k stars 4.65k forks source link

apphost.exe not created for TestTrimming=true + TestNativeAot=true #102632

Closed steveharter closed 3 months ago

steveharter commented 3 months ago

Env:

.NET SDKs installed:
  9.0.100-preview.3.24204.13 [C:\git\ComponentModel\.dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.0-preview.3.24172.13 [C:\git\ComponentModel\.dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.0-preview.3.24172.9 [C:\git\ComponentModel\.dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 9.0.0-preview.3.24175.3 [C:\git\ComponentModel\.dotnet\shared\Microsoft.WindowsDesktop.App]

Repro:

build.cmd -s clr.aot+libs+libs.tests -rc release -lc release -c release /p:TestAssemblies=false /p:TestTrimming=true /p:TestNativeAot=true

Result: a bunch of errors like this:

C:\git\ComponentModel\.dotnet\sdk\9.0.100-preview.3.24204.13\Microsoft.Common.CurrentVersion.targets(5270,5): error MSB3030: Could not copy the file C:\git\ComponentModel\artifacts\bin\trimmingTests\projects\System.Text.Json.TrimmingTests\IsReflectionEnabledByDefaultFalse\win-x64\obj\Release\net9.0\win-x64\apphost.exe" because it was not found. [C:\git\ComponentModel\artifacts\bin\trimmingTests\projects\System.Text.Json.TrimmingTests\IsReflectionEnabledByDefaultFalse\win-x64\project.csproj]

The apphost.exe file does not exist in the directory; the directory exists however.

This worked for me 2-3 weeks ago.

MichalStrehovsky commented 3 months ago

What tests are you trying to run exactly? /p:TestNativeAot=true is a modifier for libraries unit test to build with native AOT. But this is passing /p:TestAssemblies=false, so it will not build libraries unit tests. Did you mean to pass /p:TestAssemblies=false /p:RunNativeAotTestApps=true instead?

steveharter commented 3 months ago

I am trying to run the trimming tests on a NativeAot build.

MichalStrehovsky commented 3 months ago

/p:RunNativeAotTestApps=true is the option to use then - do not pass /p:TestTrimming=true or /p:TestNativeAot=true

MichalStrehovsky commented 3 months ago

I assume this is resolved (/p:RunNativeAotTestApps=true is how it runs in the CI so it should work).