{"id":17947608,"url":"https://github.com/scgm0/nativeaottest","last_synced_at":"2025-10-07T21:04:07.656Z","repository":{"id":258280964,"uuid":"871778844","full_name":"scgm0/NativeAotTest","owner":"scgm0","description":"在Linux通过wine编译能在Windows使用的C# Native Aot","archived":false,"fork":false,"pushed_at":"2024-10-16T12:23:10.000Z","size":15,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-03T01:34:52.002Z","etag":null,"topics":["cross-os","dotnet","linux","native-aot","wine"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scgm0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-12T23:00:02.000Z","updated_at":"2025-06-25T15:36:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"cedf2b79-ce8e-4675-ad25-99a534572f0c","html_url":"https://github.com/scgm0/NativeAotTest","commit_stats":null,"previous_names":["scgm0/nativeaottest"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/scgm0/NativeAotTest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scgm0%2FNativeAotTest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scgm0%2FNativeAotTest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scgm0%2FNativeAotTest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scgm0%2FNativeAotTest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scgm0","download_url":"https://codeload.github.com/scgm0/NativeAotTest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scgm0%2FNativeAotTest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278846456,"owners_count":26056111,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-os","dotnet","linux","native-aot","wine"],"created_at":"2024-10-29T08:05:58.625Z","updated_at":"2025-10-07T21:04:07.622Z","avatar_url":"https://github.com/scgm0.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 在 Linux 通过 wine 编译能在 Windows 使用的 C# Native Aot\n\n使用的 Linux 发行版: [`Arch Linux`](https://archlinux.org/)\n\n- [在 Linux 通过 wine 编译能在 Windows 使用的 C# Native Aot](#在linux通过wine编译能在windows使用的c-native-aot)\n  - [方案一](#方案一)\n  - [方案二（推荐）](#方案二推荐)\n\n## 方案一\n\n- 1.使用 AUR 助手[`yay`](https://github.com/Jguer/yay)或[`paru`](https://github.com/Morganamilo/paru)安装[`wine`](https://www.winehq.org/)和[`msvc-wine-git`](https://github.com/mstorsjo/msvc-wine)\n\n- 2.在[`.Net`](https://dotnet.microsoft.com)官网下载[`dotnet8`](https://dotnet.microsoft.com/zh-cn/download/dotnet/8.0)的`exe`安装程序，使用`wine`运行并安装\n\n- 3.运行`wine regedit`修改注册表`HKEY_CURRENT_USER\\Environment`添加以下环境变量：\n  ```\n  `/opt/msvc`是aur中`msvc-wine-git`的默认安装路径，如果安装在了其他路径请自行替换\n  PATH: /opt/msvc/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64\n  LIB: /opt/msvc/Windows Kits/10/Lib/10.0.22621.0/um/x64;Z:/opt/msvc/Windows Kits/10/Lib/10.0.22621.0/ucrt/x64;/opt/msvc/VC/Tools/MSVC/14.41.34120/lib/x64\n  ```\n\n- 4.设置项目属性`\u003cIlcUseEnvironmentalTools\u003etrue\u003c/IlcUseEnvironmentalTools\u003e`\n\n- 5.在项目根目录运行`wine dotnet publish ./ -r win-x64 -c Release`触发编译\n\n- 6.运行编译结果`wine ./bin/Release/net8.0/win-x64/publish/NativeAotTest.exe`，成功打印`Hello, World!`\n\n## 方案二（推荐）\n- 1.使用 AUR 助手[`yay`](https://github.com/Jguer/yay)或[`paru`](https://github.com/Morganamilo/paru)安装[`wine`](https://www.winehq.org/)和[`msvc-wine-git`](https://github.com/mstorsjo/msvc-wine)\n\n- 2.在项目中引入`PublishAotCross.targets`(复制到其他项目中时，`PublishAotCross.targets`和`Crosscompile.targets`应该一起复制)\n  ```\n  (可选)\n  如果`msvc-wine-git`安装目录不是`/opt/msvc`，请在项目中添加`MSVCWineBinPath`属性\n  默认为\u003cMSVCWineBinPath\u003e/opt/msvc/bin\u003c/MSVCWineBinPath\u003e\n  ```\n\n- 3.在项目根目录运行`dotnet publish ./ -r win-x64 -c Release`触发编译\n\n- 4.运行编译结果`wine ./bin/Release/net8.0/win-x64/publish/NativeAotTest.exe`，成功打印`Hello, World!`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscgm0%2Fnativeaottest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscgm0%2Fnativeaottest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscgm0%2Fnativeaottest/lists"}