Skip to content

Commit ea67882

Browse files
authored
Fix automated build for .NET releases (#2059)
* Fix automated build for .NET releases * Update build-and-release.yml * update submodule for building * Update build-and-release.yml * update consoleinteractive build * Update build-and-release.yml * set PublishSingleFile as true by default * update csproj file to include compile flag setting IncludeNativeLibrariesForSelfExtract to true removes the sni.dll output file. * update build instructions on README * move compile flags into env variable - disable compilation of PDB files - enable OSX builds
1 parent 78dd3ea commit ea67882

File tree

4 files changed

+83
-35
lines changed

4 files changed

+83
-35
lines changed
Lines changed: 65 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
1-
# This workflow will build the project using .NET 4 then publish to GitHub releases
2-
# Due to running .NET 4 this workflow needs to run on windows-2019 (support dropped on windows 2022)
3-
# Changes would need to be made for using .NET 5 and later on linux
4-
51
name: Build
62

73
on:
84
push:
95
branches: [ master ]
6+
7+
env:
8+
PROJECT: "MinecraftClient"
9+
target-version: "net6.0"
10+
compile-flags: "--no-self-contained -c Release -p:UseAppHost=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=None"
1011

1112
jobs:
1213
build:
13-
runs-on: windows-2019
14-
15-
env:
16-
PROJECT: "MinecraftClient"
14+
runs-on: ubuntu-latest
1715

1816
steps:
19-
- name: SetupMSBuild
20-
uses: microsoft/setup-msbuild@v1
17+
- name: Setup Project Path
18+
run: |
19+
echo project-path=${{ github.workspace }}/${{ env.PROJECT }} >> $GITHUB_ENV
20+
21+
- name: Setup Output Paths
22+
run: |
23+
echo win-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/win-x64/publish/ >> $GITHUB_ENV
24+
echo linux-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/linux-x64/publish/ >> $GITHUB_ENV
25+
echo osx-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/osx-x64/publish/ >> $GITHUB_ENV
26+
27+
- name: Setup .NET SDK
28+
uses: actions/[email protected]
2129

2230
- name: Checkout
2331
uses: actions/checkout@v2
2432
with:
2533
fetch-depth: 0
34+
submodules: 'true'
2635

27-
- name: DateVersion
36+
- name: Get Version DateTime
2837
id: date-version
2938
uses: nanzm/[email protected]
3039
with:
@@ -33,26 +42,61 @@ jobs:
3342

3443
- name: VersionInfo
3544
run: |
36-
# PowerShell commands
37-
set COMMIT "${{ github.sha }}".substring(0, 7)
38-
'' >> ${{ github.workspace }}\${{ env.PROJECT }}\Properties\AssemblyInfo.cs
39-
"[assembly: AssemblyConfiguration(`"GitHub build ${{ github.run_number }}, built on ${{ steps.date-version.outputs.time }} from commit $COMMIT`")]" >> ${{ github.workspace }}\${{ env.PROJECT }}\Properties\AssemblyInfo.cs
45+
COMMIT=$(echo ${{ github.sha }} | cut -c 1-7)
46+
echo '' >> ${{ env.project-path }}\Properties\AssemblyInfo.cs
47+
echo "[assembly: AssemblyConfiguration(\"GitHub build ${{ github.run_number }}, built on ${{ steps.date-version.outputs.time }} from commit $COMMIT\")]" >> ${{ env.project-path }}\Properties\AssemblyInfo.cs
48+
49+
- name: Build for Windows
50+
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r win-x64 ${{ env.compile-flags }}
51+
52+
- name: Zip Windows Build
53+
run: zip -qq -r windows.zip *
54+
working-directory: ${{ env.win-out-path }}
4055

41-
- name: Build
42-
run: msbuild ${{ github.workspace }}\${{ env.PROJECT }}.sln /t:clean,build /p:Configuration=Release /p:Platform="x86" /p:TargetFrameworkVersion="v4.0" /verbosity:minimal
56+
- name: Build for Linux
57+
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r linux-x64 ${{ env.compile-flags }}
4358

44-
- name: DateRelease
59+
- name: Zip Linux Build
60+
run: zip -qq -r linux.zip *
61+
working-directory: ${{ env.linux-out-path }}
62+
63+
- name: Build for OSX
64+
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r osx-x64 ${{ env.compile-flags }}
65+
66+
- name: Zip OSX Build
67+
run: zip -qq -r osx.zip *
68+
working-directory: ${{ env.osx-out-path }}
69+
70+
- name: Get Release DateTime
4571
id: date-release
4672
uses: nanzm/[email protected]
4773
with:
4874
timeZone: 0
4975
format: 'YYYYMMDD'
5076

51-
- name: Release
77+
- name: Windows Release
78+
uses: tix-factory/release-manager@v1
79+
with:
80+
github_token: ${{ secrets.GITHUB_TOKEN }}
81+
mode: uploadReleaseAsset
82+
filePath: ${{ env.win-out-path }}windows.zip
83+
assetName: ${{ env.PROJECT }}-windows.zip
84+
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
85+
86+
- name: Linux Release
87+
uses: tix-factory/release-manager@v1
88+
with:
89+
github_token: ${{ secrets.GITHUB_TOKEN }}
90+
mode: uploadReleaseAsset
91+
filePath: ${{ env.linux-out-path }}linux.zip
92+
assetName: ${{ env.PROJECT }}-linux.zip
93+
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
94+
95+
- name: OSX Release
5296
uses: tix-factory/release-manager@v1
5397
with:
5498
github_token: ${{ secrets.GITHUB_TOKEN }}
5599
mode: uploadReleaseAsset
56-
filePath: ${{ github.workspace }}\${{env.PROJECT}}\bin\Release\${{ env.PROJECT }}.exe
57-
assetName: ${{ env.PROJECT }}.exe
100+
filePath: ${{ env.osx-out-path }}osx.zip
101+
assetName: ${{ env.PROJECT }}-osx.zip
58102
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}

MinecraftClient/MinecraftClient.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
77
<LangVersion>default</LangVersion>
88
<Nullable>enable</Nullable>
9+
<PublishSingleFile>true</PublishSingleFile>
10+
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
911
</PropertyGroup>
1012
<PropertyGroup>
1113
<SignManifests>false</SignManifests>

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,27 @@ For the names of the translation file, please see [this comment](https://github.
3838

3939
_The recommended development environment is [Visual Studio](https://visualstudio.microsoft.com/). If you want to build the project without installing a development environment, you may also follow these instructions:_
4040

41-
First of all, get a [zip of source code](https://github.com/MCCTeam/Minecraft-Console-Client/archive/master.zip), extract it and navigate to the `MinecraftClient` folder.
41+
First of all, download the .NET 6.0 SDK [here](https://dotnet.microsoft.com/en-us/download) and follow the install instructions.
4242

43-
Edit `MinecraftClient.csproj` to set the Build target to `Release` on [line 4](https://github.com/MCCTeam/Minecraft-Console-Client/blob/master/MinecraftClient/MinecraftClient.csproj#L4):
44-
45-
```xml
46-
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
47-
```
43+
Get a [zip of source code](https://github.com/MCCTeam/Minecraft-Console-Client/archive/master.zip), extract it and navigate to the `MinecraftClient` folder.
4844

4945
### On Windows 🪟
5046

51-
1. Locate `MSBuild.exe` for .NET 4 inside `C:\Windows\Microsoft.NET\Framework\v4.X.XXXXX`
52-
2. Drag and drop `MinecraftClient.csproj` over `MSBuild.exe` to launch the build
53-
3. If the build succeeds, you can find `MinecraftClient.exe` under `MinecraftClient\bin\Release`
47+
1. Open a Terminal / Command Prompt.
48+
2. Type in `dotnet publish --no-self-contained -r win-x64 -c Release`.
49+
3. If the build succeeds, you can find `MinecraftClient.exe` under `MinecraftClient\bin\Release\net6.0\win-x64\publish\`
50+
51+
### On Linux 🐧
52+
53+
1. Open a Terminal / Command Prompt.
54+
2. Type in `dotnet publish --no-self-contained -r linux-x64 -c Release`.
55+
3. If the build succeeds, you can find `MinecraftClient` under `MinecraftClient\bin\Release\net6.0\linux-x64\publish\`
5456

55-
### On Mac and Linux 🐧
57+
### On Mac 🍎
5658

57-
1. Install the [Mono Framework](https://www.mono-project.com/download/stable/#download-lin) if not already installed
58-
2. Run `msbuild MinecraftClient.csproj` in a terminal
59-
3. If the build succeeds, you can find `MinecraftClient.exe` under `MinecraftClient\bin\Release`
59+
1. Open a Terminal / Command Prompt.
60+
2. Type in `dotnet publish --no-self-contained -r osx-x64 -c Release`.
61+
3. If the build succeeds, you can find `MinecraftClient` under `MinecraftClient\bin\Release\net6.0\osx-x64\publish\`
6062

6163
## License ⚖️
6264

0 commit comments

Comments
 (0)