mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
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
This commit is contained in:
parent
78dd3ea17e
commit
ea6788278d
4 changed files with 83 additions and 35 deletions
86
.github/workflows/build-and-release.yml
vendored
86
.github/workflows/build-and-release.yml
vendored
|
|
@ -1,30 +1,39 @@
|
||||||
# This workflow will build the project using .NET 4 then publish to GitHub releases
|
|
||||||
# Due to running .NET 4 this workflow needs to run on windows-2019 (support dropped on windows 2022)
|
|
||||||
# Changes would need to be made for using .NET 5 and later on linux
|
|
||||||
|
|
||||||
name: Build
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: windows-2019
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PROJECT: "MinecraftClient"
|
PROJECT: "MinecraftClient"
|
||||||
|
target-version: "net6.0"
|
||||||
|
compile-flags: "--no-self-contained -c Release -p:UseAppHost=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=None"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: SetupMSBuild
|
- name: Setup Project Path
|
||||||
uses: microsoft/setup-msbuild@v1
|
run: |
|
||||||
|
echo project-path=${{ github.workspace }}/${{ env.PROJECT }} >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Setup Output Paths
|
||||||
|
run: |
|
||||||
|
echo win-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/win-x64/publish/ >> $GITHUB_ENV
|
||||||
|
echo linux-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/linux-x64/publish/ >> $GITHUB_ENV
|
||||||
|
echo osx-out-path=${{ env.project-path }}/bin/Release/${{ env.target-version }}/osx-x64/publish/ >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Setup .NET SDK
|
||||||
|
uses: actions/setup-dotnet@v2.1.0
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
- name: DateVersion
|
- name: Get Version DateTime
|
||||||
id: date-version
|
id: date-version
|
||||||
uses: nanzm/get-time-action@v1.0
|
uses: nanzm/get-time-action@v1.0
|
||||||
with:
|
with:
|
||||||
|
|
@ -33,26 +42,61 @@ jobs:
|
||||||
|
|
||||||
- name: VersionInfo
|
- name: VersionInfo
|
||||||
run: |
|
run: |
|
||||||
# PowerShell commands
|
COMMIT=$(echo ${{ github.sha }} | cut -c 1-7)
|
||||||
set COMMIT "${{ github.sha }}".substring(0, 7)
|
echo '' >> ${{ env.project-path }}\Properties\AssemblyInfo.cs
|
||||||
'' >> ${{ github.workspace }}\${{ env.PROJECT }}\Properties\AssemblyInfo.cs
|
echo "[assembly: AssemblyConfiguration(\"GitHub build ${{ github.run_number }}, built on ${{ steps.date-version.outputs.time }} from commit $COMMIT\")]" >> ${{ env.project-path }}\Properties\AssemblyInfo.cs
|
||||||
"[assembly: AssemblyConfiguration(`"GitHub build ${{ github.run_number }}, built on ${{ steps.date-version.outputs.time }} from commit $COMMIT`")]" >> ${{ github.workspace }}\${{ env.PROJECT }}\Properties\AssemblyInfo.cs
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build for Windows
|
||||||
run: msbuild ${{ github.workspace }}\${{ env.PROJECT }}.sln /t:clean,build /p:Configuration=Release /p:Platform="x86" /p:TargetFrameworkVersion="v4.0" /verbosity:minimal
|
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r win-x64 ${{ env.compile-flags }}
|
||||||
|
|
||||||
- name: DateRelease
|
- name: Zip Windows Build
|
||||||
|
run: zip -qq -r windows.zip *
|
||||||
|
working-directory: ${{ env.win-out-path }}
|
||||||
|
|
||||||
|
- name: Build for Linux
|
||||||
|
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r linux-x64 ${{ env.compile-flags }}
|
||||||
|
|
||||||
|
- name: Zip Linux Build
|
||||||
|
run: zip -qq -r linux.zip *
|
||||||
|
working-directory: ${{ env.linux-out-path }}
|
||||||
|
|
||||||
|
- name: Build for OSX
|
||||||
|
run: dotnet publish ${{ env.project-path }}.sln -f ${{ env.target-version }} -r osx-x64 ${{ env.compile-flags }}
|
||||||
|
|
||||||
|
- name: Zip OSX Build
|
||||||
|
run: zip -qq -r osx.zip *
|
||||||
|
working-directory: ${{ env.osx-out-path }}
|
||||||
|
|
||||||
|
- name: Get Release DateTime
|
||||||
id: date-release
|
id: date-release
|
||||||
uses: nanzm/get-time-action@v1.0
|
uses: nanzm/get-time-action@v1.0
|
||||||
with:
|
with:
|
||||||
timeZone: 0
|
timeZone: 0
|
||||||
format: 'YYYYMMDD'
|
format: 'YYYYMMDD'
|
||||||
|
|
||||||
- name: Release
|
- name: Windows Release
|
||||||
uses: tix-factory/release-manager@v1
|
uses: tix-factory/release-manager@v1
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
mode: uploadReleaseAsset
|
mode: uploadReleaseAsset
|
||||||
filePath: ${{ github.workspace }}\${{env.PROJECT}}\bin\Release\${{ env.PROJECT }}.exe
|
filePath: ${{ env.win-out-path }}windows.zip
|
||||||
assetName: ${{ env.PROJECT }}.exe
|
assetName: ${{ env.PROJECT }}-windows.zip
|
||||||
|
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
|
||||||
|
|
||||||
|
- name: Linux Release
|
||||||
|
uses: tix-factory/release-manager@v1
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
mode: uploadReleaseAsset
|
||||||
|
filePath: ${{ env.linux-out-path }}linux.zip
|
||||||
|
assetName: ${{ env.PROJECT }}-linux.zip
|
||||||
|
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
|
||||||
|
|
||||||
|
- name: OSX Release
|
||||||
|
uses: tix-factory/release-manager@v1
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
mode: uploadReleaseAsset
|
||||||
|
filePath: ${{ env.osx-out-path }}osx.zip
|
||||||
|
assetName: ${{ env.PROJECT }}-osx.zip
|
||||||
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
|
tag: ${{ format('{0}-{1}', steps.date-release.outputs.time, github.run_number) }}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 27c73d0dc062f62e6fb64b23b14bf443c1577b90
|
Subproject commit 8a3b9bcd03d73aa1d218e8cffb19248f3a487dd4
|
||||||
|
|
@ -6,6 +6,8 @@
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<LangVersion>default</LangVersion>
|
<LangVersion>default</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
|
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SignManifests>false</SignManifests>
|
<SignManifests>false</SignManifests>
|
||||||
|
|
|
||||||
28
README.md
28
README.md
|
|
@ -38,25 +38,27 @@ For the names of the translation file, please see [this comment](https://github.
|
||||||
|
|
||||||
_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:_
|
_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:_
|
||||||
|
|
||||||
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.
|
First of all, download the .NET 6.0 SDK [here](https://dotnet.microsoft.com/en-us/download) and follow the install instructions.
|
||||||
|
|
||||||
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):
|
Get a [zip of source code](https://github.com/MCCTeam/Minecraft-Console-Client/archive/master.zip), extract it and navigate to the `MinecraftClient` folder.
|
||||||
|
|
||||||
```xml
|
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
|
|
||||||
```
|
|
||||||
|
|
||||||
### On Windows 🪟
|
### On Windows 🪟
|
||||||
|
|
||||||
1. Locate `MSBuild.exe` for .NET 4 inside `C:\Windows\Microsoft.NET\Framework\v4.X.XXXXX`
|
1. Open a Terminal / Command Prompt.
|
||||||
2. Drag and drop `MinecraftClient.csproj` over `MSBuild.exe` to launch the build
|
2. Type in `dotnet publish --no-self-contained -r win-x64 -c Release`.
|
||||||
3. If the build succeeds, you can find `MinecraftClient.exe` under `MinecraftClient\bin\Release`
|
3. If the build succeeds, you can find `MinecraftClient.exe` under `MinecraftClient\bin\Release\net6.0\win-x64\publish\`
|
||||||
|
|
||||||
### On Mac and Linux 🐧
|
### On Linux 🐧
|
||||||
|
|
||||||
1. Install the [Mono Framework](https://www.mono-project.com/download/stable/#download-lin) if not already installed
|
1. Open a Terminal / Command Prompt.
|
||||||
2. Run `msbuild MinecraftClient.csproj` in a terminal
|
2. Type in `dotnet publish --no-self-contained -r linux-x64 -c Release`.
|
||||||
3. If the build succeeds, you can find `MinecraftClient.exe` under `MinecraftClient\bin\Release`
|
3. If the build succeeds, you can find `MinecraftClient` under `MinecraftClient\bin\Release\net6.0\linux-x64\publish\`
|
||||||
|
|
||||||
|
### On Mac 🍎
|
||||||
|
|
||||||
|
1. Open a Terminal / Command Prompt.
|
||||||
|
2. Type in `dotnet publish --no-self-contained -r osx-x64 -c Release`.
|
||||||
|
3. If the build succeeds, you can find `MinecraftClient` under `MinecraftClient\bin\Release\net6.0\osx-x64\publish\`
|
||||||
|
|
||||||
## License ⚖️
|
## License ⚖️
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue