👮
COMコンポーネントを使ったC#アプリケーションをコマンドプロンプトからビルドする
$ dotnet build
Restore complete (0.3s)
TestProject failed with 1 error(s) (0.0s)
/usr/local/share/dotnet/sdk/9.0.304/Microsoft.Common.CurrentVersion.targets(3081,5): error
MSB4803: The task "ResolveComReference" is not supported on the .NET Core version of MSBuild.
Please use the .NET Framework version of MSBuild. See https://aka.ms/msbuild/MSB4803 for further details.
結論としては、dotnet build はCOMコンポーネントへの参照(ResolveCOMReference)に非対応なのでmsbuildを使うのが正解。なぜこんなことに。
$ msbuild -t:clean -t:restore -t:build
とかすればいいです。restoreタスクはnuget restore相当。
restoreしない場合、clean後にbuildした際エラーが出ます:
(ResolvePackageAssets target) ->
C:\Program Files\dotnet\sdk\9.0.304\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5):
error NETSDK1064: Package AWSSDK.S3, version 4.0.6.8 was not found. It might have been deleted since NuGet restore.
Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions.
Discussion