Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The project files and scripts in this repo build the same game (Snake clone) in
dotnet publish -r win-x64 -c Release
```

### To build the 25 MB version of the game
### To build the 11 MB version of the game

```
dotnet publish -r win-x64 -c Release /p:PublishTrimmed=true
Expand All @@ -26,34 +26,46 @@ dotnet publish -r win-x64 -c Release /p:PublishTrimmed=true

Make sure you have Visual Studio 2019 installed (Community edition is free) and include C/C++ development tools with Windows SDK (we need a tiny fraction of that - the platform linker and Win32 import libraries).

### To build the 4.7 MB version of the game
### To build the 3.57 MB version of the game

```
dotnet publish -r win-x64 -c Release /p:Mode=CoreRT
dotnet publish -r win-x64 -c Release /p:Mode=NativeAOT
```

### To build the 4.3 MB version of the game
### To build the 3.52 MB version of the game

```
dotnet publish -r win-x64 -c Release /p:Mode=CoreRT-Moderate
dotnet publish -r win-x64 -c Release /p:Mode=NativeAOT-Moderate
```

### To build the 3.0 MB version of the game
### To build the 2.2 MB version of the game

```
dotnet publish -r win-x64 -c Release /p:Mode=CoreRT-High
dotnet publish -r win-x64 -c Release /p:Mode=NativeAOT-High
```

### To build the 1.2 MB version of the game

```
dotnet publish -r win-x64 -c Release /p:Mode=CoreRT-ReflectionFree
dotnet publish -r win-x64 -c Release /p:Mode=NativeAOT-ReflectionFree
```

### To build the 820 KB version of the game

```
dotnet publish -r win-x64 -c Release /p:Mode=NativeAOT-UPX
```

### To build the 493 KB version of the game

```
dotnet publish -r win-x64 -c Release /p:Mode=NativeAOT-ReflectionFree-UPX
```

### To build the 10 kB version of the game

```
dotnet publish -r win-x64 -c Release /p:Mode=CoreRT-NoRuntime
dotnet publish -r win-x64 -c Release /p:Mode=NativeAOT-NoRuntime
```

### To build the 8 kB version of the game
Expand Down
51 changes: 30 additions & 21 deletions SeeSharpSnake.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PublishSingleFile Condition="'$(Mode)' == ''">true</PublishSingleFile>
<PublishAot Condition="'$(Mode)' != ''">true</PublishAot>
<EnableDefaultItems>false</EnableDefaultItems>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
Expand All @@ -31,13 +32,13 @@
<Compile Include="Pal/RuntimeInformation.Linux.cs" />
</ItemGroup>

<ItemGroup Condition="'$(Mode)' == 'CoreRT-NoRuntime' or '$(Mode)' == 'CoreRT-Uefi'">
<ItemGroup Condition="'$(Mode)' == 'NativeAOT-NoRuntime' or '$(Mode)' == 'NativeAOT-Uefi'">
<Compile Include="MiniBCL.cs" />
<Compile Include="MiniRuntime.cs" />
<Compile Include="MiniRuntime.Dos.cs" />
</ItemGroup>

<ItemGroup Condition="'$(Mode)' == 'CoreRT-Uefi'">
<ItemGroup Condition="'$(Mode)' == 'NativeAOT-Uefi'">
<Compile Include="Pal/Thread.Uefi.cs" />
<Compile Include="Pal/Environment.Uefi.cs" />
<Compile Include="Pal/Console.Uefi.cs" />
Expand All @@ -47,31 +48,22 @@
<Compile Include="Pal/RuntimeInformation.Uefi.cs" />
</ItemGroup>

<ItemGroup Condition="'$(Mode)' != ''">
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-*" />
</ItemGroup>

<PropertyGroup Condition="'$(Mode)' == 'CoreRT-Moderate' or '$(Mode)' == 'CoreRT-High' or '$(Mode)' == 'CoreRT-ReflectionFree'">
<PropertyGroup Condition="'$(Mode)' == 'NativeAOT-Moderate' or '$(Mode)' == 'NativeAOT-High' or '$(Mode)' == 'NativeAOT-UPX' or '$(Mode)' == 'NativeAOT-ReflectionFree' or '$(Mode)' == 'NativeAOT-ReflectionFree-UPX'">
<IlcGenerateCompleteTypeMetadata>false</IlcGenerateCompleteTypeMetadata>
<IlcOptimizationPreference>Size</IlcOptimizationPreference>
</PropertyGroup>

