未验证 提交 9a44f08a 编写于 作者: A Andrii Kurdiumov 提交者: GitHub

Simplify instructions for using ILC (#70811)

* Simplify instructions for using ILC

Because Microsoft.DotNet.ILCompiler on Nuget now, it's reasonable to inform user that adding custom nuget feed is for daily builds of ILC

* Attempt to improve docs

* Address PR feedback

* Removed unused file
Co-authored-by: NJan Kotas <jkotas@microsoft.com>
上级 b42275a3
# Compiling with Native AOT
This document explains how to compile and publish your project using Native AOT toolchain. First, please _ensure that [pre-requisites](prerequisites.md) are installed_. If you are starting a new project, you may find the [HelloWorld sample](https://github.com/dotnet/samples/tree/main/core/nativeaot/HelloWorld/README.md) directions useful.
Please consult [documentation](https://docs.microsoft.com/dotnet/core/deploying/native-aot) for instructions how to compile and publish application.
## Add ILCompiler package reference
The rest of this document covers advanced topics only.
To use Native AOT with your project, you need to add a reference to the ILCompiler NuGet package containing the Native AOT compiler and runtime. Make sure the `nuget.config` file for your project contains the following package sources under the `<packageSources>` element:
## Using daily builds
For using daily builds, you need to make sure the `nuget.config` file for your project contains the following package sources under the `<packageSources>` element:
```xml
<add key="dotnet7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
......@@ -29,20 +32,6 @@ or by adding the following element to the project file:
</ItemGroup>
```
## Compile and publish your app
Use the `dotnet publish` command to compile and publish your app:
```bash
> dotnet publish -r <RID> -c <Configuration>
```
where `<Configuration>` is your project configuration (such as Debug or Release) and `<RID>` is the runtime identifier reflecting your host OS and architecture (one of win-x64, linux-x64, osx-x64). For example, to publish the Release build of your app for Windows x64, run the following command:
```bash
> dotnet publish -r win-x64 -c Release
```
If the compilation succeeds, the native executable will be placed under the `bin/<Configuration>/net6.0/<RID>/publish/` path relative to your project's root directory.
## Cross-architecture compilation
Native AOT toolchain allows targeting ARM64 on an x64 host and vice versa for both Windows and Linux. Cross-OS compilation, such as targeting Linux on a Windows host, is not supported. To target win-arm64 on a Windows x64 host, in addition to the `Microsoft.DotNet.ILCompiler` package reference, also add the `runtime.win-x64.Microsoft.DotNet.ILCompiler` package reference to get the x64-hosted compiler:
......
If you're new to .NET, make sure to visit the [official starting page](http://dotnet.github.io). It will guide you through installing pre-requisites and building your first app.
If you're already familiar with .NET, make sure you've [downloaded and installed the .NET 6 SDK](https://www.microsoft.com/net/download/core).
The following pre-requisites need to be installed for building .NET 6 projects with Native AOT.
# Windows
* Install [Visual Studio 2022](https://visualstudio.microsoft.com/vs/community/), including Desktop development with C++ workload.
## Advanced Alternative: Minimum Visual C++ Build Tools Installation
If you wish to save disk space and do not need Visual Studio IDE, you may use the [Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022)
edition instead. First download the [bootstrapper](https://aka.ms/vs/17/release/vs_buildtools.exe) executable.
On Windows 10 version 1803 or later you may use the `curl` tool:
```cmd
curl -L https://aka.ms/vs/17/release/vs_buildtools.exe -o vs_buildtools.exe
```
Then launch the bootstrapper passing the installation path and the two required components (requires elevation):
```cmd
vs_buildtools.exe --installPath C:\VS2022 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 Microsoft.VisualStudio.Component.Windows10SDK.19041 --passive --norestart --nocache
```
Alternatively you may launch the bootstrapper without any options and use Visual Studio Installer UI to enable C++ x64/x86 build tools and Windows 10 SDK individual components.
Notes:
- You may skip the `Windows10SDK.19041` component if you already have Windows 10 SDK installed on your machine.
- To target Windows ARM64, you need to add the `Microsoft.VisualStudio.Component.VC.Tools.ARM64` (C++ ARM64 build tools) component instead.
- The `--installPath` option affects Build Tools installation only. Visual Studio Installer is always installed into
the `%ProgramFiles(x86)%\Microsoft Visual Studio\Installer` directory.
# Linux
Install `clang` and developer packages for libraries that .NET runtime depends on:
## Fedora (31+)
```sh
sudo dnf install clang zlib-devel ncurses-compat-libs
```
## Ubuntu (16.04+)
```sh
sudo apt-get install clang zlib1g-dev
```
## Alpine (3.14+)
```sh
sudo apk add clang gcc lld musl-dev build-base zlib-dev
```
# macOS (10.13+)
* Install latest [Command Line Tools for XCode](https://developer.apple.com/xcode/download/).
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册