forked from GmodNET/GmodDotNet
/
runtime.csproj
132 lines (104 loc) · 6.98 KB
/
runtime.csproj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<Project Sdk="Microsoft.Build.NoTargets/3.0.4">
<!-- Public properties to configure runtime build. -->
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<BundledNETCoreVersion>7.0.2</BundledNETCoreVersion>
<NETCoreDownloadUrl Condition="$(NETCoreSdkRuntimeIdentifier) == 'win-x64'">
https://download.visualstudio.microsoft.com/download/pr/79dbfb6e-78b4-4e2c-a3a9-040666d6b407/ad24076fc19fdfa6c7acdd6bad8a1fc5/aspnetcore-runtime-7.0.2-win-x64.zip
</NETCoreDownloadUrl>
<NETCoreDownloadUrl Condition="$(NETCoreSdkRuntimeIdentifier) == 'linux-x64'">
https://download.visualstudio.microsoft.com/download/pr/1d8c4b4c-aec9-451b-9bd3-bf7cdbd28477/def6c1a7a9cfd4590698d4f338da2803/aspnetcore-runtime-7.0.2-linux-x64.tar.gz
</NETCoreDownloadUrl>
<NETCoreDownloadUrl Condition="$(NETCoreSdkRuntimeIdentifier) == 'osx-x64'">
https://download.visualstudio.microsoft.com/download/pr/035d61f7-0418-4834-8364-eec4d3c3d112/b1fd356e10f14ee2c930e023654186f3/aspnetcore-runtime-7.0.2-osx-x64.tar.gz
</NETCoreDownloadUrl>
</PropertyGroup>
<!-- Internal properties. Do not change manually. -->
<PropertyGroup>
<BaseGmodNETPublishInst>dotnet publish gm_dotnet_managed/GmodNET/GmodNET.csproj -c $(Configuration) -o build/gmodnet/</BaseGmodNETPublishInst>
<CmakeGenerateWinFlags Condition="$(NETCoreSdkRuntimeIdentifier) == 'win-x64'">-G "Visual Studio 16 2019" -A x64</CmakeGenerateWinFlags>
<CmakeBuildWinInst>cd obj/cmake_build && cmake --build ./ -- /p:Configuration=Release</CmakeBuildWinInst>
<CmakeBuildLinuxAndMacInst>cd obj/cmake_build && cmake --build ./</CmakeBuildLinuxAndMacInst>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<Target Name="BuildRuntime" BeforeTargets="AfterBuild">
<Message Text="Starting GmodNET Runtime build process" Importance="high" />
<Exec Command="$(BaseGmodNETPublishInst)" ConsoleToMsBuild="true" />
<Delete Files="build/gmodnet/GmodNET.exe;build/gmodnet/GmodNET;build/gmodnet/web.config" />
<MakeDir Directories="obj/cmake_build" />
<Exec Command="$(CmakeGenerateInst)" ConsoleToMsBuild="true" />
<CallTarget Condition="$(NETCoreSdkRuntimeIdentifier) == 'win-x64'" Targets="CmakeBuildWindows" />
<CallTarget Condition="$(NETCoreSdkRuntimeIdentifier) == 'linux-x64'" Targets="CmakeBuildLinux" />
<CallTarget Condition="$(NETCoreSdkRuntimeIdentifier) == 'osx-x64'" Targets="CmakeBuildMac" />
<CallTarget Targets="BundleRuntime" />
<Copy SourceFiles="LICENSE" DestinationFiles="build/LICENSE" />
<Copy SourceFiles="NOTICE" DestinationFiles="build/NOTICE" />
<Exec Command="dotnet pack gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj -c $(Configuration) -o nupkgs/" ConsoleToMsBuild="true" />
<Exec Command="dotnet publish gm_dotnet_managed/Tests/Tests.csproj -c $(Configuration) -o Modules/Tests/" ConsoleToMsBuild="true" />
<CallTarget Targets="RuntimeCleanUp" />
<OnError ExecuteTargets="RuntimeCleanUp" />
</Target>
<Target Name="CmakeBuildWindows">
<Exec Command="$(CmakeBuildWinInst)" ConsoleToMsBuild="true" />
<Copy SourceFiles="build/Release/gmsv_dotnet_win64.dll" DestinationFiles="build/gmsv_dotnet_win64.dll" />
<Copy SourceFiles="build/Release/dotnethelper.dll" DestinationFiles="build/dotnethelper.dll" />
<Copy SourceFiles="build/gmsv_dotnet_win64.dll" DestinationFiles="build/gmcl_dotnet_win64.dll" />
<RemoveDir Directories="build/Release" />
</Target>
<Target Name="CmakeBuildLinux">
<Exec Command="$(CmakeBuildLinuxAndMacInst)" ConsoleToMsBuild="true" />
<Copy SourceFiles="build/gmsv_dotnet_linux64.dll" DestinationFiles="build/gmcl_dotnet_linux64.dll" />
</Target>
<Target Name="CmakeBuildMac">
<Exec Command="$(CmakeBuildLinuxAndMacInst)" ConsoleToMsBuild="true" />
<Copy SourceFiles="build/gmsv_dotnet_osx64.dll" DestinationFiles="build/gmcl_dotnet_osx64.dll" />
</Target>
<Target Name="RuntimeCleanUp">
<Message Text="Making clean-up" Importance="high" />
<RemoveDir Directories="obj/cmake_build" />
<RemoveDir Directories="obj/netcore-$(NETCoreSdkRuntimeIdentifier)-$(BundledNETCoreVersion)" />
<RemoveDir Directories="obj/aspnet-$(NETCoreSdkRuntimeIdentifier)-$(BundledAspVersion)" />
</Target>
<Target Name="BundleRuntime">
<DownloadFile SourceUrl="$(NETCoreDownloadUrl)" DestinationFolder="obj" DestinationFileName="netcore-$(NETCoreSdkRuntimeIdentifier).arch" SkipUnchangedFiles="true" />
<MakeDir Directories="build/dotnet" />
<Unzip Condition="$(NETCoreSdkRuntimeIdentifier) == 'win-x64'" SourceFiles="obj/netcore-$(NETCoreSdkRuntimeIdentifier).arch" DestinationFolder="build/dotnet" OverwriteReadOnlyFiles="true" />
<Exec Condition="$(NETCoreSdkRuntimeIdentifier) != 'win-x64'" Command="tar xvfz obj/netcore-$(NETCoreSdkRuntimeIdentifier).arch -C build/dotnet" ConsoleToMsBuild="true" />
</Target>
<Target Name="DeleteOldBuilds" BeforeTargets="BuildRuntime">
<RemoveDir Directories="build" />
<RemoveDir Directories="nupkgs" />
<RemoveDir Directories="Modules" />
<RemoveDir Directories="packed-build" />
</Target>
<Target Name="GetVersionFromTool" BeforeTargets="BuildRuntime;PackRuntimeBuild;PackLuaForPublish">
<Exec Command="dotnet tool restore" />
<Exec Command="dotnet tool run gmodnet-vt getVersion version.json" ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="RuntimeVersion" />
</Exec>
<Exec Command="dotnet tool run gmodnet-vt getVersion version.json --skip-build-data" ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="RuntimeVersionShort" />
</Exec>
<Exec Command="dotnet tool run gmodnet-vt getVersion version.json" ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="ApiVersion" />
</Exec>
<Exec Command="dotnet tool run gmodnet-vt getVersion version.json --skip-build-data" ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="ApiVersionShort" />
</Exec>
<CreateProperty Value="cd obj/cmake_build && cmake -DSEM_VERSION:STRING=$(RuntimeVersion) -DNET_CORE_VERSION:STRING=$(BundledNETCoreVersion) ../../gm_dotnet_native $(CmakeGenerateWinFlags)">
<Output
TaskParameter="Value"
PropertyName="CmakeGenerateInst" />
</CreateProperty>
</Target>
<Target Name="PackRuntimeBuild">
<MakeDir Directories="packed-build" />
<ZipDirectory DestinationFile="packed-build/gmod-dot-net-windows.$(RuntimeVersionShort).zip" SourceDirectory="build" Condition="'$(NETCoreSdkRuntimeIdentifier)' == 'win-x64'" />
<Exec Condition="'$(NETCoreSdkRuntimeIdentifier)' == 'linux-x64'" Command="cd build && tar czfv ../packed-build/gmod-dot-net-linux.$(RuntimeVersionShort).tar.gz ." />
<Exec Condition="'$(NETCoreSdkRuntimeIdentifier)' == 'osx-x64'" Command="cd build && tar czfv ../packed-build/gmod-dot-net-osx.$(RuntimeVersionShort).tar.gz ." />
</Target>
<Target Name="PackLuaForPublish">
<MakeDir Directories="lua-publish" />
</Target>
</Project>