やってみる

アウトプットすべく己を導くためのブログ。その試行錯誤すらたれ流す。

Raspbian stretch MonoDevelop .NET Core で コンソールアプリ プロジェクトがエラーになる(Error: NETSDK1061)

 なんでや!

前回

 libe_sqlite3.soファイルを作成して実行ファイルのディレクトリに配置することで「System.DllNotFoundException: e_sqlite3」エラーは解決した。が、Microsoft.Data.Sqlite.SqliteException: SQLite Error 1: 'no such table: *'.のエラーが解決できない。

今回

 一旦Eto.Formをやめて単純なコンソールプロジェクトで試そうとしたら、デフォルトのプロジェクトすらビルドできない有様。

対象環境

手順

  1. MonoDevelopを起動する
  2. メニュー→ファイル新しいソリューション
    f:id:ytyaru:20181201194454p:plain
  3. .NET Coreアプリコンソールアプリケーションを選択する
    f:id:ytyaru:20181216125630p:plain
  4. プロジェクトを右クリックしてオプションをクリックする
  5. ビルド全般ターゲットフレームワーク.NET Core 1.1(インストールされていません)で固定になって変えられないことを確認する
    f:id:ytyaru:20181216125726p:plain

 なんでや! .NET Core 2.2 入れたのにダメなの? まだ何か必要なの?

Error: NETSDK1061

 実行ボタンを押すと以下の警告とエラー。

f:id:ytyaru:20181216130548p:plain

警告

/tmp/work/Projects/EFCore0/EFCore0/EFCore0.csproj: Warning NU1604: Project dependency Microsoft.NETCore.App does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results. (NU1604) (EFCore0)

エラー

/tmp/work/Projects/EFCore0/EFCore0/EFCore0.csproj: Error: NETSDK1061: The project was restored using Microsoft.NETCore.App version 1.0.0, but with current settings, version 1.1.2 would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. (EFCore0)

 .csprojファイルでバージョンを変更しても、同様のエラー。

<!--    <TargetFramework>netcoreapp1.1</TargetFramework>-->
    <TargetFramework>netcoreapp2.0</TargetFramework>
/tmp/work/Projects/EFCore0/EFCore0/EFCore0.csproj: Error: NETSDK1061: The project was restored using Microsoft.NETCore.App version 1.0.0, but with current settings, version 2.0.0 would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection. (EFCore0)

 ググっても解決せず。どうすりゃいいの?

 .csprojに以下のいずれかを追加すればいいとある。

<PropertyGroup>
  <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
 <PropertyGroup>
   <RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion>
   <PlatformTarget>AnyCPU</PlatformTarget>
   <RuntimeIdentifier>win-x64</RuntimeIdentifier>
 </PropertyGroup>

 以下が元の.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>
</Project>

 <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>を追加したが同様のエラー。

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
  </PropertyGroup>
</Project>

Error: NETSDK1047

 <RuntimeFrameworkVersion>などを追加したら別のエラーになった。

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>

    <RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <RuntimeIdentifier>arm32</RuntimeIdentifier>
  </PropertyGroup>

</Project>

 <RuntimeIdentifier>の値をlinux-arm32にしても同様。

f:id:ytyaru:20181217072032p:plain

/home/pi/root/lib/.NETCore/2.2.101/sdk/2.2.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(5,5): Error NETSDK1047: Assets file '/tmp/work/Projects/HelloCoreConsole/HelloCoreConsole/obj/project.assets.json' doesn't have a target for '.NETCoreApp,Version=v1.1/arm32'. Ensure that restore has run and that you have included 'netcoreapp1.1' in the TargetFrameworks for your project. You may also need to include 'arm32' in your project's RuntimeIdentifiers. (NETSDK1047) (HelloCoreConsole)

 <TargetFramework>netcoreapp2.2</TargetFramework>にしてもダメ。

 <TargetFrameworks>netstandard2.0</TargetFrameworks>に変更したら、.exeでなく.dllを出力してしまう。

Invalid framework identifer ''.

 <TargetFrameworks>の値一覧。もし<TargetFrameworks>をなくすと以下のように怒られる。

Invalid framework identifer ''.

f:id:ytyaru:20181217080738p:plain

所感

 次々と可能性を潰されていく。