Search code examples
c#wpfgitgithubyaml

GitHub Action Release WPF Exe File Not Working


I have the deploy-TarotTyping.yml file below.

name: "Deploy Tarot Typing"

on:
  push:
     tags:
        - "v*"         
env:
   PROJECT_PATH: TarotType.Main/TarotType.Main.csproj    
    
jobs:
  deploy:
     runs-on: windows-latest
     steps:
        - uses: actions/checkout@v3
     
        - uses: actions/setup-dotnet@v3
          with: 
            dotnet-version: 6.0.x

        - run: dotnet restore ${{ env.PROJECT_PATH }}
  
        - run: dotnet build ${{ env.PROJECT_PATH }} -c Release --no-restore
  
        - run: dotnet publish ${{ env.PROJECT_PATH }} -c Release --self-contained -r win-x64 -p:PublishSingleFile=true
  
        - uses: actions/create-release@v1
          id: create_release
          env: 
            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          with: 
            tag_name: ${{ github.ref }} 
            release_name: ${{ github.ref }}

        - uses: csexton/release-asset-action@v2
          with:
            github-token: ${{ secrets.GITHUB_TOKEN }}
            pattern: TarotType.Main/bin/Release/net6.0-windows/win-x64/publish/TarotType.Main.exe
            release-url: ${{ steps.create_release.outputs.upload_url }}

After I publish release to here (v1.5.0) and download TarotType.Main.exe it simply does not work, and I could not find the problem.

I would be appreciate for your help.


Solution

  • I realized that my publish folder did not actually consist of a single file. There were a bunch of .dll files present. As a result, when I attempted to release the .exe on GitHub using GitHub Actions, the application failed to function correctly. This was due to the essential .dll files that were required for the proper execution of the .exe file. I solved my problem by adding

    <IncludeNativeLibrariesForSelfExtract> true </IncludeNativeLibrariesForSelfExtract>
    

    to the .csproj file.

    Here is my current .csproj configuration:

    <Project Sdk="Microsoft.NET.Sdk">
    
        <PropertyGroup>
            <OutputType>WinExe</OutputType>
            <TargetFramework>net6.0-windows</TargetFramework>
            <Nullable>enable</Nullable>
            <UseWPF>true</UseWPF>
            <PublishSingleFile>true</PublishSingleFile>
            <RuntimeIdentifier>win-x64</RuntimeIdentifier>
            <PlatformTarget>x64</PlatformTarget>
            <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
        </PropertyGroup>
    
    </Project>