- 
                Notifications
    You must be signed in to change notification settings 
- Fork 561
[nativeaot] fix project builds on Windows #9710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
                
     Merged
            
            
          Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    
              
                    dellis1972
  
              
              approved these changes
              
                  
                    Jan 27, 2025 
                  
              
              
            
            
| This fails on CI, but works locally... The  | 
| Odd, I have  On CI,  Then I see a non-escaped, non-closed quote?!?  | 
| /azp run | 
| Azure Pipelines successfully started running 1 pipeline(s). | 
ab7f020    to
    ad59c69      
    Compare
  
    
              
                    jonathanpeppers
  
              
              commented
              
                  
                    Jan 28, 2025 
                  
              
              
            
            
      Comment on lines
    
      26
     to 
      27
    
  
  | - script: echo "##vso[task.prependpath]$(Agent.ToolsDirectory)" | ||
| displayName: add $(Agent.ToolsDirectory) to path | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 2fa7954, we got Android projects *building* for NativeAOT. However, this didn't work at all on Windows. Reviewing how NativeAOT's MSBuild targets are setup, they expect various tooling to be available in `%PATH%`. To fix this: * Create a new `<SetNdkPathForIlc/>` MSBuild task. * That simply sets the Android NDK "bin" directory to `%PATH%`. NativeAOT apps now successfully build (and run) on Windows. I also updated an integration test to verify this. Unfortunately, we still have to set `$(DisableUnsupportedError)` or we will get the message: D:\.nuget\packages\microsoft.dotnet.ilcompiler\10.0.0-alpha.1.25067.10\build\Microsoft.NETCore.Native.Publish.targets(61,5): error : Cross-OS native compilation is not supported. Please use the appropriate OS-specific target. A future change might be needed here, or it might be fine to for the Android workload to set this property: * https://github.com/dotnet/runtime/blob/ea4a404ef8890f265780f798e7668d4710259e03/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets#L61-L62
ad59c69    to
    aa96dfe      
    Compare
  
    
  
      Sign up for free
      to subscribe to this conversation on GitHub.
      Already have an account?
      Sign in.
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
In 2fa7954, we got Android projects building for NativeAOT. However, this didn't work at all on Windows.
Reviewing how NativeAOT's MSBuild targets are setup, they expect various tooling to be available in
%PATH%.To fix this:
Create a new
<SetNdkPathForIlc/>MSBuild task.That simply sets the Android NDK "bin" directory to
%PATH%.NativeAOT apps now successfully build (and run) on Windows. I also updated an integration test to verify this.
Unfortunately, we still have to set
$(DisableUnsupportedError)or we will get the message:A future change might be needed here, or it might be fine to for the Android workload to set this property: