[接續昨天] NET Core 發布時輕量化 剩下一個.exe檔好棒棒
Github : CoreRT Pre-Requisites
- 安裝Visual Studio 2017 包含Visual C++
- 安裝CMake(安裝程式中記得把PATH給設定上去)
- Clone CoreRT的專案原始碼
- Build它
build[.cmd|.sh] clean [Debug|Release]
- 應該會跑一段時間
- 會Restore所有的Nuget Project
- 最重要的ILCompiler放在
\bin<OS>. . \tools. - 自動build & test (我test總會有三個沒過)
- 別忘記安裝 .NET Core SDK
- 開啟你
CMD,ㄜ不是,是x64 Native Tools Command Prompt for VS 2017 - 真的要開啟 x64 Native Tools Command Prompt for VS 2017 不是CMDㄛ
- 開啟 x64 Native Tools Command Prompt for VS 2017
- 編輯你的.csproj檔案 加入以下這些
1
2
3
4<project>
<Import Project="$(MSBuildSDKsPath)\Microsoft.NET.Sdk\Sdk\Sdk.targets" Condition=" '$(Configuration)' != 'Debug'" />
<Import Project="$(IlcPath)\build\Microsoft.NETCore.Native.targets" Condition=" '$(Configuration)' != 'Debug'" />
</project> - 切到你的專案下 輸入這個 以我的例子來舉例的話就像下面醬子
1
dotnet publish --configuration Release --runtime win-x64 /p:IlcPath=<repo_root>\bin\<OS>.<arch>.<Config>
1
dotnet publish --configuration Release --runtime win-x64 /p:IlcPath=D:\Patrick\corert\bin\Windows_NT.x64.Debug
- 江江,在 bin\x64\Release\netcoreapp2.1\win-x64\publish\ 寶藏都在那了