<PropertyGroup Condition="'$(Mode)' == 'CoreRT-High' or '$(Mode)' == 'CoreRT-ReflectionFree' or '$(Mode)' == 'CoreRT-NoRuntime'">
<PropertyGroup Condition="'$(Mode)' == 'NativeAOT-ReflectionFree' or '$(Mode)' == 'NativeAOT-ReflectionFree-UPX' or '$(Mode)' == 'NativeAOT-NoRuntime'">
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
<IlcInvariantGlobalization>true</IlcInvariantGlobalization>
<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies>
</PropertyGroup>

<ItemGroup Condition="'$(Mode)' == 'CoreRT-High'">
<IlcArg Include="--removefeature:EventSource" />
<IlcArg Include="--removefeature:FrameworkStrings" />
</ItemGroup>

<PropertyGroup Condition="'$(Mode)' == 'CoreRT-ReflectionFree'">
<PropertyGroup Condition="'$(Mode)' == 'NativeAOT-ReflectionFree' or '$(Mode)' == 'NativeAOT-ReflectionFree-UPX'">
<IlcDisableReflection>true</IlcDisableReflection>
</PropertyGroup>

<PropertyGroup Condition="'$(Mode)' == 'CoreRT-NoRuntime' or '$(Mode)' == 'CoreRT-Uefi'">
<PropertyGroup Condition="'$(Mode)' == 'NativeAOT-NoRuntime' or '$(Mode)' == 'NativeAOT-Uefi'">
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<RuntimeMetadataVersion>v4.0.30319</RuntimeMetadataVersion>
Expand All @@ -83,28 +75,38 @@
<IlcSystemModule>SeeSharpSnake</IlcSystemModule>
</PropertyGroup>

<PropertyGroup Condition="'$(Mode)' == 'CoreRT-NoRuntime'">
<PropertyGroup Condition="'$(Mode)' == 'NativeAOT-NoRuntime'">
<IncludePal>true</IncludePal>
</PropertyGroup>

<ItemGroup Condition="'$(Mode)' == 'CoreRT-NoRuntime'">
<ItemGroup Condition="'$(Mode)' == 'NativeAOT-NoRuntime'">
<LinkerArg Include="/subsystem:console /entry:__managed__Main /merge:.modules=.rdata /merge:.pdata=.rdata /DYNAMICBASE:NO /filealign:16 /align:16" />
</ItemGroup>

<ItemGroup Condition="'$(Mode)' == 'CoreRT-Uefi'">
<ItemGroup Condition="'$(Mode)' == 'NativeAOT-Uefi'">
<LinkerArg Include="/subsystem:EFI_APPLICATION /entry:EfiMain" />
</ItemGroup>

<PropertyGroup Condition="'$(Mode)' == 'NativeAOT-UPX' or '$(Mode)' == 'NativeAOT-High'">
<EventSourceSupport>false</EventSourceSupport>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

<ItemGroup Condition="'$(Mode)' == 'NativeAOT-UPX' or '$(Mode)' == 'NativeAOT-ReflectionFree-UPX'">
<PackageReference Include="PublishAotCompressed" Version="0.0.4" />
</ItemGroup>

<Target Name="CustomizeReferences" BeforeTargets="BeforeCompile" AfterTargets="FindReferenceAssembliesForReferences"
Condition="'$(Mode)' == 'CoreRT-NoRuntime' or '$(Mode)' == 'CoreRT-Uefi'">
Condition="'$(Mode)' == 'NativeAOT-NoRuntime' or '$(Mode)' == 'NativeAOT-Uefi'">
<ItemGroup>
<ReferencePathWithRefAssemblies Remove="@(ReferencePathWithRefAssemblies)" />
<ReferencePath Remove="@(ReferencePath)" />
</ItemGroup>
</Target>

<Target Name="GenerateVirtuaDisk" AfterTargets="Publish"
Condition="'$(Mode)' == 'CoreRT-Uefi'">
Condition="'$(Mode)' == 'NativeAOT-Uefi'">
<PropertyGroup>
<VHD>$(MSBuildProjectDirectory)\$(NativeOutputPath)seesharpsnake.vhdx</VHD>
<CreatePartitionCommand>
Expand Down Expand Up @@ -136,4 +138,11 @@
<Exec Command="diskpart /s &quot;$(MSBuildProjectDirectory)\$(NativeOutputPath)diskpart2.txt&quot;" />
</Target>

<!-- The AOT compiler would want to mirror these as AppContext switches. Prevent that. -->
<Target Name="RemoveHostConfigurationOptions" BeforeTargets="WriteIlcRspFileForCompilation" DependsOnTargets="PrepareForILLink" Condition="'$(Mode)' == 'NativeAOT-NoRuntime'">
<ItemGroup>
<RuntimeHostConfigurationOption Remove="@(RuntimeHostConfigurationOption)" />
</ItemGroup>
</Target>

</Project>