Skip to content

There is no warning / error when PublishAot is true, but compiler is not restored #34049

Open
@nohwnd

Description

@nohwnd

Describe the bug

I have a project that we want to build with and without NativeAot. I've published it locally for NativeAot by setting /p:PublishAot=true and everything is correctly compiled to native code.

I push the same command to server and there it compiles without a warning, but it is not NativeAot. All my tests pass, and I only noticed this because I was looking specifically for trim warnings, and was checking and printing: Console.WriteLine("Dynamic code supported: " + System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported);

The problem is that locally I have IlcCompiler in my global nuget cache, but on server there is none. Which makes this condition fail:

NoImport: $(ILCompilerTargetsPath) at (1238;3) false condition; 
('$(ILCompilerTargetsPath)' != '' and '$(PublishAot)' == 'true' was evaluated as '' != '' and 'true' == 'true').

I think this is an easy mistake to make. Would it make sense to get an error when PublishAot = true, but the build result would not be NativeAot?

To Reproduce

Have a project targetting net8.0, have .nuget cache populated from previous experimentations with nativeaot.

ILCompilerTargetsPath = C:\Users\me.nuget\packages\microsoft.dotnet.ilcompiler\8.0.0-preview.5.23280.8\build\Microsoft.DotNet.ILCompiler.SingleEntry.targets

Publish the project locally and get native aot exe.

Publish the project on build server and get non-native exe.

Exceptions (if any)

Further technical details

I am on dotnet 8.0.100-preview.5.23303.2, I have binlogs, but they are for internal project so I will have to share them using a differnet channel.

Related to #30091 ?

Metadata

Metadata

Assignees

Labels

Area-NativeAOTNative AOT compilationuntriagedRequest triage from a team member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions