目次

指定された RuntimeIdentifier 'win10-arm' で利用できる Microsoft.WindowsDesktop.App.WindowsForms のランタイム パックがありませんでした。エラーが発生しビルドできない

ビルド時に「指定された RuntimeIdentifier 'win10-arm' で利用できる Microsoft.WindowsDesktop.App.WindowsForms のランタイム パックがありませんでした。」のエラーが出る場合の対処法を紹介します。

現象

ビルド時に以下のエラーが発生します。
エラーメッセージ
NETSDK1082
指定された RuntimeIdentifier 'win10-arm' で利用できる Microsoft.WindowsDesktop.App.WindowsForms のランタイム パックがありませんでした。
C:\Program Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets
または
エラーメッセージ
NETSDK1082
指定された RuntimeIdentifier 'win10-arm' で利用できる Microsoft.WindowsDesktop.App のランタイム パックがありませんでした。
C:\Program Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets

英語では以下のメッセージになります。
エラーメッセージ
NETSDK1082
There was no runtime pack for Microsoft.WindowsDesktop.App.WindowsForms available for the specified RuntimeIdentifier 'win-arm64'.
C:\Program Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets
または
エラーメッセージ
NETSDK1082
There was no runtime pack for Microsoft.WindowsDesktop.App available for the specified RuntimeIdentifier 'win-arm64'.
C:\Program Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets

対処法

プロジェクトファイルを編集し、RuntimeIdentifiers タグを追加します。

<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
または
<RuntimeIdentifiers>win10-x86;win10-x64</RuntimeIdentifiers>
を追加します。
また、ターゲットプラットフォームから ARMを外します。
プロジェクトファイル(編集前)
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWindowsForms>true</UseWindowsForms>
    <ImplicitUsings>enable</ImplicitUsings>
    <Platforms>arm;x64</Platforms>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.4" />
  </ItemGroup>

</Project>
プロジェクトファイル(編集後)
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWindowsForms>true</UseWindowsForms>
    <ImplicitUsings>enable</ImplicitUsings>
    <Platforms>x86;x64</Platforms>
    <RuntimeIdentifiers>win10-x86;win10-x64</RuntimeIdentifiers>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.4" />
  </ItemGroup>

</Project>
プロジェクトファイル(編集後)
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWindowsForms>true</UseWindowsForms>
    <ImplicitUsings>enable</ImplicitUsings>
    <Platforms>x64</Platforms>
    <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.4" />
  </ItemGroup>

</Project>

変更後プロジェクトをビルドしエラーが解消されることを確認します。

著者
iPentecのメインプログラマー
C#, ASP.NET の開発がメイン、少し前まではDelphiを愛用
最終更新日: 2023-02-05
作成日: 2022-08-12
iPentec all rights reserverd.