1

I try to build a native .NET application with Github actions. After 2 days of trying and searching i will ask here.

The project is a solution with .NET 4.6.1 and React Native (both not updateable for legacy code reasons).

When i run the ci it always tell me this:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.WindowsSDK.targets(46,5): error MSB8036: The Windows SDK version 10.0.18362.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution"

Here is my Github action code:

name: Build

on: [push]

jobs:
  build:
    name: "Build Termnial"

env:
  POWERSHELL_TELEMETRY_OPTOUT: 1
  DOTNET_CLI_TELEMETRY_OPTOUT: 1
  UseEnv: true

runs-on: windows-2019

steps:
  - uses: actions/checkout@v3

  - name: Setup Node.js
    uses: actions/setup-node@v3
    with:
      node-version: '16.x'

  - name: Setup MSBuild
    uses: microsoft/setup-msbuild@v1.3
    with:
      msbuild-architecture: x64

  - uses: actions/cache@v3
    with:
      path: ~/.nuget/packages
      # Look to see if there is a cache hit for the corresponding requirements file
      key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
      restore-keys: |
        ${{ runner.os }}-nuget

  - name: Build key file
    env:
      CERT_FILE: ${{ secrets.CERT_FILE }}
    shell: bash
    run: |
      echo "$CERT_FILE" > sideloading.base64
      certutil -decode sideloading.base64 SideloadingMaster.pfx

  - name: Install dependencies Node.js
    run: npm ci --legacy-peer-deps

  - uses: GuillaumeFalourd/setup-windows10-sdk-action@v1.11

  - name: Install Framework
    run: |
      choco install dotnet4.6.1
      choco install dotnet4.6.1-devpack
      

  - name: Build Terminal
  #  run: dotnet build --nologo --configuration Release -p:PackageCertificateKeyFile="SideloadingMaster.pfx" windows/project.sln
    run: msbuild .windows\project.sln /nologo -verbosity:minimal /p:Configuration=Release /p:Platform=x64 /p:AppxBundle=Never /bl /p:PackageCertificateKeyFile="SideloadingMaster.pfx" /p:RestorePackagesConfig=true /t:restore,build

I'm not sure what is wrong here and i'm not a .NET guy. So please help me someone.

MaddEye
  • 691
  • 4
  • 17

2 Answers2

1

I fixed it myself.

It seems that the setup-node and the setup-msbuild actions where causing the problems. The windows runner comes with both preinstalled and the setup actions are messing with it. But you still have to install the correct windows sdk if it is not listed in the Gather environment info step

Here is the working workflow file:

name: Build

on: [push]

jobs:
  build:
    name: "Build Termnial"

    runs-on: windows-2019

    steps:
      - uses: actions/checkout@v3

      - name: Gather environment info
        run: npx envinfo

      - name: Decode pfx file
        run: |
          $PfxBytes = [System.Convert]::FromBase64String("${{ secrets.CERT_FILE }}")
          $PfxPath = [System.IO.Path]::GetFullPath("${{github.workspace}}\SideloadingMaster.pfx")
          Write-Host $PfxPath
          [System.IO.File]::WriteAllBytes("$PfxPath", $PfxBytes)

      - name: Install dependencies Node.js
        run: npm ci --legacy-peer-deps
 
      - uses: GuillaumeFalourd/setup-windows10-sdk-action@v1.11
        with:
          sdk-version: 18362

      - name: Build React Native
        run: npx react-native run-windows --no-packager --no-launch --arch x64 --release --verbose --logging --msbuildprops PackageCertificateKeyFile="SideloadingMaster.pfx"

Got this information here microsoft/react-native-windows-samples within the .github folder.

And thanks to VonC for trying to help me.

MaddEye
  • 691
  • 4
  • 17
0

As in GuillaumeFalourd/setup-windows10-sdk-action issue 3, check if the action shows the default 18362 SDK did download successfully.

If you have any error message ("iso was not found") or "The remote server returned an error: (400) Bad Request", that would explain why the rest of the action does not find that SDK.

You can also add an additional step to list the installed Windows SDKs. This will help to debug and identify if the required SDK version is installed correctly.

- name: List installed Windows SDKs
  run: |
    & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -products * -requires Microsoft.VisualStudio.Component.Windows10SDK -property installationPath
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Not the case. Got a done for downloading and installing. The command you wrote gave back ```C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise``` – MaddEye May 09 '23 at 10:00
  • Would using `vcvarsall.bat` before the msbuild help? (as in [this answer](https://stackoverflow.com/a/68720886/6309)) – VonC May 09 '23 at 10:23
  • Still same error – MaddEye May 09 '23 at 14:26
  • @MaddEye Do you have a `(my_project).vcxproj` file? And if yes, do you have in it a `WindowsTargetPlatformVersion` element? – VonC May 09 '23 at 15:25
  • Yes. The Solution exists abut it seems i don't have a WindowsTargetPlatformVersion. – MaddEye May 10 '23 at 05:45
  • @MaddEye Can you try and add in that file a `10.0.18362.0`? Then re-run your GitHub Actions workflow without the `/p:WindowsSDKVersion=10.0.18362.0` flag in the "Build Terminal" step. – VonC May 10 '23 at 05:48
  • Sadly the same result – MaddEye May 10 '23 at 06:19